Repository navigation
Conversation
An extended $ref is inlined merged with its siblings, so another $ref to the same target (or to a path under one of those sibling keys) can't be pointed at it. Inline those refs instead. Fixes APIDevTools#440
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #440.
Problem. In
remap(), the first$refto a target is inlined and every later$refto the same target (or to a path inside it) is pointed at that spot. When the first one is an extended$ref, it is inlined merged with its siblings, so:$refto the same target resolves to the target plus the first ref's siblings (the issue's repro:B.properties.statusgetsdescription: "A status"fromA);$refto a sub-path under one of those sibling keys (e.g.person.json#/properties/namewhen the first ref has its ownproperties.name) resolves to the merged value, not the target's.The sort already puts plain refs before extended ones, so this only happens when every ref to that target is extended (or the sub-path one is the only other).
Change.
remap()now keeps the sibling keys of the inlined$ref. If it has any:$refwith the same target is inlined too (it becomes the next head);$refwhose first token is one of those keys is inlined too.Sub-paths under keys the extended ref doesn't touch are still remapped as before, so bundles don't grow in the normal case.
Tests. New
test/specs/bundle-regressions/extended-ref-siblings.spec.ts(in-memory resolver):status.json$refbeneath a key the extended$refoverrides$refbeneath an untouched key is still remapped to#/$defs/A/properties/nameEach checks that
dereference(bundle)equalsdereference(files). The first two fail onmainand pass now. Fullvitest run(91 files, 746 passed),pnpm lint,pnpm typecheckandoxfmt --checkpass.