-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
tests for $ref using base URI learned from $id #403
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$id": "http://localhost:1234/subSchemas-ids.json", | ||
"allOf": [ | ||
{"$ref": "#/$defs/referencing"} | ||
], | ||
"$defs": { | ||
"referencing": { | ||
"$id": "referencing.json", | ||
"allOf": [ | ||
{"$ref": "#/$defs/referenced"} | ||
], | ||
"$defs": { | ||
"referenced": { | ||
"enum": ["should-be-valid"] | ||
} | ||
} | ||
}, | ||
"referenced": { | ||
"enum": ["should-NOT-be-valid"] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1012,5 +1012,49 @@ | |
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "$ref uses base URI learned from $id", | ||
"schema": { | ||
"allOf": [ | ||
{"$ref": "#/$defs/referencing"} | ||
], | ||
"$defs": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (It's weird that the sanity check for unknown keywords doesn't flag this, as that's the point of it, but I don't have time to look into why right this second.) |
||
"referencing": { | ||
"$id": "/referencing.json", | ||
"$comment": "The $id here changes the base URI that $ref's value is resolved against", | ||
"allOf": [ | ||
{"$ref": "#/$defs/referenced"} | ||
], | ||
"$defs": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
"referenced": { | ||
"$comment": "This schema IS being referenced", | ||
"enum": ["should-be-valid"] | ||
} | ||
} | ||
}, | ||
"referenced": { | ||
"$comment": "This schema is NOT being referenced", | ||
"enum": ["should-NOT-be-valid"] | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "the correct schema is referenced", | ||
"data": "should-be-valid", | ||
"valid": true | ||
}, | ||
{ | ||
"description": "the incorrect schema is not referenced", | ||
"data": "should-NOT-be-valid", | ||
"valid": false | ||
}, | ||
{ | ||
"description": "sanity check that other invalid values aren't accepted either", | ||
"data": "bogus", | ||
"valid": false | ||
} | ||
] | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$defs
is only a 2019-09 and later keyword. For draft 7, you'll need a copy of this file that usesdefinitions
.