Openapi-generator: [REQ][Java] Enum name should have underscore in case the value is pascal case

Created on 19 Dec 2019  路  3Comments  路  Source: OpenAPITools/openapi-generator

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.

Feature Enum

Most helpful comment

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

All 3 comments

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

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

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

Was this page helpful?
0 / 5 - 0 ratings