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] ON/OFF Enum values generated as boolean for scharp #16444

Open
RomanSoloweow opened this issue Aug 29, 2023 · 1 comment
Open

[BUG] ON/OFF Enum values generated as boolean for scharp #16444

RomanSoloweow opened this issue Aug 29, 2023 · 1 comment

Comments

@RomanSoloweow
Copy link

I have 3.0.1 Open api Spec with enum which constains ON/OFF values

    PowerState:
      type: string
      enum:
      - ON
      - OFF

It's generated as True/False for scharp rest client

@ssternal
Copy link

ssternal commented Sep 8, 2023

This not only affects C#, but also other generators like Java Spring. I followed the path where the enum values are coming from and ended up in Swagger's OpenAPI parser, i.e. it's not a problem of the OpenAPI generator itself, but from on of its dependencies. There is an issue for this swagger-api/swagger-parser#1205.

Workaround: Explicitly mark your enum values as strings. Example:

components:
  schemas:
    MyEnum:
      type: string
      enum:
        - "YES"
        - "NO"
        - "SOME_OTHER_VALUE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants