Debian Codegraph @

share/tests/draft2019-09/additionalItems.json

raw
1 [
2 {
3 "description": "additionalItems as schema",
4 "schema": {
5 "$schema": "https://json-schema.org/draft/2019-09/schema",
6 "items": [{}],
7 "additionalItems": {"type": "integer"}
8 },
9 "tests": [
10 {
11 "description": "additional items match schema",
12 "data": [ null, 2, 3, 4 ],
13 "valid": true
14 },
15 {
16 "description": "additional items do not match schema",
17 "data": [ null, 2, 3, "foo" ],
18 "valid": false
19 }
20 ]
21 },
22 {
23 "description": "when items is schema, additionalItems does nothing",
24 "schema": {
25 "$schema":"https://json-schema.org/draft/2019-09/schema",
26 "items": {
27 "type": "integer"
28 },
29 "additionalItems": {
30 "type": "string"
31 }
32 },
33 "tests": [
34 {
35 "description": "valid with a array of type integers",
36 "data": [1,2,3],
37 "valid": true
38 },
39 {
40 "description": "invalid with a array of mixed types",
41 "data": [1,"2","3"],
42 "valid": false
43 }
44 ]
45 },
46 {
47 "description": "when items is schema, boolean additionalItems does nothing",
48 "schema": {
49 "$schema": "https://json-schema.org/draft/2019-09/schema",
50 "items": {},
51 "additionalItems": false
52 },
53 "tests": [
54 {
55 "description": "all items match schema",
56 "data": [ 1, 2, 3, 4, 5 ],
57 "valid": true
58 }
59 ]
60 },
61 {
62 "description": "array of items with no additionalItems permitted",
63 "schema": {
64 "$schema": "https://json-schema.org/draft/2019-09/schema",
65 "items": [{}, {}, {}],
66 "additionalItems": false
67 },
68 "tests": [
69 {
70 "description": "empty array",
71 "data": [ ],
72 "valid": true
73 },
74 {
75 "description": "fewer number of items present (1)",
76 "data": [ 1 ],
77 "valid": true
78 },
79 {
80 "description": "fewer number of items present (2)",
81 "data": [ 1, 2 ],
82 "valid": true
83 },
84 {
85 "description": "equal number of items present",
86 "data": [ 1, 2, 3 ],
87 "valid": true
88 },
89 {
90 "description": "additional items are not permitted",
91 "data": [ 1, 2, 3, 4 ],
92 "valid": false
93 }
94 ]
95 },
96 {
97 "description": "additionalItems as false without items",
98 "schema": {
99 "$schema": "https://json-schema.org/draft/2019-09/schema",
100 "additionalItems": false
101 },
102 "tests": [
103 {
104 "description":
105 "items defaults to empty schema so everything is valid",
106 "data": [ 1, 2, 3, 4, 5 ],
107 "valid": true
108 },
109 {
110 "description": "ignores non-arrays",
111 "data": {"foo" : "bar"},
112 "valid": true
113 }
114 ]
115 },
116 {
117 "description": "additionalItems are allowed by default",
118 "schema": {
119 "$schema": "https://json-schema.org/draft/2019-09/schema",
120 "items": [{"type": "integer"}]
121 },
122 "tests": [
123 {
124 "description": "only the first item is validated",
125 "data": [1, "foo", false],
126 "valid": true
127 }
128 ]
129 },
130 {
131 "description": "additionalItems does not look in applicators, invalid case",
132 "schema": {
133 "$schema": "https://json-schema.org/draft/2019-09/schema",
134 "allOf": [
135 { "items": [ { "type": "integer" }, { "type": "string" } ] }
136 ],
137 "items": [ {"type": "integer" } ],
138 "additionalItems": { "type": "boolean" }
139 },
140 "tests": [
141 {
142 "description": "items defined in allOf are not examined",
143 "data": [ 1, "hello" ],
144 "valid": false
145 }
146 ]
147 },
148 {
149 "description": "items validation adjusts the starting index for additionalItems",
150 "schema": {
151 "$schema": "https://json-schema.org/draft/2019-09/schema",
152 "items": [ { "type": "string" } ],
153 "additionalItems": { "type": "integer" }
154 },
155 "tests": [
156 {
157 "description": "valid items",
158 "data": [ "x", 2, 3 ],
159 "valid": true
160 },
161 {
162 "description": "wrong type of second item",
163 "data": [ "x", "y" ],
164 "valid": false
165 }
166 ]
167 },
168 {
169 "description": "additionalItems with heterogeneous array",
170 "schema": {
171 "$schema": "https://json-schema.org/draft/2019-09/schema",
172 "items": [{}],
173 "additionalItems": false
174 },
175 "tests": [
176 {
177 "description": "heterogeneous invalid instance",
178 "data": [ "foo", "bar", 37 ],
179 "valid": false
180 },
181 {
182 "description": "valid instance",
183 "data": [ null ],
184 "valid": true
185 }
186 ]
187 },
188 {
189 "description": "additionalItems with null instance elements",
190 "schema": {
191 "$schema": "https://json-schema.org/draft/2019-09/schema",
192 "additionalItems": {
193 "type": "null"
194 }
195 },
196 "tests": [
197 {
198 "description": "allows null elements",
199 "data": [ null ],
200 "valid": true
201 }
202 ]
203 }
204 ]