openapi-typescript-codegen
openapi-typescript-codegen copied to clipboard
Transform properties name from snake_case to camelCase
Hello,
Is there a way to transform response property name from snake_case to camelCase for API response models ?
We use Python on the server which uses snake_case
and following standards we like JSON
responses to be in camelCase
, turns out that this isn't the responsibility of the api client generator (we use OTC codegen).
The Open API schema is meant to expose what the code generators use to build the API client, and it's the responsibility of the server layer to transpose between snake_case
and camelCase
.
In our case we use FastAPI and translate between when we get the JSON payload and when the Pydantic models are exposed. I have documented this here.
I also recommend reading this article (if you are using Python) - CamelCase Models with FastAPI and Pydantic.
Hopefully it points you in the right direction.