Open NfNitLoop opened 4 months ago
--force
isn't expected to resolve this issue as there is no invalid reference that can be ignored, just an unexpected error. I'll take a peek.
Alright, I've figured it out. https://vega.github.io/schema/vega-lite/v5.json is a JSON Schema file and its $ref
plays by different rules than JSON References. So the many cases where $ref
is adjacent to other properties, these are not valid in JSON References but are for JSON Schema. But the problematic one is the $ref
on line 2 of v5.json
because it tells json-refs
to replace the entire content of the document with the resolved value it points to. At that point, json-refs
will then continue to attempt to resolve the other references it found which now no longer point to valid places in the resolved document and therein lies the rub. Typically json-refs
handles this is by using a graph of dependencies to know the order in which to resolve references. But I'm guessing this logic doesn't work with documents having a JSON Reference at the root of the document and elsewhere, as that's invalid. So I now need to figure out if I want to update json-refs
to work in cases where it's working with invalid JSON References.
Just to be sure, if you remove the $ref
at the root of the document, json-refs resolve
works just fine but it fails later on when trying to JSON.stringify
a document that is so large.
Thanks for looking into it!
I ran into this because I was going to try to generate a Zod schema validator (and type definitions) from the schema, and https://github.com/StefanTerdell/json-schema-to-zod requires that I resolve refs first (and recommends json-refs
).
I'm going to open an issue over there just to let them know that json-refs has this known issue with JSON Schemas.
FWIW, I've moved on from the issue and decided not to pursue it further so it's not necessarily a pressing issue for me at the moment. Thanks for this library!
Adding
--force
doesn't solve the issue and continues to return the same error.