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

[REQ][Java] Enum name should have underscore in case the value is pascal case #4837

Open
zawataki opened this issue Dec 19, 2019 · 4 comments · May be fixed by #18594
Open

[REQ][Java] Enum name should have underscore in case the value is pascal case #4837

zawataki opened this issue Dec 19, 2019 · 4 comments · May be fixed by #18594

Comments

@zawataki
Copy link

Is your feature request related to a problem? Please describe.

If string enum value in OpenAPI definition is pascal case, the enum name on generated Java client will be named without underscores like below:

  public enum StatusEnum {
    WAITINGFORSOMETHING("WaitingForSomething"),

Describe the solution you'd like

I think that should be named with underscores for readability like below:

  public enum StatusEnum {
    WAITING_FOR_SOMETHING("WaitingForSomething"),

Describe alternatives you've considered

Nothing.

Additional context

Nothing.

@jmini
Copy link
Member

jmini commented Dec 30, 2019

Describe alternatives you've considered

You could use x-enum-varnames to influence the name of the enum:

Status:
  type: string
  enum:
    - WaitingForSomething
    - Done
  x-enum-varnames:
    - WAITING_FOR_SOMETHING
    - DONE

@zawataki
Copy link
Author

@jmini Thank you for letting me know the alternative. I will try it.

@afwlehmann
Copy link

@jmini Thanks a lot! I couldn't find this in the docs, though.

@xuanswe
Copy link

xuanswe commented May 12, 2021

In the doc of kotlin-spring generator:

enumPropertyNaming: Naming convention for enum properties: 'camelCase', 'PascalCase', 'snake_case', 'UPPERCASE', and 'original'

What we need is SCREAMING_SNAKE_CASE for all generators related to Java and Kotlin.

renatomameli added a commit to renatomameli/openapi-generator that referenced this issue May 7, 2024
renatomameli added a commit to renatomameli/openapi-generator that referenced this issue May 7, 2024
renatomameli added a commit to renatomameli/openapi-generator that referenced this issue May 7, 2024
renatomameli pushed a commit to renatomameli/openapi-generator that referenced this issue May 16, 2024
renatomameli added a commit to renatomameli/openapi-generator that referenced this issue May 17, 2024
renatomameli pushed a commit to renatomameli/openapi-generator that referenced this issue May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants