acacode / acacode/swagger-typescript-api

Add an option to disable converting path params into camelCase

未關閉
#592 3 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
4.1k
分支
436
PR 合併指標
30 天內沒有已合併 PR

描述

If I have a snake_case path param in original schema like

```yaml
/some/{path_param}/:
...
parameters:
- name: path_param
in: path
required: true
type: string
```

then it'll be converted into camelCase in generated route (using `generateRouteTypes: true`):

```ts
'/some/{path_param}/': {
get: {
params: {
pathParam: number;
};
...
};
}
```

I guess I found this place and I see that this behavior is hard-coded:
https://github.com/acacode/swagger-typescript-api/blob/2b6db2346028fe6fb1f311bf5b1221a89837032e/src/schema-routes/schema-routes.js#L252

The problem is that in our project we don't want path params to be converted into camelCase. We expecting that they are stay as given by schema.

Would be nice to have an option for `generateApi` for disabling this converting. Something like

```ts
return generateApi({
generateRouteTypes: true,
pathParamsInCamelCase: false, // true by default for example
});
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。