swagger-api / swagger-api/swagger-codegen
How to prevent changing model fields naming (swagger-codegen-cli.jar generate)
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hello, swagger-codegen Team,
I am investigating swagger-codegen API generation and using such script:
java -jar ./swagger-codegen-cli.jar generate -i ./.openapi3.json -l typescript-angular -o ./generated
As a result of the generation I am getting ApplicationUser model with a such field in camelCase - firstName:
But in our backend it is called first_name in snaked_case:
The trouble is that we are using typescript-angular and when the backend response is:
I cannot declare the field in a such way, because of the typescript
So it is not feasible to use the lib, because the generated models were changed, but the generated APIs returns the data in the same way how it is stored in the backend. Is it possible to prevent changing of the field names?
Best Regards
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shown swagger-codegen-cli.jar generate command, using ./.openapi3.json and the typescript-angular generator, and inspect the generated ApplicationUser model. Compare its firstName field with the backend's first_name response and determine whether generation can preserve the source name. Done means the generated model accepts the backend response without changing the field name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100