Conversation
2b5d0bb to
ed8b59a
Compare
|
Hey @Tony133, could you take a look at this fix for sibling keywords not applying once a schema resolves a $ref? It's been open a month with no feedback. |
Tony133
left a comment
There was a problem hiding this comment.
Thanks, and sorry for the delay. The fix looks correct.
Two small changes before merging, see inline comments.
|
CI is red |
|
CI failed on the 100% coverage gate, not on a failing test. The catch in |
|
Sorry, this needs a rebase now. |
3952e0f to
27cbcc6
Compare
|
Rebased. |
Problem
A property that both references another schema and adds its own keywords loses those keywords.
resolveRefswaps the whole location for the reference target, so anything sitting next to$refis gone before any code is generated:valueis enforced because it comes fromFoo,extrais not, so incomplete data serializes as if it were valid.Fix
A
$refthat carries siblings now gets the resolved target and those siblings merged throughmergeLocations, the same pathallOfalready takes. Everything else keeps the direct dereference it always had:title,description,$comment,examples,deprecated,readOnly,writeOnly) are skipped, so annotated refs still share one serializertypethe target contradicts) the merge is dropped and the plain target is used, which is what happens todayMerged refs are cached by content rather than by object identity, since a merge clones its input and a recursive
$refwould otherwise be merged again on every level.Test
Two cases in
test/ref.test.js, internal and external$refwith a siblingrequired: the sibling constraint is enforced and the target's ownrequiredstill is. Both fail on the current main.Fixes #866