Debian Codegraph @

t/additional-tests-draft2020-12/dynamicRef.json

raw
1 [
2 {
3 "description": "after leaving a dynamic scope, it should not be used by a $dynamicRef",
4 "schema": {
5 "$id": "main",
6 "if": {
7 "$id": "first_scope",
8 "$defs": {
9 "thingy": {
10 "$comment": "this is first_scope#thingy",
11 "$dynamicAnchor": "thingy",
12 "type": "number"
13 }
14 }
15 },
16 "then": {
17 "$id": "second_scope",
18 "$ref": "start",
19 "$defs": {
20 "thingy": {
21 "$comment": "this is second_scope#thingy, the final destination of the $dynamicRef",
22 "$dynamicAnchor": "thingy",
23 "type": "null"
24 }
25 }
26 },
27 "$defs": {
28 "start": {
29 "$comment": "this is the landing spot from $ref",
30 "$id": "start",
31 "$dynamicRef": "inner_scope#thingy"
32 },
33 "thingy": {
34 "$comment": "this is the first stop by the $dynamicRef",
35 "$id": "inner_scope",
36 "$dynamicAnchor": "thingy",
37 "type": "string"
38 }
39 }
40 },
41 "tests": [
42 {
43 "description": "string matches /$defs/thingy, but the $dynamicRef does not stop here",
44 "data": "a string",
45 "valid": false
46 },
47 {
48 "description": "first_scope is not in dynamic scope for the $dynamicRef",
49 "data": 42,
50 "valid": false
51 },
52 {
53 "description": "value validates against /then/$defs/thingy, the final stop for the $dynamicRef",
54 "data": null,
55 "valid": true
56 }
57 ]
58 },
59 {
60 "description": "schema in dynamic scope must have a $dynamicAnchor that matches the fragment",
61 "schema": {
62 "$defs": {
63 "enhanced": {
64 "$comment": "a matching $anchor is not sufficient: it must be a $dynamicAnchor",
65 "$anchor": "thingy",
66 "$dynamicAnchor": "something_else",
67 "minimum": 10
68 },
69 "orig": {
70 "$id": "orig",
71 "$dynamicAnchor": "thingy",
72 "minimum": 2
73 }
74 },
75 "$dynamicRef": "orig#thingy"
76 },
77 "tests": [
78 {
79 "description": "value would fail under either subschema",
80 "data": 1,
81 "valid": false
82 },
83 {
84 "description": "$anchor does not match $dynamicAnchor; original subschema is used",
85 "data": 5,
86 "valid": true
87 }
88 ]
89 },
90 {
91 "description": "$dynamicRef points to a boolean schema",
92 "schema": {
93 "$comment": "submitted as https://github.com/json-schema-org/JSON-Schema-Test-Suite/pull/701",
94 "$schema": "https://json-schema.org/draft/2020-12/schema",
95 "$defs": {
96 "true": true,
97 "false": false
98 },
99 "properties": {
100 "true": {
101 "$dynamicRef": "#/$defs/true"
102 },
103 "false": {
104 "$dynamicRef": "#/$defs/false"
105 }
106 }
107 },
108 "tests": [
109 {
110 "description": "follow $dynamicRef to a true schema",
111 "data": { "true": 1 },
112 "valid": true
113 },
114 {
115 "description": "follow $dynamicRef to a false schema",
116 "data": { "false": 1 },
117 "valid": false
118 }
119 ]
120 }
121 ]