Allow ComposedSchemas to replace non-composed so we can respect polymorphic links discovered in later methods #1620
+210
−2
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.
Paths are inspected in reverse alphabetical order, with the first schema generated any inserted into components taking precedence.
Therefore if you have paths e.g.
We'll generate Dog first by inspecting zzzGetDog, which isn't composed because we are returning Dog directly.
We then generate Pet and subtypes when we find the other method. At this point we should replace the existing Dog component with the new composed one, as we're now aware that we care about the polymorphism, but the existing code skips the existing key for Dog, meaning the spec incorrectly presents Dog as unrelated to Pet.
Meanwhile, as Pet and Cat were not previously generated, Cat is correctly emitted as a subtype of Pet with an allOf Pet reference.
As far as I can tell, this issue hasn't cropped up before in examples or existing tests because the path naming has always been such that Pet generated first by conincidence, which meant a ComposedSchema for Dog would already be present in the components.