Bug Report Checklist
Description
When generating models with default values, I have come across multiple bugs.
Arrays: default value is not respected
Strings: Is generated with " instead of " (double quote), which makes it not compile
Enums: Inline enums are generated with the wrong names, which makes it not compile. Note this one has a relatively easy workaround, define enums as separate schemas.
openapi-generator version
openapigenerator: 5.1.1
kotlin: 1.5.10
gradle: 7.1
OpenAPI declaration file content or url
Minimal schema
"Test": {
"title": "TestObject",
"type": "object",
"required": [ "testArray" ],
"properties": {
"stringDefault": {
"type": "string",
"default": "test"
},
"testArray": {
"type": "array",
"default": [],
"items": {
"type": "string"
}
},
"testArrayOptional": {
"type": "array",
"default": [],
"items": {
"type": "string"
}
},
"testEnum": {
"type": "string",
"enum": [ "A", "B", "C" ],
"default": "C"
}
}
}
Results
data class Test(
@field:JsonProperty("stringDefault", required = true) val stringDefault: kotlin.String = "test",
@field:JsonProperty("testArray", required = true) val testArray: kotlin.collections.List<kotlin.String>,
@field:JsonProperty("testArrayOptional") val testArrayOptional: kotlin.collections.List<kotlin.String>? = null,
@field:JsonProperty("testEnum") val testEnum: Test.TestEnum? = TestEnumEnum.c
) {
enum class TestEnum(val value: kotlin.String) { a("A"), b("B"), c("C") }
}
Generation Details
Using gradle
task generateExample(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
inputSpec = "$rootDir/test.json"
generatorName = "kotlin-spring"
outputDir = "$buildDir/generated/testing"
}
Related issues/PRs
Might be related to #8373
Bug Report Checklist
Description
When generating models with default values, I have come across multiple bugs.
Arrays: default value is not respected
Strings: Is generated with " instead of " (double quote), which makes it not compile
Enums: Inline enums are generated with the wrong names, which makes it not compile. Note this one has a relatively easy workaround, define enums as separate schemas.
openapi-generator version
openapigenerator: 5.1.1
kotlin: 1.5.10
gradle: 7.1
OpenAPI declaration file content or url
Minimal schema
Results
Generation Details
Using gradle
Related issues/PRs
Might be related to #8373