| 1 |
[ |
| 2 |
{ |
| 3 |
"description": "order of evaluation: $id and $ref", |
| 4 |
"schema": { |
| 5 |
"$comment": "$id must be evaluated before $ref to get the proper $ref destination", |
| 6 |
"$id": "/ref1/base.json", |
| 7 |
"allOf": [ { "$ref": "int.json" } ], |
| 8 |
"definitions": { |
| 9 |
"bigint": { |
| 10 |
"$comment": "canonical uri: /ref1/int.json", |
| 11 |
"$id": "int.json", |
| 12 |
"maximum": 10 |
| 13 |
}, |
| 14 |
"smallint": { |
| 15 |
"$comment": "canonical uri: /int.json", |
| 16 |
"$id": "/int.json", |
| 17 |
"maximum": 2 |
| 18 |
} |
| 19 |
} |
| 20 |
}, |
| 21 |
"tests": [ |
| 22 |
{ |
| 23 |
"description": "data is valid against first definition", |
| 24 |
"data": 5, |
| 25 |
"valid": true |
| 26 |
}, |
| 27 |
{ |
| 28 |
"description": "data is invalid against first definition", |
| 29 |
"data": 50, |
| 30 |
"valid": false |
| 31 |
} |
| 32 |
] |
| 33 |
}, |
| 34 |
{ |
| 35 |
"description": "order of evaluation: $id and $anchor and $ref", |
| 36 |
"schema": { |
| 37 |
"$comment": "$id must be evaluated before $ref to get the proper $ref destination", |
| 38 |
"$id": "/ref2/base.json", |
| 39 |
"allOf": [ { "$ref": "#bigint" } ], |
| 40 |
"definitions": { |
| 41 |
"bigint": { |
| 42 |
"$comment": "canonical uri: /ref2/base.json#/definitions/bigint; another valid uri for this location: /ref2/base.json#bigint", |
| 43 |
"$id": "#bigint", |
| 44 |
"maximum": 10 |
| 45 |
}, |
| 46 |
"smallint": { |
| 47 |
"$id": "/ref2/", |
| 48 |
"definitions": { |
| 49 |
"bigint": { |
| 50 |
"$comment": "canonical uri: /ref2/#/definitions/smallint; another valid uri for this location: /ref2/#bigint, /ref2/base.json#/definitions/smallint/definitions/bigint", |
| 51 |
"$id": "#bigint", |
| 52 |
"maximum": 2 |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
}, |
| 58 |
"tests": [ |
| 59 |
{ |
| 60 |
"description": "data is valid against first definition", |
| 61 |
"data": 5, |
| 62 |
"valid": true |
| 63 |
}, |
| 64 |
{ |
| 65 |
"description": "data is invalid against first definition", |
| 66 |
"data": 50, |
| 67 |
"valid": false |
| 68 |
} |
| 69 |
] |
| 70 |
}, |
| 71 |
{ |
| 72 |
"description": "naive replacement of $ref with its destination is not correct", |
| 73 |
"schema": { |
| 74 |
"definitions": { |
| 75 |
"a_string": { "type": "string" } |
| 76 |
}, |
| 77 |
"enum": [ |
| 78 |
{ "$ref": "#/definitions/a_string" } |
| 79 |
] |
| 80 |
}, |
| 81 |
"tests": [ |
| 82 |
{ |
| 83 |
"description": "do not evaluate the $ref inside the enum", |
| 84 |
"data": "this is a string", |
| 85 |
"valid": false |
| 86 |
}, |
| 87 |
{ |
| 88 |
"description": "match the enum exactly", |
| 89 |
"data": { "$ref": "#/definitions/a_string" }, |
| 90 |
"valid": true |
| 91 |
} |
| 92 |
] |
| 93 |
}, |
| 94 |
{ |
| 95 |
"description": "invalid $ref: invalid anchor fragment", |
| 96 |
"schema": { |
| 97 |
"definitions": { |
| 98 |
"foo": { |
| 99 |
"$ref": "https://foo.com/bar.json#-not-an-anchor" |
| 100 |
} |
| 101 |
} |
| 102 |
}, |
| 103 |
"tests": [ |
| 104 |
{ |
| 105 |
"description": "an invalid anchor fragment", |
| 106 |
"data": 1, |
| 107 |
"valid": false |
| 108 |
} |
| 109 |
] |
| 110 |
}, |
| 111 |
{ |
| 112 |
"description": "invalid $ref: invalid json-pointer fragment", |
| 113 |
"schema": { |
| 114 |
"definitions": { |
| 115 |
"foo": { |
| 116 |
"$ref": "https://foo.com/bar.json#/~2/not/json/pointer" |
| 117 |
} |
| 118 |
} |
| 119 |
}, |
| 120 |
"tests": [ |
| 121 |
{ |
| 122 |
"description": "an invalid json-pointer fragment", |
| 123 |
"data": 1, |
| 124 |
"valid": false |
| 125 |
} |
| 126 |
] |
| 127 |
}, |
| 128 |
{ |
| 129 |
"description": "base URI change - change folder in subschema with path from root", |
| 130 |
"comment": "based on test suite draft7/refRemote.json 'base URI change - change folder in subschema'", |
| 131 |
"schema": { |
| 132 |
"$id": "http://localhost:1234/scope_change_defs.json", |
| 133 |
"type" : "object", |
| 134 |
"properties": { |
| 135 |
"list": { "$ref": "#/definitions/baz/definitions/bar" } |
| 136 |
}, |
| 137 |
"definitions": { |
| 138 |
"folderInteger": { |
| 139 |
"$id": "baseUriChangeFolderInSubschema/folderInteger.json", |
| 140 |
"type": "integer" |
| 141 |
}, |
| 142 |
"baz": { |
| 143 |
"$id": "baseUriChangeFolderInSubschema/", |
| 144 |
"definitions": { |
| 145 |
"bar": { |
| 146 |
"type": "array", |
| 147 |
"items": { "$ref": "folderInteger.json" } |
| 148 |
} |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
}, |
| 153 |
"tests": [ |
| 154 |
{ |
| 155 |
"description": "number is valid", |
| 156 |
"data": {"list": [1]}, |
| 157 |
"valid": true |
| 158 |
}, |
| 159 |
{ |
| 160 |
"description": "string is invalid", |
| 161 |
"data": {"list": ["a"]}, |
| 162 |
"valid": false |
| 163 |
} |
| 164 |
] |
| 165 |
} |
| 166 |
] |