DRAFT: [java][jaxrs-spec][quarkus] - Part 2 - useSealed interfaces#24189
Draft
Ignacio-Vidal wants to merge 2 commits into
Draft
DRAFT: [java][jaxrs-spec][quarkus] - Part 2 - useSealed interfaces#24189Ignacio-Vidal wants to merge 2 commits into
Ignacio-Vidal wants to merge 2 commits into
Conversation
The jaxrs-spec generator had no rendering for the useOneOfInterfaces feature: a oneOf schema was always emitted as a pojo, even when the feature transformed it into an interface model. This adds the missing interface template so that, with useOneOfInterfaces=true, a oneOf schema is generated as a Java interface and the concrete subtypes implement it. - model.mustache routes x-is-one-of-interface models to a new oneof_interface template; all other models still render as pojos (default behavior unchanged). - oneof_interface.mustache emits a plain interface, carrying the discriminator getter (whose type now resolves to the shared enum, e.g. PetType) plus the generated/typeInfo/deduction annotations. - Adds the oneof_interface fixture, a JavaJAXRSSpecServerCodegenTest, and a jaxrs-spec-oneof-interface sample (registered in the JAX-RS samples workflow). The feature stays opt-in; default jaxrs-spec output is unchanged.
Adds a useSealed option to the jaxrs-spec generator. When useSealed=true (on top of useOneOfInterfaces=true), the generated oneOf interface is sealed and permits its subtypes, which become final classes implementing the interface. - JavaJAXRSSpecServerCodegen: useSealed option (constant/field/CliOption/processOpts). - sealed.mustache / permits.mustache emit the sealed/permits/final modifiers, gated on useSealed; oneof_interface.mustache and pojo.mustache reference them so the modifiers appear on both the interface and the pojos. - pom.mustache bumps java.version to 17 when useSealed (sealed types need JDK 17+); the default stays 1.8. - Adds testOneOfSealedInterfaceGeneration and a jaxrs-spec-sealed sample (registered in the JDK17 samples workflow). The feature stays opt-in; default jaxrs-spec output is unchanged.
98907a7 to
05ce164
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.
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
Adds support for generating oneOf schemas as Java interfaces in
jaxrs-spec(optionally sealed), and fixes discriminator mapping so subtypes get correct@JsonTypeNameand interface getters use the enum type.New Features
useOneOfInterfaces=true: oneOf schemas render as interfaces viaoneof_interface.mustache; subtypes implement the interface and carry Jackson type info.useSealed=true(withuseOneOfInterfaces): emits sealed interfaces withpermits; subtypes becomefinaland implement the interface;pom.mustachesets Java 17 when enabled.oneof_interface.mustache,sealed.mustache,permits.mustache,additionalOneOfTypeAnnotations.mustache; workflows build new samples:jaxrs-spec-oneof-interface(JAX-RS),jaxrs-spec-sealed(JDK17).Bug Fixes
x-discriminator-valuefor subtypes is resolved from the parent or from the implemented oneOf interface, producing the correct@JsonTypeName(e.g.,CAT/DOG).PetType) instead of defaulting toString.Written for commit 05ce164. Summary will update on new commits.