swagger-api / swagger-api/swagger-codegen
List of enums in Android generator results in broken enum definition
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
List of enums in Android generator results in broken enum definition.
Swagger-codegen version
2.3.1.
Swagger declaration file content or url
"ApplyCommunicationRecipeResult" : {
"properties" : {
"ok" : {
"type" : "boolean"
},
"errors" : {
"type" : "array",
"items" : {
"type" : "string",
"enum" : [
"NO_DISCOUNT_OR_BAD_DISCOUNT_TYPE",
"HAS_PRODUCT_RELATIONS",
"NOT_ONE_INPUT_PRODUCT",
"NOT_ONE_OUTPUT_PRODUCT",
"NOT_ONE_INPUT_BRAND",
"NOT_ONE_OUTPUT_BRAND",
"COMMUNICATION_HAS_RULES"
]
}
}
},
"type" : "object"
}
Command line used for generation
swagger-codegen generate -i spec.json -l android -o out
Steps to reproduce
Run generator with definition like above. The resulting code will look like
@ApiModel(description = "")
public class ApplyCommunicationRecipeResult {
public enum List<ErrorsEnum> {
NO_DISCOUNT_OR_BAD_DISCOUNT_TYPE, HAS_PRODUCT_RELATIONS, NOT_ONE_INPUT_PRODUCT, NOT_ONE_OUTPUT_PRODUCT, NOT_ONE_INPUT_BRAND, NOT_ONE_OUTPUT_BRAND, COMMUNICATION_HAS_RULES,
};
@SerializedName("errors")
private List<ErrorsEnum> errors = null;
// ...
}
Suggest a fix/enhancement
It works in the Java generator.
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
Run the swagger-codegen generate -i spec.json -l android -o out command with the declaration and inspect the generated ApplyCommunicationRecipeResult class. Compare the Android output with the Java generator, then verify that the enum declaration is valid Java while the errors field remains a typed list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100