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

JSON references to files relative to schema #180

Open
roddypratt opened this issue Jul 12, 2023 · 1 comment
Open

JSON references to files relative to schema #180

roddypratt opened this issue Jul 12, 2023 · 1 comment

Comments

@roddypratt
Copy link

I'm trying to use the fetchDocument/freeDocument callbacks to load $ref schemas.

My understanding is that if file c:/my/schemas/test.json contains something like this:

                "foo": {
                    "description": "hello",
                    "$ref": "commonschema.json#/$defs/foo"
                },

.. that the validator should look for a file c:/my/schemas/commonschema.json?

The fetchDocument callback is passed commonschema.json, but how do I know the directory containing the parent schema?

I'm probably missing something obvious here....

@roddypratt
Copy link
Author

I'm probably missing something obvious here....

... which is that you can use std::bind() to pass the original schema path to the callback. However, I'm not sure that's going to do the right thing with deeply nested refs. If a refs b which refs c, then AIUI c should be relative to b rather than a?

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

1 participant