You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ee01904
Browse filesBrowse the repository at this point in the historyBrowse files
fix(expander): rebase a $ref found under an unmapped keyword
expandSchema walks the fields of Schema and stops there. A keyword the
Swagger 2.0 model predates - propertyNames, contains, if/then/else, $defs -
lands in Schema.ExtraProps as raw JSON, and inlining that subtree from
another document copied its $ref into the root verbatim: "#/definitions/leaf"
then named a definition of the root document rather than the one it came
from, and resolving it raised "has no key".
rebaseExtraRefs walks the raw JSON and rewrites every string under a "$ref"
key with normalizeURI then denormalizeRef, the pair the SkipSchemas branch
already uses for a mapped $ref, so "#/definitions/leaf" becomes
"other.json#/definitions/leaf". The pointer is correct; it is not expanded,
and the output is no more self-contained than before. Empty and unparseable
strings are left alone: an unmapped keyword may hold any JSON, and a string
under a "$ref" key is not necessarily a reference.
Two alternatives were rejected: refusing to expand a $ref whose target the
model cannot represent breaks documents that work today, and expanding the
ExtraProps subtree properly needs a raw-JSON walker with its own cycle
detection over untyped values.
FuzzExpandSpec gains the property that found this - every local $ref
surviving expansion must still name something - guarded by the same check on
the input, so a document that already dangles proves nothing. Its stub loader
used to answer every path, including the root document's own URL, so a $ref
spelled "." inlined a foreign document; it now returns the document's own
bytes for that path.
No cycle is involved: the cut point of shared-node-cycles.json is unchanged
over 40 expansions, with the same three outcomes as before.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
0 commit comments