|
207 | 207 | "schema": {
|
208 | 208 | "$schema": "https://json-schema.org/draft/next/schema",
|
209 | 209 | "$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main",
|
210 |
| - "$defs": { |
211 |
| - "inner": { |
212 |
| - "$id": "inner", |
213 |
| - "$dynamicAnchor": "foo", |
214 |
| - "title": "inner", |
215 |
| - "additionalProperties": { |
216 |
| - "$dynamicRef": "#foo" |
217 |
| - } |
| 210 | + "propertyDependencies": { |
| 211 | + "kindOfList": { |
| 212 | + "numbers": { "$ref": "numberList" }, |
| 213 | + "strings": { "$ref": "stringList" } |
218 | 214 | }
|
219 | 215 | },
|
220 |
| - "if": { |
221 |
| - "propertyNames": { |
222 |
| - "pattern": "^[a-m]" |
| 216 | + "$defs": { |
| 217 | + "genericList": { |
| 218 | + "$id": "genericList", |
| 219 | + "properties": { |
| 220 | + "list": { |
| 221 | + "items": { "$dynamicRef": "#itemType" } |
| 222 | + } |
| 223 | + } |
| 224 | + }, |
| 225 | + "numberList": { |
| 226 | + "$id": "numberList", |
| 227 | + "$defs": { |
| 228 | + "itemType": { |
| 229 | + "$dynamicAnchor": "itemType", |
| 230 | + "type": "number" |
| 231 | + } |
| 232 | + }, |
| 233 | + "$ref": "genericList" |
| 234 | + }, |
| 235 | + "stringList": { |
| 236 | + "$id": "stringList", |
| 237 | + "$defs": { |
| 238 | + "itemType": { |
| 239 | + "$dynamicAnchor": "itemType", |
| 240 | + "type": "string" |
| 241 | + } |
| 242 | + }, |
| 243 | + "$ref": "genericList" |
223 | 244 | }
|
224 |
| - }, |
225 |
| - "then": { |
226 |
| - "title": "any type of node", |
227 |
| - "$id": "anyLeafNode", |
228 |
| - "$dynamicAnchor": "foo", |
229 |
| - "$ref": "inner" |
230 |
| - }, |
231 |
| - "else": { |
232 |
| - "title": "integer node", |
233 |
| - "$id": "integerNode", |
234 |
| - "$dynamicAnchor": "foo", |
235 |
| - "type": [ "object", "integer" ], |
236 |
| - "$ref": "inner" |
237 | 245 | }
|
238 | 246 | },
|
239 | 247 | "tests": [
|
240 | 248 | {
|
241 |
| - "description": "recurse to anyLeafNode - floats are allowed", |
242 |
| - "data": { "alpha": 1.1 }, |
| 249 | + "description": "number list with number values", |
| 250 | + "data": { |
| 251 | + "kindOfList": "numbers", |
| 252 | + "list": [1.1] |
| 253 | + }, |
243 | 254 | "valid": true
|
244 | 255 | },
|
245 | 256 | {
|
246 |
| - "description": "recurse to integerNode - floats are not allowed", |
247 |
| - "data": { "november": 1.1 }, |
| 257 | + "description": "number list with string values", |
| 258 | + "data": { |
| 259 | + "kindOfList": "numbers", |
| 260 | + "list": ["foo"] |
| 261 | + }, |
248 | 262 | "valid": false
|
| 263 | + }, |
| 264 | + { |
| 265 | + "description": "string list with number values", |
| 266 | + "data": { |
| 267 | + "kindOfList": "strings", |
| 268 | + "list": [1.1] |
| 269 | + }, |
| 270 | + "valid": false |
| 271 | + }, |
| 272 | + { |
| 273 | + "description": "string list with string values", |
| 274 | + "data": { |
| 275 | + "kindOfList": "strings", |
| 276 | + "list": ["foo"] |
| 277 | + }, |
| 278 | + "valid": true |
249 | 279 | }
|
250 | 280 | ]
|
251 | 281 | },
|
|
564 | 594 | "valid": false
|
565 | 595 | }
|
566 | 596 | ]
|
| 597 | + }, |
| 598 | + { |
| 599 | + "description": "$ref to $dynamicRef finds detached $dynamicAnchor", |
| 600 | + "schema": { |
| 601 | + "$ref": "http://localhost:1234/draft-next/detached-dynamicref.json#/$defs/foo" |
| 602 | + }, |
| 603 | + "tests": [ |
| 604 | + { |
| 605 | + "description": "number is valid", |
| 606 | + "data": 1, |
| 607 | + "valid": true |
| 608 | + }, |
| 609 | + { |
| 610 | + "description": "non-number is invalid", |
| 611 | + "data": "a", |
| 612 | + "valid": false |
| 613 | + } |
| 614 | + ] |
567 | 615 | }
|
568 | 616 | ]
|
0 commit comments