-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Correct allOf with only one child schema (no discriminator) #6901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
99b8533
fix single allof resulting in inheritance
wing328 1bf3e7d
clear cache
wing328 2576ef1
Revert "fix single allof resulting in inheritance"
wing328 920ae0c
revise message
wing328 1baf2b5
Merge remote-tracking branch 'origin/master' into fix-allof-single
wing328 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1222,8 +1222,6 @@ public static List<Schema> getInterfaces(ComposedSchema composed) { | |
| public static String getParentName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) { | ||
| List<Schema> interfaces = getInterfaces(composedSchema); | ||
| int nullSchemaChildrenCount = 0; | ||
| boolean hasAmbiguousParents = false; | ||
| List<String> refedWithoutDiscriminator = new ArrayList<>(); | ||
|
|
||
| if (interfaces != null && !interfaces.isEmpty()) { | ||
| for (Schema schema : interfaces) { | ||
|
|
@@ -1239,8 +1237,10 @@ public static String getParentName(ComposedSchema composedSchema, Map<String, Sc | |
| return parentName; | ||
| } else { | ||
| // not a parent since discriminator.propertyName is not set | ||
| hasAmbiguousParents = true; | ||
| refedWithoutDiscriminator.add(parentName); | ||
| // TOOD to be removed in 6.x release | ||
| LOGGER.warn("[deprecated] inheritance without use of 'discriminator.propertyName' has been deprecated" + | ||
| " in the 5.x release. Composed schema name: {}. Title: {}", | ||
| composedSchema.getName(), composedSchema.getTitle()); | ||
| } | ||
| } else { | ||
| // not a ref, doing nothing, except counting the number of times the 'null' type | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block is no longer needed at all right? It only increments an unused variable |
||
|
|
@@ -1253,21 +1253,6 @@ public static String getParentName(ComposedSchema composedSchema, Map<String, Sc | |
| } | ||
| } | ||
| } | ||
| if (refedWithoutDiscriminator.size() == 1 && nullSchemaChildrenCount == 1) { | ||
| // One schema is a $ref and the other is the 'null' type, so the parent is obvious. | ||
| // In this particular case there is no need to specify a discriminator. | ||
| hasAmbiguousParents = false; | ||
| } | ||
| } | ||
|
|
||
| // parent name only makes sense when there is a single obvious parent | ||
| if (refedWithoutDiscriminator.size() == 1) { | ||
| if (hasAmbiguousParents) { | ||
| LOGGER.warn("[deprecated] inheritance without use of 'discriminator.propertyName' is deprecated " + | ||
| "and will be removed in a future release. Generating model for composed schema name: {}. Title: {}", | ||
| composedSchema.getName(), composedSchema.getTitle()); | ||
| } | ||
| return refedWithoutDiscriminator.get(0); | ||
| } | ||
|
|
||
| return null; | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-) Misspelling:
TOOD-->TODOThis case indicates composition, not inheritance right? Especially in the edge case of an
allOfreference to a model with nopropertiesnoradditionalPropertiesSo why is it being deprecated? This seems like a valid use case for composition.The log warning message seems to indicate that I will not be able to do composition in this way. Is that what is intended?