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
953 stars 227 forks source link

Impossible to bundle a circular schema after dereferencing it #219

Closed paztis closed 3 years ago

paztis commented 3 years ago

If a schema has circular ancestor, it is possible to dereference it but if we want to re-reference it (for stringification for example), it is impossible to bundle it.

Tested in the unit tests with specs/circular/circular-indirect-ancestor.yaml

let parser = new $RefParser();
const schemaDeref = await parser.dereference(path.rel("specs/circular/circular-indirect-ancestor.yaml"));

const schema = await parser.bundle(schemaDeref);

This crashed with Maximum call stack in 2 places:

paztis commented 3 years ago

I've create a PR with a new method rereference that exactly do this job in sync: #221

Cab you look at it ?

paztis commented 3 years ago

Hello

Any new about it ? Have you found any time to look at the PR ?

philsturgeon commented 3 years ago

Why would you dereference AND bundle? I don't understand the use case so its hard to imagine a solution.

paztis commented 3 years ago

My ui is based over schemas. I need to use schemas everywhere, and don't want to support reference in tons of places.

But my ui need also to save in session storage the schemas. And I cannot serialize the without re-referencing them

Le jeu. 6 mai 2021 à 13:52, Phil Sturgeon @.***> a écrit :

Why would you dereference AND bundle? I don't understand the use case so its hard to imagine a solution.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/APIDevTools/json-schema-ref-parser/issues/219#issuecomment-833462253, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIKMMLCZK3WGMIQMKANKDTTMJ7JPANCNFSM4Y65A47A .

philsturgeon commented 3 years ago

@paztis can you see if this works in 9.0.9? We've done a lot of work on making various circular scenarios work better.