[JAVA-SPRING;KOTLIN-SPRING] - add possibility to override x-implements and x-kotlin-implements via config options.#22839
Merged
wing328 merged 22 commits intoOpenAPITools:masterfrom Feb 4, 2026
Conversation
Picazsoo
commented
Jan 30, 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 |
Contributor
Author
There was a problem hiding this comment.
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.
Picazsoo
commented
Jan 30, 2026
Comment on lines
-6
to
-8
| {{#serializableModel}} | ||
| import java.io.Serializable | ||
| {{/serializableModel}} |
Contributor
Author
There was a problem hiding this comment.
No need as I now fully qualify the Serializable.
Contributor
There was a problem hiding this comment.
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.
.../openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java
Outdated
Show resolved
Hide resolved
Contributor
Author
|
Ok, I am pleasantly surprised by the cubic-dev-ai bot. Pretty cool stuff. |
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.
Provides a flexible mechanism to:
x-implementsorx-kotlin-implements= hence no need to pre-process existing open api spec file.Implementation details:
Adds config options
xImplementsSkip(java-spring) andxKotlinImplementsSkipandxKotlinImplementsFieldsSkip(kotlin-spring) to allow specifying interfaces that should be EXCLUDED from implementation despite being requested via the vendor extensionsx-implements(java-spring) andx-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) andschemaImplementsFields(kotlin-spring) to allow specifying interfaces that should be IMPLEMENTED in a schema (similar functionality tox-implementsandx-kotlin-implementsbut fully decoupled from the open api spec)(in kotlin-spring) Imports
java.io.Serializableas fully qualified and simplifies the template logic by passing it as one of thex-kotlin-implementsitem.(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
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.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)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
Bug Fixes
Written for commit 9d6f082. Summary will update on new commits.