[java][microprofile] Extend support for useOneOfInterfaces to the microprofile library when Jackson serialisation is enabled#24190
Open
Ignacio-Vidal wants to merge 2 commits into
Conversation
3955785 to
b87a351
Compare
Contributor
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
ac5eed3 to
6785752
Compare
Contributor
Author
|
I test these changes in a separate project: https://github.com/Ignacio-Vidal/openapi-servers/tree/main And these 2 PRs supporting oneOfInterfaces in the server and client generators are covered:
I create a branch that combined #24190 and #24174 in my local and installed into my m2 repository |
3 tasks
wing328
reviewed
Jul 8, 2026
| @@ -0,0 +1,11 @@ | |||
| generatorName: java | |||
| outputDir: samples/client/petstore/java/microprofile-oneof-interface | |||
Member
There was a problem hiding this comment.
please add the new output folder to the gihtub workflow for java client in https://github.com/OpenAPITools/openapi-generator/blob/master/.github/workflows/samples-java-client-jdk11.yaml
Route oneOf schemas to the shared oneof_interface template in the microprofile library's model.mustache, so useOneOfInterfaces=true renders a oneOf schema as a Java interface implemented by its subtypes, instead of an unrelated pojo. The microprofile library ships its own model.mustache (it overrides the base to support JSON-B and the jakarta/javax package split), which did not carry the oneOf-interface routing the base template has. Adding the routing lets the existing global oneof_interface template render the interface; children already implement it via x-implements. Scoped to serializationLibrary=jackson (the interface polymorphism annotations are Jackson-based). Adds a self-consistent oneof_interface_petstore.yaml fixture, a JavaClientCodegenTest case, and a microprofile-oneof-interface sample.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34582dd to
ab33a9c
Compare
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.
[java][microprofile] Support
useOneOfInterfacesThe java client generator already supports oneOfInterface templating and it's currently used by the
Springlibrary variants. This PR extends this to theMicroprofilelibrary whenJacksonis selected for serialisation.It renders a
oneOfschema as a Java interface (implemented by its subtypes) for themicroprofilelibrary, instead of an unrelated pojo.The
microprofilelibrary ships its ownmodel.mustacheand supportsserializationLibrary=jacksonandserialisationLibrary=jsonB. This PR guarantees support Jackson and JsonB will be verified in a follow up PR.Add support for OneOfInterfaces to avoid having circular dependencies because the child schemas components extend a parent class that also has oneOf and mapping pointing to the children. Example:
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.
Summary by cubic
Extends
useOneOfInterfacesto the Java MicroProfile client whenserializationLibrary=jackson, renderingoneOfschemas as interfaces implemented by subtypes. Adds a MicroProfile sample and CI coverage.model.mustacheto the sharedoneof_interfacetemplate viavendorExtensions.x-is-one-of-interfacewhenuseOneOfInterfaces=trueandserializationLibrary=jackson; fall back topojootherwise.modules/openapi-generator/src/test/resources/3_0/java/oneof_interface_petstore.yaml), generator config (bin/configs/java-microprofile-oneof-interface.yaml, MicroProfile Rest Client3.0), aJavaClientCodegenTest, and a sample atsamples/client/petstore/java/microprofile-oneof-interface.oneOfcontainer is an interface, children implement it, the discriminator getter returns the enum type, and interfaces are non-sealed by default.useSealedOneOfInterfacesis not enabled;jsonbis not supported yet.Written for commit ab33a9c. Summary will update on new commits.