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
21.24k stars 6.43k forks source link

[BUG] ENUM Attribute Mapping - SPRING/JAVA - Spring generator #19086

Open SlinToWin opened 2 months ago

SlinToWin commented 2 months ago

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

mprins commented 2 months ago

caused by https://github.com/OpenAPITools/openapi-generator/issues/4837

Trebuac commented 2 months ago

Linked to https://github.com/OpenAPITools/openapi-generator/issues/19066