Description
Description
Kotlin generator generates Kotlin enums with strange capitalization: it lower-cases the first enum item letter (e.g. generates rED
instead of RED
).
openapi-generator version
Generator Version 4.1.1
Spec Version 3.0.2
OpenAPI declaration file content or url
openapi: "3.0.2"
info:
version: "1.0.0"
title: Testing Kotlin generation
# We only care about schemas, but this prevents codegen error: "attribute paths is missing"
paths:
/dummy:
get:
responses:
'200':
description: OK
components:
schemas:
StatusColorEnum:
description: >
RGB.
type: string
enum:
- RED
- YELLOW
- GREEN
Command line used for generation
openapi-generator generate -i my-models.yml -g kotlin
NOTE: we actually use the Gradle plugin for code generation (org.openapi.generator
version 4.1.1
), but the above command-line tool gives the same result. However, we would like the fix to propagate to the Gradle plugin as well, so we can use in our build.
Steps to reproduce
Run the command above and inspect the generated StatusColorEnum.kt
. It will look like below:
package org.openapitools.client.models
import com.squareup.moshi.Json
/**
* RGB.
* Values: rED,yELLOW,gREEN
*/
enum class StatusColorEnum(val value: kotlin.String){
@Json(name = "RED")
rED("RED"),
@Json(name = "YELLOW")
yELLOW("YELLOW"),
@Json(name = "GREEN")
gREEN("GREEN");
}
Note the capitalization is very odd: instead of rED
it should really be just RED
.
Related issues/PRs
Not found.
Suggest a fix
Generate Kotlin enums with the same capitalization as given in the declaration file (do not lower case the first letter).