swagger-api / swagger-api/swagger-codegen
JAX-RS Swagger codegen does not handle enum defined in external json file
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
If an enum is added into external json file Swagger Codegen does not generate model correctly.
Example project: https://github.com/abhijith-prabhakar/swagger-ref-error-demo/blob/master/src/main/resources/v1/schema/title/title.json#L43
"media_types": {
"description": "different media types",
"type": "array",
"items" : {
"type" : "string",
"enum" : [ "application/pdf", "application/json" ]
}
},
Generated Code
/**
* different media types
*/
public enum List<MediaTypesEnum> {
PDF("application/pdf"),
JSON("application/json");
private List<String> value;
List<MediaTypesEnum>(List<String> value) {
this.value = value;
}
@Override
@JsonValue
public String toString() {
return String.valueOf(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
Start with the external schema at src/main/resources/v1/schema/title/title.json#L43 in the linked example project and inspect the generated JAX-RS enum shown in the issue. Trace how Swagger Codegen handles the external JSON definition and compare the generated model with the schema. Done means an external enum inside an array generates a valid Java model with the expected enum values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100