swagger-api / swagger-api/swagger-codegen
[Java] Models with arrays of inner number types are wrongly, uncompiable generated
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Models with arrays of inner number types are wrongly generated. Generally a number type with enum is generated as NUMBER_0(0).
If this number type with enum is part of an array it is generated as: _0("0") The NUMBER is missing and the value would be generated as String.
This doesn't even compile.
Swagger-codegen version
2.2.3
Swagger declaration file content or url
"ModelWithArrayHavingNumbersWithEnum": {
"type": "object",
"properties": {
"arrayWithNumbers": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"enum": [0, 1, 2]
}
}
}
}
Command line used for generation
..
Steps to reproduce
..
Related issues/PRs
#5712, #5619
Suggest a fix/enhancement
..
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
Use the supplied ModelWithArrayHavingNumbersWithEnum declaration to generate the Java model and inspect the array element enum output. Compare the generated constants with the non-array NUMBER_0(0) form and review related issues #5712 and #5619. Done means the generated Java compiles and preserves numeric enum values for array items.
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
- 35/100