swagger-api / swagger-api/swagger-codegen-generators
[Java] Enums are renamed - why??
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Description
Enum values are renamed in generated Java classes - compared to what I write in the schema.
This "feature" was already reported several times (in the swagger-codegen project)
- https://github.com/swagger-api/swagger-codegen/issues/5932
- https://github.com/swagger-api/swagger-codegen/issues/7725
but I just noticed this now by my own.
I found even a closed MR (in the swagger-codegen project at least)
- https://github.com/swagger-api/swagger-codegen/pull/4331
which seems to touch this topic (and code looks good)
but this option/if/ whatever is not present in DefaultCodegenConfig
My question first of all would be: why? Why was such a mechanism introduced at all?
What do I miss?? What is the benefit / intention by doing this?
Does anyone know the answer for this?
In DefaultCodegenConfig there is a method findCommonPrefixOfVars() which is used in Enums generation and at the end of the day leads to renaming Enums.
Since this thing is sitting in DefaultCodegenConfig although not verified maybe happening in other languages too not just Java. For Java it is there for sure.
Version
1.0.36-SNAPSHOT (current master - when I file this problem)
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 DefaultCodegenConfig.findCommonPrefixOfVars() and trace how it is used during Java enum generation. Compare the generated enum names with the schema values, then review the referenced swagger-codegen issues and pull request for the intended behavior. Done requires a documented decision about whether renaming is expected and a clearly scoped change or regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100