We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin generator produce a invalid kotlin file when shema have an enum with default value.
Unresolved reference: TypeEnum
5.2.1, master
openapi: 3.0.0 info: title: 'Enum Bug' version: latest paths: '/': get: operationId: demoBug responses: '200': description: Success content: application/json: schema: $ref: '#/components/schemas/MoveMovement' components: schemas: MoveMovement: required: - type properties: type: type: string default: MOVE enum: - MOVE
docker run --rm -v ${PWD}:/local --user "${USER_ID}:${GROUP_ID}" openapitools/openapi-generator-cli:latest generate -i /local/model.yaml -g kotlin -o /local/kotlin
Generate a model with an enum property with default value
The model constructor will have invalid kotlin code
data class MovementMoveMovement ( @Json(name = "type") val type: MovementMoveMovement.Type = TypeEnum.MOVE ) : MovementMovement { /** * * * Values: MOVE */ enum class Type(val value: kotlin.String) { @Json(name = "MOVE") MOVE("MOVE"); } }
should be
val type: MovementMoveMovement.Type = Type.MOVE
Similar to #10244
The regression was introduced by #9853 in 5.2.1
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
@Override public String toEnumName(CodegenProperty property) { return property.nameInCamelCase; }
I will try to submit a proper pull request with unit tests.
The text was updated successfully, but these errors were encountered:
Issue OpenAPITools#10591 kotlin enum defaultValue
796d0b3
Issue #10591 kotlin enum defaultValue (#10592)
11bfc66
* Issue #10591 kotlin enum defaultValue * Updated sample * Register sample Co-authored-by: Eric Durand-Tremblay <etremblay@kronostechnologies.com>
No branches or pull requests
Description
Kotlin generator produce a invalid kotlin file when shema have an enum with default value.
openapi-generator version
5.2.1, master
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Generate a model with an enum property with default value
The model constructor will have invalid kotlin code
should be
Related issues/PRs
Similar to #10244
The regression was introduced by #9853 in 5.2.1
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java
I will try to submit a proper pull request with unit tests.
The text was updated successfully, but these errors were encountered: