-
-
Notifications
You must be signed in to change notification settings - Fork 220
Add tests for location-independent identifiers #225
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
Changes from 1 commit
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 |
---|---|---|
|
@@ -296,5 +296,110 @@ | |
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Location-independent identifier", | ||
"schema": { | ||
"$ref": "#foo", | ||
"definitions": { | ||
"A": { | ||
"id": "#foo", | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Canonical location-independent identifier", | ||
"schema": { | ||
"$ref": "http://localhost:1234/bar#foo", | ||
"definitions": { | ||
"A": { | ||
"id": "http://localhost:1234/bar#foo", | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Location-independent identifier with base URI change in subschema", | ||
"schema": { | ||
"id": "http://localhost:1234/root", | ||
"$ref": "http://localhost:1234/nested.json#foo", | ||
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. Does having |
||
"definitions": { | ||
"A": { | ||
"id": "nested.json", | ||
"definitions": { | ||
"B": { | ||
"id": "#foo", | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Location-independent identifiers should take precedent over regular fragments", | ||
"schema": { | ||
"$ref": "#foo", | ||
"definitions": { | ||
"A": { | ||
"id": "#foo", | ||
"type": "integer" | ||
} | ||
}, | ||
"foo": { | ||
"type": "string" | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,5 +328,110 @@ | |
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Location-independent identifier", | ||
"schema": { | ||
"$ref": "#foo", | ||
"definitions": { | ||
"A": { | ||
"$id": "#foo", | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Canonical location-independent identifier", | ||
"schema": { | ||
"$ref": "http://localhost:1234/bar#foo", | ||
"definitions": { | ||
"A": { | ||
"$id": "http://localhost:1234/bar#foo", | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Location-independent identifier with base URI change in subschema", | ||
"schema": { | ||
"$id": "http://localhost:1234/root", | ||
"$ref": "http://localhost:1234/nested.json#foo", | ||
"definitions": { | ||
"A": { | ||
"$id": "nested.json", | ||
"definitions": { | ||
"B": { | ||
"$id": "#foo", | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Location-independent identifiers should take precedent over regular fragments", | ||
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. I'm trying to figure out the failure mode of this test case. Is there reason to think that an implementation might insert a 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. At first I didn't notice the difference between JSON pointers which require a |
||
"schema": { | ||
"$ref": "#foo", | ||
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. I really want the Let's avoid gray areas except when explicitly testing around them. |
||
"definitions": { | ||
"A": { | ||
"$id": "#foo", | ||
"type": "integer" | ||
} | ||
}, | ||
"foo": { | ||
"type": "string" | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"data": 1, | ||
"description": "match", | ||
"valid": true | ||
}, | ||
{ | ||
"data": "a", | ||
"description": "mismatch", | ||
"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.
I'd like to avoid the word "canonical" due to its role in the confusing draft-04 canonical vs inline mess.
I'm not entirely sure it applies to this case even in draft-04 terms, but TBH none of the current spec team really know what the point of that was AFAIK.
Is the point of this test to use a URI (with scheme) rather than a URI reference? If so, that seems like the thing to note in the description.