Skip to content

[kotlin] add additionalEnumTypeAnnotations option - #24987

Merged
wing328 merged 2 commits into
OpenAPITools:masterfrom
kdelay:fix/issue-24978-kotlin-enum-annotations
Sep 24, 2026
Merged

wing328 merged 2 commits into
OpenAPITools:masterfrom
kdelay:fix/issue-24978-kotlin-enum-annotations

Conversation

@kdelay

@kdelay kdelay commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #24978.

AbstractKotlinCodegen implements only additionalModelTypeAnnotations, and kotlin-server/libraries/jaxrs-spec/enum_class.mustache includes that partial, so an annotation valid only on classes is emitted on generated enums too and the output does not compile.

This adds additionalEnumTypeAnnotations to AbstractKotlinCodegen, mirroring AbstractJavaCodegen, and switches the jaxrs-spec enum template to it.

New test in KotlinServerCodegenTest: with both options set, the enum carries only the enum annotation and the data class only the model annotation. On master it fails at the first assertion (Type.kt does not contain line [@EnumOnlyAnnotation]).

./bin/generate-samples.sh bin/configs/kotlin*.yaml produces no sample changes; generator docs are regenerated.


Summary by cubic

Fixes #24978. additionalModelTypeAnnotations was applied to generated Kotlin enums too, causing compilation failures for annotations valid only on classes.

Adds additionalEnumTypeAnnotations to AbstractKotlinCodegen and switches the kotlin-server jaxrs-spec enum template to use it, so enum and model annotations stay separate.

  • Regenerates generator docs for the Kotlin generators, including ktorm-schema.
  • New test verifies enums receive only the enum annotation and data classes only the model annotation.

Written for commit 538104a. Summary will update on new commits.

Review in cubic

AbstractKotlinCodegen only implemented additionalModelTypeAnnotations, and the
kotlin-server jaxrs-spec enum_class template included that partial, so an
annotation that is only valid on classes was also emitted on generated enums
and the output did not compile.

Add additionalEnumTypeAnnotations to AbstractKotlinCodegen, mirroring
AbstractJavaCodegen, and let the jaxrs-spec enum template use it instead.

Fixes OpenAPITools#24978

@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 11 files

Re-trigger cubic

@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.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/generators/ktorm-schema.md">

<violation number="1" location="docs/generators/ktorm-schema.md:22">
P3: This row advertises an option that Ktorm does not render: `ktorm-schema/enum_class.mustache` never reads `additionalEnumTypeAnnotations`, so setting it has no effect. Remove the row or wire the Ktorm enum template to emit the option before documenting it.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|addSurrogateKey|Adds the surrogate key for all models that don't already have a primary key (named by the above convention)| |false|
|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|

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.

P3: This row advertises an option that Ktorm does not render: ktorm-schema/enum_class.mustache never reads additionalEnumTypeAnnotations, so setting it has no effect. Remove the row or wire the Ktorm enum template to emit the option before documenting it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/ktorm-schema.md, line 22:

<comment>This row advertises an option that Ktorm does not render: `ktorm-schema/enum_class.mustache` never reads `additionalEnumTypeAnnotations`, so setting it has no effect. Remove the row or wire the Ktorm enum template to emit the option before documenting it.</comment>

<file context>
@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
 | Option | Description | Values | Default |
 | ------ | ----------- | ------ | ------- |
 |addSurrogateKey|Adds the surrogate key for all models that don't already have a primary key (named by the above convention)| |false|
+|additionalEnumTypeAnnotations|Additional annotations for enum type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
 |additionalModelTypeAnnotations|Additional annotations for model type(class level annotations). List separated by semicolon(;) or new line (Linux or Windows)| |null|
 |artifactId|Generated artifact id (name of jar).| |ktorm|
</file context>

@wing328 wing328 added this to the 7.26.0 milestone Sep 24, 2026
@wing328
wing328 merged commit 217dbbf into OpenAPITools:master Sep 24, 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] [kotlin-server] [jaxrs-spec] additionalModelTypeAnnotations also added to generated enums

2 participants