Skip to content

[kotlin] Fix inline enum array parameter default values - #24940

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
TanbirRamim:kotlin-enum-array-default
Sep 14, 2026
Merged

wing328 merged 1 commit into
OpenAPITools:masterfrom
TanbirRamim:kotlin-enum-array-default

Conversation

@TanbirRamim

@TanbirRamim TanbirRamim commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #24851. An array parameter with inline enum items and a default was rendered with an enum class that doesn't exist for operation parameters, and jvm-ktor then mangled it into something like Set<Colors>.setOfLeft_Parenthesis.... Parameter defaults for these arrays now use the plain item values (setOf("red","blue")), which fixes jvm-ktor, jvm-volley and kotlin-server javalin5/javalin6; arrays of referenced enums keep Color.RED. I added tests in KotlinClientCodegenApiTest and KotlinServerCodegenTest that fail without the change, and ran all tests under org.openapitools.codegen.kotlin (565 run, 0 failures). The enum-typed client libraries (okhttp4, vertx, spring, multiplatform, retrofit2) still render ColorsGetItems.setOf(red,blue) for this case through their templates, which is left for a separate change.

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    Regenerated bin/configs/kotlin*.yaml (124 configs); no sample output changed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

cc @karismann @Zomzog @andrewemery @4brunu @yutaka0m @stefankoppier @e5l


Summary by cubic

Fixes inline enum array parameter defaults so they render plain item values instead of referencing a nonexistent enum class.

  • Array parameters with inline enum items and defaults now generate setOf("red","blue"); referenced enum items keep Color.RED.
  • Fixes jvm-ktor, jvm-volley, and javalin5/javalin6; enum-typed client libraries (okhttp4, vertx, spring, multiplatform, retrofit2) are left for a separate change.
  • Adds regression tests for both client and server codegen, and a new test resource spec for the case.

Written for commit 0421d71. Summary will update on new commits.

Review in cubic

An array parameter with inline enum items and a default was rendered as an
enum class reference that does not exist for operation parameters, and the
jvm-ktor client then mangled it further into an invalid identifier.
Parameter defaults for such arrays now use the plain item values, e.g.
setOf("red","blue"), which fixes jvm-ktor, jvm-volley and javalin5/6.

Fixes OpenAPITools#24851
Copilot AI lite review requested due to automatic review settings September 13, 2026 00:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Re-trigger cubic

@wing328

wing328 commented Sep 14, 2026

Copy link
Copy Markdown
Member

thanks for the pr

i was able to repeat the issue and confirmed the fix.

@wing328
wing328 merged commit 5a0fa87 into OpenAPITools:master Sep 14, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][KOTLIN][jvm-ktor] Inline enum array default generates invalid Kotlin -> compile error

3 participants