[kotlin] add additionalEnumTypeAnnotations option - #24987
Merged
wing328 merged 2 commits intoSep 24, 2026
Merged
Conversation
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
Contributor
There was a problem hiding this comment.
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| |
Contributor
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24978.
AbstractKotlinCodegenimplements onlyadditionalModelTypeAnnotations, andkotlin-server/libraries/jaxrs-spec/enum_class.mustacheincludes that partial, so an annotation valid only on classes is emitted on generated enums too and the output does not compile.This adds
additionalEnumTypeAnnotationstoAbstractKotlinCodegen, mirroringAbstractJavaCodegen, 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*.yamlproduces no sample changes; generator docs are regenerated.Summary by cubic
Fixes #24978.
additionalModelTypeAnnotationswas applied to generated Kotlin enums too, causing compilation failures for annotations valid only on classes.Adds
additionalEnumTypeAnnotationstoAbstractKotlinCodegenand switches the kotlin-server jaxrs-spec enum template to use it, so enum and model annotations stay separate.ktorm-schema.Written for commit 538104a. Summary will update on new commits.