swagger-api / swagger-api/swagger-codegen
[Android/Java] Generating Enum Values
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When exporting to Android enums are generated as:
public enum GenderIdEnum {
0, 1, 2,
};
Versus a potential workaround:
public enum GenderIdEnum {
Zero(0), One(1), Two(2);
private int value;
private GenderIdEnum(int value) {
this.value = value;
}
public int getValue() {
return value;
}
};
Swagger-codegen version
Using: http://editor.swagger.io/#/
Loading from URL:
https://polling.arena.razerzone.com/swagger/docs/v1
Exporting to Android.
Importing to Android Studio.
Gradle reports the enum syntax error.
Steps to reproduce
-
File Import URL:
https://polling.arena.razerzone.com/swagger/docs/v1 -
Generate Client Android
-
Unpack zip file
-
Import as new project in Android Studio
-
See the gradle compile error
Related issues
https://github.com/swagger-api/swagger-codegen/issues/4279
Suggest a Fix
public enum GenderIdEnum {
Zero(0), One(1), Two(2);
private int value;
private GenderIdEnum(int value) {
this.value = value;
}
public int getValue() {
return value;
}
};
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
Reproduce the issue by importing the supplied Swagger URL in editor.swagger.io and generating an Android client. Inspect the generated Java enum and the Android generation template or entry point that produces it, then verify completion by importing the client into Android Studio and confirming that Gradle compiles without the enum syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100