Skip to content

Commit cd441d2

Browse files
committed
A whole new version of multiple dynamic paths
1 parent e93077e commit cd441d2

File tree

1 file changed

+58
-35
lines changed

1 file changed

+58
-35
lines changed

tests/draft2020-12/dynamicRef.json

Lines changed: 58 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -393,59 +393,82 @@
393393
"$schema": "https://json-schema.org/draft/2020-12/schema",
394394
"$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main",
395395
"if": {
396-
"propertyNames": {
397-
"pattern": "^[a-m]"
398-
}
399-
},
400-
"then": {
401-
"$id": "numberValues",
402-
"$defs": {
403-
"foo": {
404-
"$dynamicAnchor": "foo",
405-
"type": "number"
406-
}
407-
},
408-
"$ref": "inner"
409-
},
410-
"else": {
411-
"$id": "stringValues",
412-
"$defs": {
413-
"foo": {
414-
"$dynamicAnchor": "foo",
415-
"type": "string"
416-
}
396+
"properties": {
397+
"kindOfList": { "const": "numbers" }
417398
},
418-
"$ref": "inner"
399+
"required": ["kindOfList"]
419400
},
401+
"then": { "$ref": "numberList" },
402+
"else": { "$ref": "stringList" },
403+
420404
"$defs": {
421-
"inner": {
422-
"$id": "inner",
423-
"$dynamicAnchor": "foo",
424-
"additionalProperties": {
425-
"$dynamicRef": "#foo"
405+
"genericList": {
406+
"$id": "genericList",
407+
"properties": {
408+
"list": {
409+
"items": { "$dynamicRef": "#itemType" }
410+
}
411+
},
412+
"$defs": {
413+
"defaultItemType": {
414+
"$comment": "Only needed to satisfy bookending requirement",
415+
"$dynamicAnchor": "itemType"
416+
}
426417
}
418+
},
419+
"numberList": {
420+
"$id": "numberList",
421+
"$defs": {
422+
"itemType": {
423+
"$dynamicAnchor": "itemType",
424+
"type": "number"
425+
}
426+
},
427+
"$ref": "genericList"
428+
},
429+
"stringList": {
430+
"$id": "stringList",
431+
"$defs": {
432+
"itemType": {
433+
"$dynamicAnchor": "itemType",
434+
"type": "string"
435+
}
436+
},
437+
"$ref": "genericList"
427438
}
428439
}
429440
},
430441
"tests": [
431442
{
432-
"description": "alpha with number values",
433-
"data": { "alpha": 1.1 },
443+
"description": "number list with number values",
444+
"data": {
445+
"kindOfList": "numbers",
446+
"list": [1.1]
447+
},
434448
"valid": true
435449
},
436450
{
437-
"description": "alpha with string values",
438-
"data": { "alpha": "foo" },
451+
"description": "number list with string values",
452+
"data": {
453+
"kindOfList": "numbers",
454+
"list": ["foo"]
455+
},
439456
"valid": false
440457
},
441458
{
442-
"description": "november with number values",
443-
"data": { "november": 1.1 },
459+
"description": "string list with number values",
460+
"data": {
461+
"kindOfList": "strings",
462+
"list": [1.1]
463+
},
444464
"valid": false
445465
},
446466
{
447-
"description": "november with string values",
448-
"data": { "november": "foo" },
467+
"description": "string list with string values",
468+
"data": {
469+
"kindOfList": "strings",
470+
"list": ["foo"]
471+
},
449472
"valid": true
450473
}
451474
]

0 commit comments

Comments
 (0)