Skip to content

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

@adamzzza

Description

@adamzzza

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:

  • In GET requests, the client has to send enum values in upper-case because the server uses Enum.valueOf(String) to create an enum instance from request parameters. The valueOf method expects enum values in upper-case.
  • In POST requests, the client has to send enum values in lower-case because the server uses a generated fromValue method to create an enum instance from the request body. The fromValue method expects enum values in lower-case.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions