Bug Report Checklist
Description
For an OpenAPI 3.1 spec with a property type: boolean + const: true, the Kotlin generator (kotlin client, jvm-ktor library) emits an inline enum class typed as kotlin.Boolean but populates the single enum entry with a String literal. The generated file does not compile.
Related but distinct: #10445 (request for const keyword), #22398 (missing validation for const). Neither covers the Kotlin-specific compile failure.
openapi-generator version
Reproduced on 7.14.0 and 7.21.0.
OpenAPI declaration file content or url
openapi: 3.1.0
info:
title: Repro
version: 1.0.0
paths: {}
components:
schemas:
ExceptionPeriod:
type: object
required: [startDate, endDate]
properties:
startDate: { type: string, format: date }
endDate: { type: string, format: date }
isClosed:
type: boolean
const: true
description: Marker flag; when present always true.
Generation Details
kotlin client generator, jvm-ktor library (default options).
Steps to reproduce
- Run codegen against the spec above.
- Compile the generated Kotlin.
Actual output
enum class ExceptionPeriodIsClosed(@get:JsonValue val value: kotlin.Boolean) {
@JsonProperty(value = "true")
`true`("true"); // String passed where Boolean required
...
}
e: ExceptionPeriodIsClosed.kt:41:12 Argument type mismatch: actual type is 'String', but 'Boolean' was expected.
Expected output
Either:
Suggest a fix
In the Kotlin inline-enum promotion path, type-check the enum value and emit the literal matching the declared type, not always "$value" as a String.
Bug Report Checklist
Description
For an OpenAPI 3.1 spec with a property
type: boolean+const: true, the Kotlin generator (kotlinclient,jvm-ktorlibrary) emits an inline enum class typed askotlin.Booleanbut populates the single enum entry with aStringliteral. The generated file does not compile.Related but distinct: #10445 (request for
constkeyword), #22398 (missing validation forconst). Neither covers the Kotlin-specific compile failure.openapi-generator version
Reproduced on 7.14.0 and 7.21.0.
OpenAPI declaration file content or url
Generation Details
kotlinclient generator,jvm-ktorlibrary (default options).Steps to reproduce
Actual output
Expected output
Either:
true(Boolean) instead of"true"(String), orconston a boolean to an enum at all — emitval isClosed: kotlin.Boolean? = null(a single-valued boolean is triviallytrue; validation can be tracked separately per [BUG] Missing validation forconstkeyword in generated code #22398).Suggest a fix
In the Kotlin inline-enum promotion path, type-check the enum value and emit the literal matching the declared
type, not always"$value"as a String.