Skip to content

Conversation

@Picazsoo
Copy link
Contributor

@Picazsoo Picazsoo commented Jan 28, 2026

Provides a flexible mechanism to:

  • skip any unwanted interface(s) already defined via vendor extensions x-implements or x-kotlin-implements  = hence no need to pre-process existing open api spec file.
  • add any desired interface(s) to any schema without touching the original open api spec file. = hence no need to pre-process existing open api spec file.

Implementation details:

  • Adds config options xImplementsSkip (java-spring) and xKotlinImplementsSkip and xKotlinImplementsFieldsSkip (kotlin-spring) to allow specifying interfaces that should be EXCLUDED from implementation despite being requested via the vendor extensions x-implements (java-spring) and x-kotlin-implements (kotlin-spring). This should help with reuse of a spec between server/client where the interfaces are not shared among both.

  • Adds config options schemaImplements (java-spring and kotlin-spring) and schemaImplementsFields (kotlin-spring) to allow specifying interfaces that should be IMPLEMENTED in a schema (similar functionality to x-implements and x-kotlin-implements but fully decoupled from the open api spec)

  • (in kotlin-spring) Imports java.io.Serializable as fully qualified and simplifies the template logic by passing it as one of the x-kotlin-implements item.

  • (in kotlin-spring) also fixes issue [BUG][KOTLIN][SPRING] Wildcard path generates invalid code #22756 (whether it is a valid bug is a matter of opinion, but fixing it is trivial and does not hurt anything)

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • 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
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • Tagging java-spring commitee: @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08)
  • Tagging kotlin committee: @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @stefankoppier (2022/06) @e5l (2024/10)

Summary by cubic

Adds config-driven controls to replace or skip x-implements/x-kotlin-implements and adds schema-level interface mapping for Java and Kotlin Spring. This lets you add, substitute, or skip interfaces per model without editing the OpenAPI spec.

  • New Features

    • Java Spring: schemaImplements per schema and xImplementsSkip to skip interfaces; config takes precedence over x-implements.
    • Kotlin Spring: schemaImplements and schemaImplementsFields to add interfaces and define covered fields; xKotlinImplementsSkip and xKotlinImplementsFieldsSkip to skip interfaces or specific fields; config takes precedence over x-kotlin-implements.
    • Kotlin templates now add java.io.Serializable via x-kotlin-implements using its fully qualified name; samples and tests updated.
  • Bug Fixes

    • Kotlin Spring: adjusted path comments in annotations to avoid Kotlin compile issues.

Written for commit 9d6f082. Summary will update on new commits.

@Picazsoo Picazsoo changed the title [JAVA;KOTLIN-SPRING] - add possibility to override x-implements and x-kotlin-implements via additionalProperties. [JAVA-SPRING;KOTLIN-SPRING] - add possibility to override x-implements and x-kotlin-implements via additionalProperties. Jan 29, 2026
@Picazsoo Picazsoo changed the title [JAVA-SPRING;KOTLIN-SPRING] - add possibility to override x-implements and x-kotlin-implements via additionalProperties. [JAVA-SPRING;KOTLIN-SPRING] - add possibility to override x-implements and x-kotlin-implements via config options. Jan 29, 2026
Comment on lines -22 to -41
}}{{#serializableModel}}{{! no newline
}}{{^vendorExtensions.x-kotlin-implements}}, Serializable{{/vendorExtensions.x-kotlin-implements}}{{! no newline
}}{{#vendorExtensions.x-kotlin-implements}}, Serializable, {{! no newline
}}{{#-first}} {{{.}}}{{/-first}}{{! no newline
}}{{^-first}}, {{{.}}}{{/-first}}{{! no newline
}}{{/vendorExtensions.x-kotlin-implements}}{{! no newline
}}{{/serializableModel}}{{! no newline
}}{{^serializableModel}}{{! no newline
}}{{#vendorExtensions.x-kotlin-implements}}, {{{.}}}{{/vendorExtensions.x-kotlin-implements}}{{! no newline
}}{{/serializableModel}}{{! no newline
}}{{#vendorExtensions.x-kotlin-implements}}, {{{.}}}{{/vendorExtensions.x-kotlin-implements}}{{! <- serializableModel is also handled via x-kotlin-implements
}}{{/parent}}{{! no newline
}}{{^parent}}{{! no newline
}}{{#serializableModel}}{{! no newline
}}{{^vendorExtensions.x-kotlin-implements}} : Serializable{{/vendorExtensions.x-kotlin-implements}}{{! no newline
}}{{#vendorExtensions.x-kotlin-implements}}{{! no newline
}}{{#-first}} : Serializable, {{{.}}}{{/-first}}{{! no newline
}}{{^-first}}, {{{.}}}{{/-first}}{{! no newline
}}{{/vendorExtensions.x-kotlin-implements}}{{! no newline
}}{{/serializableModel}}{{! no newline
}}{{^serializableModel}}{{! no newline
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this simplifications is pretty much worth it. I now handle adding the Serializable as one of the x-kotlin-implements items. That allows me to remove much of the mustache template complexity.

Comment on lines -6 to -8
{{#serializableModel}}
import java.io.Serializable
{{/serializableModel}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need as I now fully qualify the Serializable.

@Picazsoo Picazsoo marked this pull request as ready for review January 30, 2026 10:00
Copy link

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

Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".github/workflows/samples-jdk17.yaml">

<violation number="1" location=".github/workflows/samples-jdk17.yaml:57">
P2: New matrix sample lacks matching path filters, so changes to it won’t trigger this workflow.</violation>
</file>

<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java">

<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java:2021">
P2: Unsafe cast of x-implements to List<String> can throw ClassCastException when the vendor extension is defined as a scalar string (as seen in test resources).</violation>
</file>

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

@Picazsoo
Copy link
Contributor Author

Ok, I am pleasantly surprised by the cubic-dev-ai bot. Pretty cool stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant