Skip to content

[kotlin] Support @Deprecation annotation for kotlin-spring generator#23104

Merged
wing328 merged 5 commits intoOpenAPITools:masterfrom
eugeniyk:support-deprecation-for-kotlin-spring
Mar 3, 2026
Merged

[kotlin] Support @Deprecation annotation for kotlin-spring generator#23104
wing328 merged 5 commits intoOpenAPITools:masterfrom
eugeniyk:support-deprecation-for-kotlin-spring

Conversation

@eugeniyk
Copy link
Copy Markdown
Contributor

@eugeniyk eugeniyk commented Mar 3, 2026

OpenAPI operations marked as deprecated: true were not emitting @Deprecated in the generated Kotlin Spring output. The annotation was missing from both the default controller mode (api.mustache) and the interface-only/delegate-pattern mode (apiInterface.mustache).

Related issues: #12804

Changes:

  • Added {{#isDeprecated}}@Deprecated{{/isDeprecated}} to api.mustache (generates *Controller.kt) and apiInterface.mustache (generates *.kt interface), placed immediately before @RequestMapping - consistent with the existing pattern
  • Added tests

Summary by cubic

Adds @deprecated(message="Operation is deprecated") to generated Kotlin Spring endpoints when an OpenAPI operation has deprecated: true. Applies to controllers, interfaces, and services.

  • Bug Fixes
    • Inserted the annotation before @RequestMapping in api.mustache and apiInterface.mustache; added on service methods in service.mustache.
    • Added tests for interface-only and controller modes using support-deprecated-api.yaml, asserting the message attribute.
    • Regenerated Kotlin Spring server samples to include the annotation across controller, interface, and service outputs.

Written for commit 66b9219. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

2 issues found across 4 files

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="modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache:106">
P1: Generated Kotlin emits `@Deprecated` without required `message`, causing compile errors for deprecated operations.</violation>
</file>

<file name="modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache">

<violation number="1" location="modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache:91">
P2: Bare `@Deprecated` in Kotlin template will resolve to `kotlin.Deprecated`, which requires a mandatory message parameter, causing generated controllers for deprecated operations to fail compilation.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread modules/openapi-generator/src/main/resources/kotlin-spring/apiInterface.mustache Outdated
Comment thread modules/openapi-generator/src/main/resources/kotlin-spring/api.mustache Outdated
@eugeniyk eugeniyk changed the title Support @Deprecation annotation for kotlin-spring generator [kotlin] Support @Deprecation annotation for kotlin-spring generator Mar 3, 2026
@wing328
Copy link
Copy Markdown
Member

wing328 commented Mar 3, 2026

lgtm. thanks for the PR

@wing328 wing328 merged commit 0869cad into OpenAPITools:master Mar 3, 2026
62 of 63 checks passed
davidricodias pushed a commit to davidricodias/openapi-generator that referenced this pull request Mar 11, 2026
…penAPITools#23104)

* Add change to template with tests

* Update test

* Add required message attribute for Kotlin code

* Regenerate samples
@eugeniyk eugeniyk deleted the support-deprecation-for-kotlin-spring branch March 27, 2026 08:20
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.

2 participants