Debian Codegraph @

spec/JSON-Schema-Test-Suite/tests/draft2020-12/items.json

raw ◀ ▶
1 Debian patch touch this file
•1 [
2 {
3 "description": "a schema given for items",
4 "schema": {
5 "items": {"type": "integer"}
6 },
7 "tests": [
8 {
9 "description": "valid items",
10 "data": [ 1, 2, 3 ],
11 "valid": true
12 },
13 {
14 "description": "wrong type of items",
15 "data": [1, "x"],
16 "valid": false
17 },
18 {
19 "description": "ignores non-arrays",
20 "data": {"foo" : "bar"},
21 "valid": true
22 },
23 {
24 "description": "JavaScript pseudo-array is valid",
25 "data": {
26 "0": "invalid",
27 "length": 1
28 },
29 "valid": true
30 }
31 ]
32 },
33 {
34 "description": "items with boolean schema (true)",
35 "schema": {"items": true},
36 "tests": [
37 {
38 "description": "any array is valid",
39 "data": [ 1, "foo", true ],
40 "valid": true
41 },
42 {
43 "description": "empty array is valid",
44 "data": [],
45 "valid": true
46 }
47 ]
48 },
49 {
50 "description": "items with boolean schema (false)",
51 "schema": {"items": false},
52 "tests": [
53 {
54 "description": "any non-empty array is invalid",
55 "data": [ 1, "foo", true ],
56 "valid": false
57 },
58 {
59 "description": "empty array is valid",
60 "data": [],
61 "valid": true
62 }
63 ]
64 },
65 {
66 "description": "items and subitems",
67 "schema": {
68 "$defs": {
69 "item": {
70 "type": "array",
71 "items": false,
72 "prefixItems": [
73 { "$ref": "#/$defs/sub-item" },
74 { "$ref": "#/$defs/sub-item" }
75 ]
76 },
77 "sub-item": {
78 "type": "object",
79 "required": ["foo"]
80 }
81 },
82 "type": "array",
83 "items": false,
84 "prefixItems": [
85 { "$ref": "#/$defs/item" },
86 { "$ref": "#/$defs/item" },
87 { "$ref": "#/$defs/item" }
88 ]
89 },
90 "tests": [
91 {
92 "description": "valid items",
93 "data": [
94 [ {"foo": null}, {"foo": null} ],
95 [ {"foo": null}, {"foo": null} ],
96 [ {"foo": null}, {"foo": null} ]
97 ],
98 "valid": true
99 },
100 {
101 "description": "too many items",
102 "data": [
103 [ {"foo": null}, {"foo": null} ],
104 [ {"foo": null}, {"foo": null} ],
105 [ {"foo": null}, {"foo": null} ],
106 [ {"foo": null}, {"foo": null} ]
107 ],
108 "valid": false
109 },
110 {
111 "description": "too many sub-items",
112 "data": [
113 [ {"foo": null}, {"foo": null}, {"foo": null} ],
114 [ {"foo": null}, {"foo": null} ],
115 [ {"foo": null}, {"foo": null} ]
116 ],
117 "valid": false
118 },
119 {
120 "description": "wrong item",
121 "data": [
122 {"foo": null},
123 [ {"foo": null}, {"foo": null} ],
124 [ {"foo": null}, {"foo": null} ]
125 ],
126 "valid": false
127 },
128 {
129 "description": "wrong sub-item",
130 "data": [
131 [ {}, {"foo": null} ],
132 [ {"foo": null}, {"foo": null} ],
133 [ {"foo": null}, {"foo": null} ]
134 ],
135 "valid": false
136 },
137 {
138 "description": "fewer items is valid",
139 "data": [
140 [ {"foo": null} ],
141 [ {"foo": null} ]
142 ],
143 "valid": true
144 }
145 ]
146 },
147 {
148 "description": "nested items",
149 "schema": {
150 "type": "array",
151 "items": {
152 "type": "array",
153 "items": {
154 "type": "array",
155 "items": {
156 "type": "array",
157 "items": {
158 "type": "number"
159 }
160 }
161 }
162 }
163 },
164 "tests": [
165 {
166 "description": "valid nested array",
167 "data": [[[[1]], [[2],[3]]], [[[4], [5], [6]]]],
168 "valid": true
169 },
170 {
171 "description": "nested array with invalid type",
172 "data": [[[["1"]], [[2],[3]]], [[[4], [5], [6]]]],
173 "valid": false
174 },
175 {
176 "description": "not deep enough",
177 "data": [[[1], [2],[3]], [[4], [5], [6]]],
178 "valid": false
179 }
180 ]
181 },
182 {
183 "description": "prefixItems with no additional items allowed",
184 "schema": {
185 "prefixItems": [{}, {}, {}],
186 "items": false
187 },
188 "tests": [
189 {
190 "description": "empty array",
191 "data": [ ],
192 "valid": true
193 },
194 {
195 "description": "fewer number of items present (1)",
196 "data": [ 1 ],
197 "valid": true
198 },
199 {
200 "description": "fewer number of items present (2)",
201 "data": [ 1, 2 ],
202 "valid": true
203 },
204 {
205 "description": "equal number of items present",
206 "data": [ 1, 2, 3 ],
207 "valid": true
208 },
209 {
210 "description": "additional items are not permitted",
211 "data": [ 1, 2, 3, 4 ],
212 "valid": false
213 }
214 ]
215 },
216 {
217 "description": "items should not look in applicators, valid case",
218 "schema": {
219 "allOf": [
220 { "prefixItems": [ { "minimum": 3 } ] }
221 ],
222 "items": { "minimum": 5 }
223 },
224 "tests": [
225 {
226 "description": "prefixItems in allOf should not constrain items, invalid case",
227 "data": [ 3, 5 ],
228 "valid": false
229 },
230 {
231 "description": "prefixItems in allOf should not constrain items, valid case",
232 "data": [ 5, 5 ],
233 "valid": true
234 }
235 ]
236 },
237 {
238 "description": "prefixItems validation adjusts the starting index for items",
239 "schema": {
240 "prefixItems": [ { "type": "string" } ],
241 "items": { "type": "integer" }
242 },
243 "tests": [
244 {
245 "description": "valid items",
246 "data": [ "x", 2, 3 ],
247 "valid": true
248 },
249 {
250 "description": "wrong type of second item",
251 "data": [ "x", "y" ],
252 "valid": false
253 }
254 ]
255 }
256 ]