[kotlin] Fix boolean const enum literal generation

Merged
SC
5mo ago
+46-1

Fixes #23550.

This keeps Kotlin boolean enum/const values as boolean literals when rendering enum values. Before this change, const: true could generate a Kotlin enum entry with "true" even though the enum value type is kotlin.Boolean.

I added a focused toEnumValue assertion and a generated-output regression fixture for the reported OpenAPI 3.1 boolean const: true case.

Tests:

  • ./mvnw clean package
  • ./bin/generate-samples.sh ./bin/configs/*.yaml
  • ./bin/utils/export_docs_generators.sh

Kotlin technical committee: @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l @dennisameling


Summary by cubic

Ensure Kotlin boolean const enums are generated as boolean literals, not strings. Fixes #23550.

  • Bug Fixes
    • Updated toEnumValue to pass through values for kotlin.Boolean (like kotlin.Int/kotlin.Long).
    • Added unit and generator tests for OpenAPI 3.1 const: true with jvm-ktor and jackson, plus a regression fixture (issue23550-boolean-const.yaml).