Debian Codegraph @

share/tests/draft6/additionalItems.json

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