-
-
Notifications
You must be signed in to change notification settings - Fork 218
Additional $ref tests for draft-04/06 #160
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 all commits
a884acc
0178c74
3186761
cbe0e5b
44f6447
671bad6
25836f7
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,11 @@ | ||
{ | ||
"definitions": { | ||
"orNull": { | ||
"anyOf": [ | ||
{"type": "null"}, | ||
{"$ref": "#"} | ||
] | ||
} | ||
}, | ||
"type": "string" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
] | ||
}, | ||
{ | ||
"description": "change resolution scope", | ||
"description": "base URI change", | ||
"schema": { | ||
"id": "http://localhost:1234/", | ||
"items": { | ||
|
@@ -60,15 +60,112 @@ | |
}, | ||
"tests": [ | ||
{ | ||
"description": "changed scope ref valid", | ||
"description": "base URI change ref valid", | ||
"data": [[1]], | ||
"valid": true | ||
}, | ||
{ | ||
"description": "changed scope ref invalid", | ||
"description": "base URI change ref invalid", | ||
"data": [["a"]], | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "base URI change - change folder", | ||
"schema": { | ||
"id": "http://localhost:1234/scope_change_defs1.json", | ||
"type" : "object", | ||
"properties": { | ||
"list": {"$ref": "#/definitions/baz"} | ||
}, | ||
"definitions": { | ||
"baz": { | ||
"id": "folder/", | ||
"type": "array", | ||
"items": {"$ref": "folderInteger.json"} | ||
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. Where is folderInteger.json? Maybe I just don't understand this schema or the use of id, I don't know =/ 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. @Relequestual there is a convention already used in other tests to assume that schemas at 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. |
||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "number is valid", | ||
"data": {"list": [1]}, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "string is invalid", | ||
"data": {"list": ["a"]}, | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "base URI change - change folder in subschema", | ||
"schema": { | ||
"id": "http://localhost:1234/scope_change_defs2.json", | ||
"type" : "object", | ||
"properties": { | ||
"list": {"$ref": "#/definitions/baz/definitions/bar"} | ||
}, | ||
"definitions": { | ||
"baz": { | ||
"id": "folder/", | ||
"definitions": { | ||
"bar": { | ||
"type": "array", | ||
"items": {"$ref": "folderInteger.json"} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "number is valid", | ||
"data": {"list": [1]}, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "string is invalid", | ||
"data": {"list": ["a"]}, | ||
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "root ref in remote ref", | ||
"schema": { | ||
"id": "http://localhost:1234/object", | ||
"type": "object", | ||
"properties": { | ||
"name": {"$ref": "name.json#/definitions/orNull"} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "string is valid", | ||
"data": { | ||
"name": "foo" | ||
}, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "null is valid", | ||
"data": { | ||
"name": null | ||
}, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "object is invalid", | ||
"data": { | ||
"name": { | ||
"name": null | ||
} | ||
}, | ||
"valid": false | ||
} | ||
] | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,5 +240,93 @@ | |
"valid": false | ||
} | ||
] | ||
}, | ||
{ | ||
"description": "Recursive references between schemas", | ||
"schema": { | ||
"$id": "http://localhost:1234/tree", | ||
"description": "tree of nodes", | ||
"type": "object", | ||
"properties": { | ||
"meta": {"type": "string"}, | ||
"nodes": { | ||
"type": "array", | ||
"items": {"$ref": "node"} | ||
} | ||
}, | ||
"required": ["meta", "nodes"], | ||
"definitions": { | ||
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 don't see definitions used in this schema. 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. @Relequestual it's the same test as above, just in draft6 folder - please see the comment above |
||
"node": { | ||
"$id": "http://localhost:1234/node", | ||
"description": "node", | ||
"type": "object", | ||
"properties": { | ||
"value": {"type": "number"}, | ||
"subtree": {"$ref": "tree"} | ||
}, | ||
"required": ["value"] | ||
} | ||
} | ||
}, | ||
"tests": [ | ||
{ | ||
"description": "valid tree", | ||
"data": { | ||
"meta": "root", | ||
"nodes": [ | ||
{ | ||
"value": 1, | ||
"subtree": { | ||
"meta": "child", | ||
"nodes": [ | ||
{"value": 1.1}, | ||
{"value": 1.2} | ||
] | ||
} | ||
}, | ||
{ | ||
"value": 2, | ||
"subtree": { | ||
"meta": "child", | ||
"nodes": [ | ||
{"value": 2.1}, | ||
{"value": 2.2} | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"valid": true | ||
}, | ||
{ | ||
"description": "invalid tree", | ||
"data": { | ||
"meta": "root", | ||
"nodes": [ | ||
{ | ||
"value": 1, | ||
"subtree": { | ||
"meta": "child", | ||
"nodes": [ | ||
{"value": "string is invalid"}, | ||
{"value": 1.2} | ||
] | ||
} | ||
}, | ||
{ | ||
"value": 2, | ||
"subtree": { | ||
"meta": "child", | ||
"nodes": [ | ||
{"value": 2.1}, | ||
{"value": 2.2} | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
"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 don't see definitions used in this schema.
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.
@Relequestual
{"$ref": "node"}
points tohttp://localhost:1234/node
which is defined in#/definitions/node
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.
How exactly does
{"$ref": "node"}
points tohttp://localhost:1234/node
? I don't follow.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.
base URI is
http://localhost:1234/tree
when you resolve relative urinode
it becomeshttp://localhost:1234/node
.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.
It's section 5.2 of RFC 3986