Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug resolving vega-lite JSON schema #207

Open
NfNitLoop opened this issue Mar 7, 2024 · 3 comments
Open

Bug resolving vega-lite JSON schema #207

NfNitLoop opened this issue Mar 7, 2024 · 3 comments

Comments

@NfNitLoop
Copy link

> json-refs resolve https://vega.github.io/schema/vega-lite/v5.json

  error: JSON Pointer points to missing location: #/definitions/PredicateComposition/anyOf

Adding --force doesn't solve the issue and continues to return the same error.

@whitlockjc
Copy link
Owner

--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.

@whitlockjc
Copy link
Owner

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.

@NfNitLoop
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants