APIDevTools / json-schema-ref-parser

Parse, Resolve, and Dereference JSON Schema $ref pointers in Node and browsers
https://apitools.dev/json-schema-ref-parser
MIT License
942 stars 226 forks source link

Remap incorrectly using escaped paths #333

Closed mzbik closed 6 months ago

mzbik commented 6 months ago

json-schema-ref-parser/lib/bundle.js in routine remap will take external file $ref's and remap them to self-relative $refs. At the time this is done, the paths in the parsed api file have been escaped ('/' -> '~1'), so you end up with a reference that looks like:

$ref: #/paths/~1foo~1bar/content-type...

This will break anyone (such as ajv) who will parse this on '/' boundaries and use it to walk the json file to find the actual referent.

The problem may be located in crawl() which calls Pointer.join to form full paths and also escape the embedded '/'

mzbik commented 6 months ago

Completely bad triage. Ignore. Sorry