OpenAPITools / OpenAPITools/openapi-generator
[BUG] ENUM Attribute Mapping - SPRING/JAVA - Spring generator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Relates to https://github.com/OpenAPITools/openapi-generator/issues/4837
With the recent Change, the Enum Validation for API generated for Microservices is not working anymore.
The Spring AbstractNamedValueArgumentResolver -> StringToEnumConverterFactory is using Name Mapping (via Enum.valueOf) to parse an Enum on Validation.
With the Change, the Name and The Value of the Enum can differ, so a ServerInput Error is raised
Example
OAS3 Enum Value: B2C
Before the Change, the Enum Constant is generated like this: B2C
After the Change, it is: B2_C
The StringToEnumConverterFactory in Spring fails to map now a request &something=B2C while a request with &something=B2_C is passing
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing Spring generator enum handling around AbstractNamedValueArgumentResolver and StringToEnumConverterFactory, using the related issue 4837 for context. Reproduce the generated Microservices case where OAS3 value B2C maps to constant B2_C, then verify that validation accepts B2C while preserving the generated enum naming.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100