| 1 |
[ |
| 2 |
{ |
| 3 |
"description": "root pointer ref", |
| 4 |
"schema": { |
| 5 |
"properties": { |
| 6 |
"foo": {"$ref": "#"} |
| 7 |
}, |
| 8 |
"additionalProperties": false |
| 9 |
}, |
| 10 |
"tests": [ |
| 11 |
{ |
| 12 |
"description": "match", |
| 13 |
"data": {"foo": false}, |
| 14 |
"valid": true |
| 15 |
}, |
| 16 |
{ |
| 17 |
"description": "recursive match", |
| 18 |
"data": {"foo": {"foo": false}}, |
| 19 |
"valid": true |
| 20 |
}, |
| 21 |
{ |
| 22 |
"description": "mismatch", |
| 23 |
"data": {"bar": false}, |
| 24 |
"valid": false |
| 25 |
}, |
| 26 |
{ |
| 27 |
"description": "recursive mismatch", |
| 28 |
"data": {"foo": {"bar": false}}, |
| 29 |
"valid": false |
| 30 |
} |
| 31 |
] |
| 32 |
}, |
| 33 |
{ |
| 34 |
"description": "relative pointer ref to object", |
| 35 |
"schema": { |
| 36 |
"properties": { |
| 37 |
"foo": {"type": "integer"}, |
| 38 |
"bar": {"$ref": "#/properties/foo"} |
| 39 |
} |
| 40 |
}, |
| 41 |
"tests": [ |
| 42 |
{ |
| 43 |
"description": "match", |
| 44 |
"data": {"bar": 3}, |
| 45 |
"valid": true |
| 46 |
}, |
| 47 |
{ |
| 48 |
"description": "mismatch", |
| 49 |
"data": {"bar": true}, |
| 50 |
"valid": false |
| 51 |
} |
| 52 |
] |
| 53 |
}, |
| 54 |
{ |
| 55 |
"description": "relative pointer ref to array", |
| 56 |
"schema": { |
| 57 |
"items": [ |
| 58 |
{"type": "integer"}, |
| 59 |
{"$ref": "#/items/0"} |
| 60 |
] |
| 61 |
}, |
| 62 |
"tests": [ |
| 63 |
{ |
| 64 |
"description": "match array", |
| 65 |
"data": [1, 2], |
| 66 |
"valid": true |
| 67 |
}, |
| 68 |
{ |
| 69 |
"description": "mismatch array", |
| 70 |
"data": [1, "foo"], |
| 71 |
"valid": false |
| 72 |
} |
| 73 |
] |
| 74 |
}, |
| 75 |
{ |
| 76 |
"description": "escaped pointer ref", |
| 77 |
"schema": { |
| 78 |
"definitions": { |
| 79 |
"tilde~field": {"type": "integer"}, |
| 80 |
"slash/field": {"type": "integer"}, |
| 81 |
"percent%field": {"type": "integer"} |
| 82 |
}, |
| 83 |
"properties": { |
| 84 |
"tilde": {"$ref": "#/definitions/tilde~0field"}, |
| 85 |
"slash": {"$ref": "#/definitions/slash~1field"}, |
| 86 |
"percent": {"$ref": "#/definitions/percent%25field"} |
| 87 |
} |
| 88 |
}, |
| 89 |
"tests": [ |
| 90 |
{ |
| 91 |
"description": "slash invalid", |
| 92 |
"data": {"slash": "aoeu"}, |
| 93 |
"valid": false |
| 94 |
}, |
| 95 |
{ |
| 96 |
"description": "tilde invalid", |
| 97 |
"data": {"tilde": "aoeu"}, |
| 98 |
"valid": false |
| 99 |
}, |
| 100 |
{ |
| 101 |
"description": "percent invalid", |
| 102 |
"data": {"percent": "aoeu"}, |
| 103 |
"valid": false |
| 104 |
}, |
| 105 |
{ |
| 106 |
"description": "slash valid", |
| 107 |
"data": {"slash": 123}, |
| 108 |
"valid": true |
| 109 |
}, |
| 110 |
{ |
| 111 |
"description": "tilde valid", |
| 112 |
"data": {"tilde": 123}, |
| 113 |
"valid": true |
| 114 |
}, |
| 115 |
{ |
| 116 |
"description": "percent valid", |
| 117 |
"data": {"percent": 123}, |
| 118 |
"valid": true |
| 119 |
} |
| 120 |
] |
| 121 |
}, |
| 122 |
{ |
| 123 |
"description": "nested refs", |
| 124 |
"schema": { |
| 125 |
"definitions": { |
| 126 |
"a": {"type": "integer"}, |
| 127 |
"b": {"$ref": "#/definitions/a"}, |
| 128 |
"c": {"$ref": "#/definitions/b"} |
| 129 |
}, |
| 130 |
"extends": { |
| 131 |
"$ref": "#/definitions/c" |
| 132 |
} |
| 133 |
}, |
| 134 |
"tests": [ |
| 135 |
{ |
| 136 |
"description": "nested ref valid", |
| 137 |
"data": 5, |
| 138 |
"valid": true |
| 139 |
}, |
| 140 |
{ |
| 141 |
"description": "nested ref invalid", |
| 142 |
"data": "a", |
| 143 |
"valid": false |
| 144 |
} |
| 145 |
] |
| 146 |
}, |
| 147 |
{ |
| 148 |
"description": "ref overrides any sibling keywords", |
| 149 |
"schema": { |
| 150 |
"definitions": { |
| 151 |
"reffed": { |
| 152 |
"type": "array" |
| 153 |
} |
| 154 |
}, |
| 155 |
"properties": { |
| 156 |
"foo": { |
| 157 |
"$ref": "#/definitions/reffed", |
| 158 |
"maxItems": 2 |
| 159 |
} |
| 160 |
} |
| 161 |
}, |
| 162 |
"tests": [ |
| 163 |
{ |
| 164 |
"description": "remote ref valid", |
| 165 |
"data": { "foo": [] }, |
| 166 |
"valid": true |
| 167 |
}, |
| 168 |
{ |
| 169 |
"description": "remote ref valid, maxItems ignored", |
| 170 |
"data": { "foo": [ 1, 2, 3] }, |
| 171 |
"valid": true |
| 172 |
}, |
| 173 |
{ |
| 174 |
"description": "ref invalid", |
| 175 |
"data": { "foo": "string" }, |
| 176 |
"valid": false |
| 177 |
} |
| 178 |
] |
| 179 |
}, |
| 180 |
{ |
| 181 |
"description": "property named $ref, containing an actual $ref", |
| 182 |
"schema": { |
| 183 |
"properties": { |
| 184 |
"$ref": {"$ref": "#/definitions/is-string"} |
| 185 |
}, |
| 186 |
"definitions": { |
| 187 |
"is-string": { |
| 188 |
"type": "string" |
| 189 |
} |
| 190 |
} |
| 191 |
}, |
| 192 |
"tests": [ |
| 193 |
{ |
| 194 |
"description": "property named $ref valid", |
| 195 |
"data": {"$ref": "a"}, |
| 196 |
"valid": true |
| 197 |
}, |
| 198 |
{ |
| 199 |
"description": "property named $ref invalid", |
| 200 |
"data": {"$ref": 2}, |
| 201 |
"valid": false |
| 202 |
} |
| 203 |
] |
| 204 |
}, |
| 205 |
{ |
| 206 |
"description": "$ref prevents a sibling id from changing the base uri", |
| 207 |
"schema": { |
| 208 |
"id": "http://localhost:1234/sibling_id/base/", |
| 209 |
"definitions": { |
| 210 |
"foo": { |
| 211 |
"id": "http://localhost:1234/sibling_id/foo.json", |
| 212 |
"type": "string" |
| 213 |
}, |
| 214 |
"base_foo": { |
| 215 |
"$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", |
| 216 |
"id": "foo.json", |
| 217 |
"type": "number" |
| 218 |
} |
| 219 |
}, |
| 220 |
"extends": [ |
| 221 |
{ |
| 222 |
"$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", |
| 223 |
"id": "http://localhost:1234/sibling_id/", |
| 224 |
"$ref": "foo.json" |
| 225 |
} |
| 226 |
] |
| 227 |
}, |
| 228 |
"tests": [ |
| 229 |
{ |
| 230 |
"description": "$ref resolves to /definitions/base_foo, data does not validate", |
| 231 |
"data": "a", |
| 232 |
"valid": false |
| 233 |
}, |
| 234 |
{ |
| 235 |
"description": "$ref resolves to /definitions/base_foo, data validates", |
| 236 |
"data": 1, |
| 237 |
"valid": true |
| 238 |
} |
| 239 |
] |
| 240 |
}, |
| 241 |
{ |
| 242 |
"description": "remote ref, containing refs itself", |
| 243 |
"schema": {"$ref": "http://json-schema.org/draft-03/schema#"}, |
| 244 |
"tests": [ |
| 245 |
{ |
| 246 |
"description": "remote ref valid", |
| 247 |
"data": {"items": {"type": "integer"}}, |
| 248 |
"valid": true |
| 249 |
}, |
| 250 |
{ |
| 251 |
"description": "remote ref invalid", |
| 252 |
"data": {"items": {"type": 1}}, |
| 253 |
"valid": false |
| 254 |
} |
| 255 |
] |
| 256 |
}, |
| 257 |
{ |
| 258 |
"description": "naive replacement of $ref with its destination is not correct", |
| 259 |
"schema": { |
| 260 |
"definitions": { |
| 261 |
"a_string": { "type": "string" } |
| 262 |
}, |
| 263 |
"enum": [ |
| 264 |
{ "$ref": "#/definitions/a_string" } |
| 265 |
] |
| 266 |
}, |
| 267 |
"tests": [ |
| 268 |
{ |
| 269 |
"description": "do not evaluate the $ref inside the enum, matching any string", |
| 270 |
"data": "this is a string", |
| 271 |
"valid": false |
| 272 |
}, |
| 273 |
{ |
| 274 |
"description": "match the enum exactly", |
| 275 |
"data": { "$ref": "#/definitions/a_string" }, |
| 276 |
"valid": true |
| 277 |
} |
| 278 |
] |
| 279 |
} |
| 280 |
] |