-
-
Notifications
You must be signed in to change notification settings - Fork 886
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
$id
doesn't alter resolution scope for { "$ref": "#" }
#815
Comments
Thank you, I think I know why it is the case. Workaround is indeed easy but it should work. |
@epoberezkin Heads up, looks like this is still an issue in the latest ajv (v6.9.2). The mentioned workaround no longer seems to work either. |
@epoberezkin Heads up, I wrote a spec to reproduce the issue. I took a crack at solving it, but was having issues wrapping my head around how |
It’s indeed an existing limitation. |
Resolve.js is indeed a bit of a puzzle, but this issue is in ref.jst. |
We have two circumstances where we're running into the issue:
We've also tried using named anchors ( |
…eck that anchor is present (no support yet for $id changing resolution scope, similar to #815)
…tsRefScope $id doesn't change Base URI $ref "#" (#815)
fixed in v8 |
v8 now released: https://ajv.js.org/v6-to-v8-migration.html |
…eck that anchor is present (no support yet for $id changing resolution scope, similar to ajv-validator#815)
While helping someone write a JSON Schema that involves recursion, I noticed that ajv doesn't correctly resolve
{ "$ref": "#" }
when an$id
is altering the resolution scope.What version of Ajv are you using? Does the issue happen if you use the latest version?
I was using http://jsonschemalint.com which uses ajv, but I don't know exactly what version is used. I observed the same problems with draft-04 and draft-06.
JSON Schema
Here's an example I put together to illustrate the issue.
Sample data
Validation result, data AFTER validation, error messages
It says that the
/spouse
schema and the/children
schemas require a "root" property.What results did you expect?
I expect the "root" property to only be required at the top level. The
$id
keyword should change the resolution scope of{ "$ref": "#" }
so it refers to/allOf/0
rather than the top level of the document. Using{ "$ref": "" }
instead does work as expected.Are you going to resolve the issue?
It's not likely that I will get to this any time soon. I just wanted to bring this to your attention.
The text was updated successfully, but these errors were encountered: