Description
When generating kotlin code using "kotlin-spring" generator, and one of the fields in API specs is string with enum type:
Issue:
type: object
properties:
operator:
type: string
enum: [ One, Two ]
generated code contains backtick "`" encoded as HTML entity: `:
@field:JsonProperty("operator") val `operator`: Issue.`Operator`? = null,
Obviously, compiler has issue with that :)
openapi-generator version
5.3.0
Not regresion, I have checked 5.2.0 and 4.3.1 and all suffer from same issue. But 5.3.0 has expanded keyword list and operator and value (which we use) are escaped now.
For basic fun keyword it fails the same way in all versions.
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Kotlin Issue
version: "1.0"
paths:
/issue:
get:
tags:
- Issue
responses:
'200':
description: Issue
content:
application/json:
schema:
$ref: '#/components/schemas/Issue'
components:
schemas:
Issue:
type: object
properties:
ok:
type: string
enum: [ One, Two ]
operator:
type: string
enum: [ One, Two ]
fun:
type: string
enum: [ One, Two ]
value:
type: string
enum: [ One, Two ]
Command line used for generation
gradle plugin with options:
configOptions.putAll(mapOf(
"library" to "spring-boot",
"serializationLibrary" to "jackson",
"interfaceOnly" to "true",
"delegatePattern" to "true",
"useBeanValidation" to "true",
"sourceFolder" to "src/main/kotlin",
"enumPropertyNaming" to "original"
))
Steps to reproduce
generate code and open Issue.kt, it will be like:
data class Issue(
@field:JsonProperty("ok") val ok: Issue.Ok? = null,
@field:JsonProperty("operator") val `operator`: Issue.`Operator`? = null,
/* snip */
) {
enum class `Operator`(val value: kotlin.String) {
@JsonProperty("One") One("One"),
@JsonProperty("Two") Two("Two");
}
}
Related issues/PRs
Suggest a fix/enhancement
Description
When generating kotlin code using "kotlin-spring" generator, and one of the fields in API specs is string with enum type:
generated code contains backtick "`" encoded as HTML entity:
`:Obviously, compiler has issue with that :)
openapi-generator version
5.3.0
Not regresion, I have checked 5.2.0 and 4.3.1 and all suffer from same issue. But 5.3.0 has expanded keyword list and
operatorandvalue(which we use) are escaped now.For basic
funkeyword it fails the same way in all versions.OpenAPI declaration file content or url
Command line used for generation
gradle plugin with options:
Steps to reproduce
generate code and open
Issue.kt, it will be like:Related issues/PRs
Suggest a fix/enhancement