Debian Codegraph @

t/additional-tests-draft2019-09/recursive-dynamic.json

raw
1 [
2 {
3 "description": "dynamic $recursiveRef destination (not predictable at schema compile time)",
4 "schema": {
5 "$id": "main.json",
6 "$defs": {
7 "inner": {
8 "$id": "inner.json",
9 "$recursiveAnchor": true,
10 "title": "inner",
11 "additionalProperties": {
12 "$recursiveRef": "#"
13 }
14 }
15
16 },
17 "if": { "propertyNames": { "pattern": "^[a-m]" } },
18 "then": {
19 "title": "any type of node",
20 "$id": "anyLeafNode.json",
21 "$recursiveAnchor": true,
22 "$ref": "main.json#/$defs/inner"
23 },
24 "else": {
25 "title": "integer node",
26 "$id": "integerNode.json",
27 "$recursiveAnchor": true,
28 "type": [ "object", "integer" ],
29 "$ref": "main.json#/$defs/inner"
30 }
31 },
32 "tests": [
33 {
34 "description": "numeric node",
35 "data": { "alpha": 1.1 },
36 "valid": true
37 },
38 {
39 "description": "integer node",
40 "data": { "november": 1.1 },
41 "valid": false
42 }
43 ]
44 },
45 {
46 "description": "$recursiveRef points to a boolean schema",
47 "schema": {
48 "$schema": "https://json-schema.org/draft/2019-09/schema",
49 "$defs": {
50 "true": true,
51 "false": false
52 },
53 "properties": {
54 "true": {
55 "$recursiveRef": "#/$defs/true"
56 },
57 "false": {
58 "$recursiveRef": "#/$defs/false"
59 }
60 }
61 },
62 "tests": [
63 {
64 "description": "follow $recursiveRef to a true schema",
65 "data": { "true": 1 },
66 "valid": true
67 },
68 {
69 "description": "follow $recursiveRef to a false schema",
70 "data": { "false": 1 },
71 "valid": false
72 }
73 ]
74 }
75 ]