[Java] Fix oneOf discriminator type for inline schemas and allOf inheritance#24156
Draft
pa314159 wants to merge 3 commits into
Draft
[Java] Fix oneOf discriminator type for inline schemas and allOf inheritance#24156pa314159 wants to merge 3 commits into
pa314159 wants to merge 3 commits into
Conversation
getDiscriminatorPropertyType only followed $ref and otherwise returned String, so an inline enum or uri-format discriminator gave the interface a String getter while the concrete classes used the real type. Resolve the inline schema via fromProperty. Refs OpenAPITools#22541, OpenAPITools#18693
Cover the other generators that render the discriminator getter through an oneof_interface template (java client/resttemplate, micronaut, helidon, kotlin-spring) with the inline-enum discriminator inherited via allOf. Refs OpenAPITools#22541
Contributor
|
Hi, I can see that it seems that we have solved almost the same problem at almost the same time (I have #24158). How would we like to join our work? I believe my solution might not handle non-enums, and your PR also better tracks issues related to this (I am solving this for myself, I had totally forgot that I had been involved with these issues before). What I would really like to investigate is if your approach could be joined into |
3 tasks
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.
Fixes discriminator type resolution in two cases:
FruitTypeEnum,URI) instead of always falling back toStringRefs #22541, #18693
PR checklist
./bin/generate-samples.sh bin/configs/java*) and committed all changed files.Summary by cubic
Fixes oneOf discriminator type resolution for inline schemas and allOf inheritance so interface getter types match concrete models (e.g., enum or
URIinstead ofString). Prevents type mismatches and compile errors across Java generators when using oneOf interfaces (refs #22541, #18693).Bug Fixes
fromPropertyso the oneOf interface uses the real type (inline enum,URI) instead ofString.$ref,allOf,oneOf, andanyOfto use the correct type in the interface.java(resttemplate),spring,micronaut,helidon, andkotlin-spring; updatedoneOfDiscriminator.yaml.Dependencies
Written for commit 1a987e3. Summary will update on new commits.