openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

`snake_case` parameters should not auto convert to `camelCase`

Open wei opened this issue 4 years ago • 4 comments

Describe the bug Currently, snake_case parameters are automatically translated to camelCase in the method signature leading to inconsistencies especially if the snake_case is what's being used elsewhere in the request and response data.

Currently: image

Ideally we should have an option to keep it intact like so: image

Is there any way to turn this feature off? Thank you!

wei avatar Apr 06 '21 18:04 wei

@wei it's a good question. Originally i wanted to convert the properties to a more default formatting that we are used to in Typescript projects. I see a lot of REST API specs out there that have 'weird' (subjective i know) variable names. We could decide not to convert these properties (or only convert them when the formatting is incompatible with Typescript)... Need to check if that would create any big issues.

ferdikoomen avatar Apr 27 '21 11:04 ferdikoomen

Perhaps we can use something like this to check the validity of the variable names:

https://github.com/shinnn/is-var-name/blob/master/index.js

wei avatar Apr 27 '21 12:04 wei

My main complaint is that they are different between requests and responses, so if we have one API to get some model and another to update the model, we may need to manually convert all field names to camelCase when updating.

To me, it's also acceptable if the response field names are also being automatically converted, to conform team-wise variable naming schema.

yume-chan avatar Apr 28 '21 10:04 yume-chan

still bug here without option to stay with original snake case parameters

Dimon70007 avatar Jun 30 '22 20:06 Dimon70007