-
Notifications
You must be signed in to change notification settings - Fork 527
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
Fix ref handling in CB, AnyOf & examples (fixes : #2086) #2087
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,9 +14,12 @@ | |
import io.swagger.v3.parser.util.OpenAPIDeserializer; | ||
import io.swagger.v3.parser.util.RefUtils; | ||
|
||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.stream.Stream; | ||
|
||
import static io.swagger.v3.parser.util.RefUtils.computeRefFormat; | ||
import static io.swagger.v3.parser.util.RefUtils.isAnExternalRefFormat; | ||
|
@@ -157,33 +160,21 @@ public void processComposedSchema(ComposedSchema composedSchema) { | |
} | ||
} | ||
} | ||
}if(composedSchema.getOneOf() != null){ | ||
final List<Schema> schemas = composedSchema.getOneOf(); | ||
if (schemas != null) { | ||
for (Schema schema : schemas) { | ||
if (schema.get$ref() != null) { | ||
String oldRef = schema.get$ref(); | ||
processReferenceSchema(schema); | ||
String newRef = schema.get$ref(); | ||
changeDiscriminatorMapping(composedSchema, oldRef, newRef); | ||
} else { | ||
processSchemaType(schema); | ||
} | ||
} | ||
} | ||
}if(composedSchema.getAnyOf() != null){ | ||
final List<Schema> schemas = composedSchema.getAnyOf(); | ||
if (schemas != null) { | ||
for (Schema schema : schemas) { | ||
if (schema.get$ref() != null) { | ||
processReferenceSchema(schema); | ||
} else { | ||
processSchemaType(schema); | ||
} | ||
} | ||
} | ||
} | ||
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. AS mentioned above: IIANM the changes here consider 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. Updated as suggested. |
||
|
||
if(composedSchema.getOneOf() != null || composedSchema.getAnyOf() != null) { | ||
Stream.of(composedSchema.getOneOf(), composedSchema.getAnyOf()) | ||
.filter(Objects::nonNull).filter(l -> !l.isEmpty()).flatMap(Collection::stream) | ||
.forEach(schema -> { | ||
if (schema.get$ref() != null) { | ||
String oldRef = schema.get$ref(); | ||
processReferenceSchema(schema); | ||
String newRef = schema.get$ref(); | ||
changeDiscriminatorMapping(composedSchema, oldRef, newRef); | ||
} else { | ||
processSchemaType(schema); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private void changeDiscriminatorMapping(ComposedSchema composedSchema, String oldRef, String newRef) { | ||
|
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.
AS mentioned above:
IIANM the changes here consider
oneOf
andanyOf
as mutually exclusive, while they can coexist even if not so common. I would suggest to consider them both in the processingThere 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.
Made the processing to be mutually inclusive.
Intuitively though, the definitions feel that they are mutually exclusive.