reduxjs / redux-toolkit

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

[RTKQ Code Gen OpenAPI] feature request: convert case styles of request and response parameters #2675

Open aidy1991 opened 2 years ago

aidy1991 commented 2 years ago

When generating codes from OpenAPI schema, the parameters of request body and response use the names defined in the schema as they are. For example, if a parameter is defined as a snake case, it is necessary to exceptionally write snake case in the TypeScript code. Since it is common to use camel case in TypeScript and JavaScript, we would like to use camel case in the code generated from OpenAPI schema.

phryneas commented 2 years ago

If this would be a configurable option, I think we'd accept a PR for this.

blwinters commented 1 year ago

I just started using the codegen functionality today and similar to above, we have snake_case on the Python backend and camelCase on the TypeScript clients.

I see that generate.ts does perform some camelCase conversion, but as I'm new to the package, the scope and intention of this conversion isn't clear to me. Which aspects of codegen does the camelCase conversion currently affect? That is, what does the existing conversion enable if the generated types are not being converted to camelCase?

I'd like to make a PR for this as a configurable option in the future. I'm just wondering what the best approach is in this mixed-case situation when using the codegen functionality as it stands.

blwinters commented 1 year ago

I also read through this issue, so it seems like some users are getting conversions (though undesired), so I'm not clear about the intended behavior and use.