Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

openapi-generator cuts beginning of enum names in generated class

Openapi-generator cuts beginning of enum names starting with "SB_". I don’t understand why this happens or how to fix this.

This is a part of my openapi.yaml:

...
sb:
  type: string
  enum:
    - SB_150_150
    - SB_300_150
...

This is the generated class:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  public enum SbEnum {
    ...
    _150_150("SB_150_150")
    _300_150("SB_300_150")
    ...
  }

When I delete the first underscore from the first enum name the rest of enum names is generated correctly.

How can I achieve a result like this?

  public enum SbEnum {
    ...
    SB_150_150("SB_150_150")
    SB_300_150("SB_300_150")
    ...
  }

>Solution :

I tried to replicate your issue as I was working with openapi-generator at the moment, and I encountered the same issue. What resolved it for me was including extra option in the plugin configuration block in my pom.xml as follows

<configuration>
        <additionalProperties>removeEnumValuePrefix=false</additionalProperties>
</configuration>

Hope that helps in your case as well, hopefully you don’t need those prefixes actually removed somewhere else.

I am using version 6.4.0 of the openapi-generator-maven-plugin

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading