gauee
gauee

Reputation: 305

Swagger avoid removing common prefix

How to skip removing the common prefix from modelsEnum name? I have got an enum with single value (in the future I will have more values) and swagger code gen plugin generates the class with enum CODE instead of AIRPORT_CODE

properties:
  type:
    enum: ["AIRPORT_CODE"]
    description: the type of location that is identified by the value

Upvotes: 5

Views: 4559

Answers (2)

r_benedikt
r_benedikt

Reputation: 54

You just need to overwrite the default configuration with: removeEnumValuePrefix=false

Examples:

Maven:

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

Gradle:

openApiGenerate {
   ...
   additionalProperties = [
      removeEnumValuePrefix: "false"
   ]
}

For more details you can also take a look here: https://github.com/OpenAPITools/openapi-generator/pull/5166

Upvotes: 1

Helen
Helen

Reputation: 97737

There's a pull request that adds the --use-enum-common-prefix argument to address this issue, but it's not merged into master yet (as of time of writing). You can follow issue #4261 for updates.

For now you can try rebuilding swagger-codegen yourself with this PR included, and use your custom build to generate the code.

Upvotes: 2

Related Questions