OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
22.01k stars 6.6k forks source link

[REQ][Java][Server][Spring] Add support for enumPropertyNaming config option in spring server generator #18987

Open adamzzza opened 5 months ago

adamzzza commented 5 months ago

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

The enumPropertyNaming config option is not supported by the Spring server generator, and all enum properties are generated in upper-case. Having an enum with lower-case properties in the API definition causes the following problem:

Describe the solution you'd like

Implementation of the enumPropertyNaming option and setting it to the value 'original' (as in the Kotlin server) would resolve this problem. The generator would generate all enum properties as defined, without changing them to upper-case.

Additional context

The workaround for this problem is to implement a custom type converter for the enum, which uses the generated fromValue method instead of the enum's valueOf. This converter will be used instead of the default converter for request parameters. However, this is only a workaround for the problem.

wing328 commented 5 months ago

have you tried using enumNameMappings option to see if it meets your requirement?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping

adamzzza commented 5 months ago

have you tried using enumNameMappings option to see if it meets your requirement?

https://github.com/openapitools/openapi-generator/blob/master/docs/customization.md#name-mapping

I know that option, but it is also a kind of workaround. I need a resolution for the future, so when a new developer adds another enum, he won't have a problem with it. I had a situation where two developers got stuck on that problem.

asjp1970 commented 4 months ago

Same issue found and all the alternatives I bumped into seem to me workarounds affecting maintainability:

I think the best is to have enumPropertyNaming for java generator, as for several other generators.