Open lukas1 opened 3 weeks ago
The fact that Strings and not Enums are used in the parameters may not necessarily be a bug. Retrofit does not support enums for @FormUrlEncoded
properly, one would need to provide also some converter for them. Maybe it was intentional for @FormUrlEncoded
to use strings.
But the fact that when default value is provided the resulting code does not compile is a clear bug.
Bug Report Checklist
Description
There's an issue generating models for API spec that contains enums in request body for Kotlin and Retrofit 2. Enums are generated, but the request method then uses Strings as parameters. If a default value is provided, the result is even code that doesn't compile at all, because the default value doesn't have quotation marks for String.
openapi-generator version
7.9.0
OpenAPI declaration file content or url
Generation Details
Setup of the gradle task that fails to generate proper Kotlin code:
Steps to reproduce
Run the
openApiGenerateTestApi
task in the demo app provided here:OpenApiEnumBug.zip
Observe the generated Kotlin code of the file
DefaultApi.kt
Here's the generated file:
Notice how the
EnumPropTypeTestPost
is not used inside thetestPost
method, for theenumPropType
. A String is used as the type. On top of that, the default valuetest1
is not wrapped by quotation marks for a String parameter.This would be the expected result:
Related issues/PRs
I did not find anything related
Suggest a fix
No suggestion on my side