fix: issue where response schemas in the original spec may get overridden #634
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.
🧰 Changes
This resolves a data corruption bug I discovered in https://github.com/readmeio/api where if you compile the JSON Schema for an operation response with
getResponseAsJsonSchema
, and somewhere within that response is anexample
property, we'd update the original API definition object that was supplied toOas
with theexamples
syntax thatgetResponseAsJsonSchema
reshapesexample
to -- rendering the original API definition in a non-spec validating state.🧬 QA & Testing
I added a test that runs
getResponseAsJsonSchema
against a response in our own spec and then queries the original spec inside the originalOas
instance to ensure that the schema property whereexample
was present is only set toexamples
in the generated JSON Schema.:upsidedown-cowboy-quadboy: