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 lodash/lodash#5045) and I think it would be better to use an alternative (like hump) which has the expected behavior.
Relevant code:
|
const isPureSnakeCase = /^[a-zA-Z][a-zA-Z0-9_]*$/.test(param.name); |
|
const camelCaseName = camelCase(param.name); |
|
|
|
const name = isPureSnakeCase && !allNames.includes(camelCaseName) ? camelCaseName : param.name; |
In my API I use a variation of camel casing that preserves uppercase in abbreviations. For example,
userIdbecomesuserID. 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
camelCasefunction, which convertsuserIDtouserId. Lodash's behavior in this regard has been controversial (see lodash/lodash#5045) and I think it would be better to use an alternative (like hump) which has the expected behavior.Relevant code:
redux-toolkit/packages/rtk-query-codegen-openapi/src/generate.ts
Lines 218 to 221 in 2bb44b9