Bug Report Checklist
Description
When the enumPropertyNaming config option value differs from original (e.g. UPPERCASE) kotlin-spring generator produces
enum class TestEnumSpec(@get:JsonValue val value: kotlin.String) {
ABC("abc"),
DEF("def"),
GHK("ghk");
companion object {
@JvmStatic
@JsonCreator
fun forValue(value: kotlin.String): TestEnumSpec {
return values().first{it -> it.value == value}
}
}
}
for the mentioned spec.
However forValue is not used by Spring by default to convert String input into the TestEnumSpec query parameter and the exception is thrown
Caused by: java.lang.IllegalArgumentException: No enum constant my.package.TestEnumSpec.abc
at java.base/java.lang.Enum.valueOf(Enum.java:293) ~[?:?]
at org.springframework.core.convert.support.StringToEnumConverterFactory$StringToEnum.convert(StringToEnumConverterFactory.java:54) ~[spring-core-6.2.7.jar:6.2.7]
at org.springframework.core.convert.support.StringToEnumConverterFactory$StringToEnum.convert(StringToEnumConverterFactory.java:39) ~[spring-core-6.2.7.jar:6.2.7]
at org.springframework.core.convert.support.GenericConversionService$ConverterFactoryAdapter.convert(GenericConversionService.java:415) ~[spring-core-6.2.7.jar:6.2.7]
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41) ~[spring-core-6.2.7.jar:6.2.7]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:182) ~[spring-core-6.2.7.jar:6.2.7]
Java Spring generator seem to generate EnumConverterConfiguration to provide custom converters for the generated enums and force using forValue for conversion from String
openapi-generator version
7.12.0
OpenAPI declaration file content or url
schema
TestEnumSpec:
enum:
- abc
- def
- ghk
default: abc
then user in parameters as
- name: test
in: query
schema:
$ref: "#/components/schemas/TestEnumSpec"
Steps to reproduce
Create enum schema, use it as query parameter.
Use enumPropertyNaming=UPPERCASE config option for generation.
Related issues/PRs
The #12874 seems to be the similar issue for Java Spring generator
Bug Report Checklist
Description
When the
enumPropertyNamingconfig option value differs fromoriginal(e.g.UPPERCASE) kotlin-spring generator producesfor the mentioned spec.
However
forValueis not used by Spring by default to convert String input into theTestEnumSpecquery parameter and the exception is thrownJava Spring generator seem to generate EnumConverterConfiguration to provide custom converters for the generated enums and force using
forValuefor conversion fromStringopenapi-generator version
7.12.0
OpenAPI declaration file content or url
schema
then user in parameters as
Steps to reproduce
Create enum schema, use it as query parameter.
Use
enumPropertyNaming=UPPERCASEconfig option for generation.Related issues/PRs
The #12874 seems to be the similar issue for Java Spring generator