Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Java] Error when using property of type boolean with enum #9005

Open
5 of 6 tasks
jvs64893 opened this issue Mar 18, 2021 · 0 comments
Open
5 of 6 tasks

[BUG][Java] Error when using property of type boolean with enum #9005

jvs64893 opened this issue Mar 18, 2021 · 0 comments

Comments

@jvs64893
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • 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);
    ...
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant