swagger-api / swagger-api/swagger-codegen
[JAVA] Incorrect java code gen when enum has only one element
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
swagger-codegen-maven-plugin 2.2.2
"action" : {
"type" : "string",
"enum" : [ "MOVE_TO_GROUP" ]
},
Generates this
public enum ActionEnum {
GROUP("MOVE_TO_GROUP"),
...
Should be
public enum ActionEnum {
MOVE_TO_GROUP("MOVE_TO_GROUP"),
Work around - add dummy second element
"action" : {
"type" : "string",
"enum" : [ "MOVE_TO_GROUP", "UNSUPPORTED" ]
},
enum with one element makes no sense, but i think it should be fixed
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 swagger-codegen-maven-plugin and reproduce generation using the provided schema with a single-value enum. Trace the Java enum generation path and verify that the generated constant uses MOVE_TO_GROUP rather than GROUP; the workaround and expected output in the issue define done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100