fix: edge case where allOfs would receive a type
when one wasn't present
#374
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.
🧰 What's being changed?
@rafegoldberg stumbled on this in the AWS Workspaces definition while testing out readmeio/api-explorer#1179, but we have an edge case right now where if you're using
allOf
to dynamically add adescription
, and only that, to another schema, we'll addtype: string
to the description object.For example:
Reason why this ends up failing in the API Explorer is because when
@readme/oas-form
attempts to merge the schemas in theallOf
,array
andstring
collide and json-schema-merge-allof throws an error and instead of merging the schemas together@readme/oas-form
instead returns the original schemas sans theallOf
-- resulting in atype
-less schema.I continue to be eternally grateful that I took the time to rewrite
getParametersAsJsonSchema
in December because fixing this kind of thing in the old code would have been a Hot Mess.🧪 Testing
See attached unit tests, but here's the before and after of this fix in the API Explorer:
Before
After