DRAFT: Jaxrs-spec: Resolve @JsonTypeName with the mapping key of the discriminator in the child models when OpenAPI specification uses OneOf for polymorphism#23075
Draft
Ignacio-Vidal wants to merge 6 commits intoOpenAPITools:masterfrom
Conversation
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.
The Jaxrx-spec adds the class name to the
@JsonTypeNameannotation in child classes when the OpenAPI specification has aOneOfwith a discriminator mapping. Instead, the generator should add the mappingkeyof the discriminator.This MR updates the
POJOmustache template to inject the vendor extensionx-discriminator-valueto the@JsonTypeNameannotation when the discriminator has a mapping or defaults to the original behaviour with the class name when not available.This MR will fix #10822 and will fix #17343
Summary by cubic
Fixes wrong @JsonTypeName in the JAX-RS spec generator for oneOf + discriminator mappings. Child models now use the discriminator mapping key (e.g., CAT); parents keep their names. Fixes #17343, #10822.
Written for commit 763a354. Summary will update on new commits.