reduxjs / redux-toolkit

The official, opinionated, batteries-included toolset for efficient Redux development
https://redux-toolkit.js.org
MIT License
10.64k stars 1.15k forks source link

RTK-Query Codegen: Camel case applied incorrectly in some situations #2181

Open sbward opened 2 years ago

sbward commented 2 years ago

In my API I use a variation of camel casing that preserves uppercase in abbreviations. For example, userId becomes userID. Normally this is interpreted as camel case and I would not expect any transformations to be applied to the string.

The issue is that RTK-Query Codegen uses the lodash camelCase function, which converts userID to userId. Lodash's behavior in this regard has been controversial (see https://github.com/lodash/lodash/issues/5045) and I think it would be better to use an alternative (like hump) which has the expected behavior.

Relevant code:

https://github.com/reduxjs/redux-toolkit/blob/2bb44b97dc290b70e3ef2502c743c9e90520fe50/packages/rtk-query-codegen-openapi/src/generate.ts#L218-L221

jenniferrethi commented 2 years ago

This is happening for us as well. Our generated types are all in camelCase but our models are in PascalCase so this is making it hard to actually use the generated types.