-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Local references don't work correctly #415
Comments
Is the issue that promped creating #414 |
The issue is that the schema needs to be initialized. This copies the base URI to all of the subschemas that don't define their own base URI (via Instead of schema.BaseUri = new Uri(file);
SchemaRegistry.Global.Register(schema); use SchemaRegistry.Global.Register(new Uri(file), schema); This is what I do in the test suite to load files. json-everything/JsonSchema.Tests/Suite/Validation.cs Lines 107 to 112 in 44d5fe8
This will properly initialize the schema which sets the base URI throughout the schema components. Not sure why what you're doing isn't working. I can look into that. The other thing you can do (which might actually be preferred) is to add |
Another thing to consider is that when you're using |
Okay thankyou. I tried what you suggested and it did indeed fix it so long as no schema with a $id references one without. If that happens the reference cannot be followed because the basePath is that of the $id not of the actual filepath. Would it be worth checking for refs with the id and then if it's not found falling back to checking with the filepath as the basepath? |
The file path is already set as the base URI when you load it from the file. If it has an |
I understand that there isn't one now but it might be nice to have an option to enable that in case your schema references a schema with a local path that either doesn't have a $id or has a different prefix in its $id |
Overriding |
Environment
Describe the bug
When referencing schemas locally from inside a AllOf /OneOf/AnyOf block the reference isn't resolved against the baseUri of that schema
To Reproduce
Load all the json schema with their full path:
then evaluate a file with a local reference eg:
The ref attempts to resolve ""https://json-everything.net/y984i8rniyfr/b.json". This is because because the scope was changed to a randomly generated one when entering het AllOf block "
Expected behavior
The ref should resolve and evaluate correctly based on the baseUrl
Additional context
I'm not entirely sure if this is actually within spec for jsonschema, but it certainly seems to be how all the other validators I've used work
The text was updated successfully, but these errors were encountered: