fix(reducer): make sure $ref
s are actual pointers
#753
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
@andrew-rdme was seeing the following error when attempting to reduce a file:
which is coming from this line:
oas/src/lib/reducer.ts
Line 33 in 6162c84
This is happening because of an edge case where a spec file might have an object definition with a property called
$ref
. In other words, say the object were to look something like this:then its schema definition would look something like:
The reducer was looking blindly for
$ref
keys and assuming their values are always strings. This tweaks the logic ever-so-slightly to ensure that the value of the$ref
is indeed a string before we attempt to load its$ref
.🧬 QA & Testing
Added a fixture and a test to confirm that the fix works as expected.