openapi-generator
openapi-generator copied to clipboard
[BUG][Java] Error when using property of type boolean with enum
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Generating from a model with a boolean property wich contains enums results in code that contains compile errors. I know that this is a rather stupid OpenAPI description, but it is nonetheless valid (and I sadly can't change the input spec I have to use).
openapi-generator version
5.0.1
OpenAPI declaration file content or url
"test": {
"type": "boolean",
"description": "Test",
"example": true,
"enum": [
true,
false
]
}
This results in:
public enum Test{
TRUE("true"),
FALSE("false");
...
}
Which fails to compile:
error: incompatible types: String cannot be converted to Boolean
TRUE("true"),
Generation Details
Java with any library results in this issue.
Steps to reproduce
Have any model contain a boolean property with enum values.
Related issues/PRs
None
Suggest a fix
The expected outcome should be:
public enum Test{
TRUE(true),
FALSE(false);
...
}