fabien0102 / openapi-codegen

A tool for generating code base on an OpenAPI schema.
511 stars 64 forks source link

Changing default case of schema properties #118

Open stefanbartos opened 2 years ago

stefanbartos commented 2 years ago

Hi,

I have a question about changing the case of generated schema properties.

Our OpenApi specification is generated from .NET API. Since all exported object properties have pascal case by default, generated schemas have also pascal, which is not TS/JS convention. It can be solved by these suggestions.



Which option is better? If none, how should solve this issue?

Thx for your answers.
MbBrainz commented 1 year ago

You'd still need a conversion from what the api returns to your casing though. I was looking for a option to set the casing to camelcase, but the api returns snake_case. If you then generate the types in CamelCase, the conversion from the snake_case json to your CamelCase types would fail.

I would love to see this problem worked out though!

Rendez commented 2 months ago

You'd still need a conversion from what the api returns to your casing though. I was looking for a option to set the casing to camelcase, but the api returns snake_case. If you then generate the types in CamelCase, the conversion from the snake_case json to your CamelCase types would fail.

I would love to see this problem worked out though!

And then there's the complexity of tracking fields in request bodies which are actually part of the schema, to not just blindly camelCase everything recursively, but just those keys that are part of the OAS (additionalProperties: true)