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 1204c7e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(flatten): import the target of a $ref held by an unmapped keyword
A keyword the Swagger 2.0 model does not map - propertyNames, contains,
if/then/else, $defs - lands in spec.Schema.ExtraProps as raw JSON, and
analyzeSchema never looked there. Flatten imported the subtree holding such
a $ref and left the pointer untouched, so "#/definitions/leaf" ended up
naming a definition of the root document: nothing at all when the root had
no definition of that name, and an unrelated schema when it had one. The
second case validates, wrongly, and reports no error.
analyzeSchema now walks ExtraProps and records what it finds in
referenceAnalysis.unmappedRefs, keyed by the node holding the $ref
("#/definitions/deep/if/anyOf/0"). The index is deliberately kept out of
allRefs and schemas: AllRefs, AllReferences and AllDefinitionReferences
address schemas through the model, and a key naming a raw JSON node is of no
use to them or to what go-swagger builds on them. Their contents are
unchanged.
Flatten consults the new index where it has to: normalizeRef strips the
absolute base from those $ref too, importExternalReferences indexes them
alongside the mapped ones so the target is imported and named through
uniqifyName, importNewRef rebases them onto the document they came from, and
removeUnusedSinglePass counts them as a use - without that last one, the
definition just imported would be pruned again.
replace.UpdateRef gains two cases for raw JSON nodes. No spec-side change is
needed: jsonpointer hands back a copy of the any that holds the map, and a
copied map shares its storage, so writing to it reaches the document.
A document where a mapped $ref happens to pull the same target in was
already flattened correctly, by coincidence. Its output is unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
0 commit comments