1[
2 {
3 "description": "anyOf",
4 "schema": {
5 "anyOf": [
6 {
7 "type": "integer"
8 },
9 {
10 "minimum": 2
11 }
12 ]
13 },
14 "tests": [
15 {
16 "description": "first anyOf valid",
17 "data": 1,
18 "valid": true
19 },
20 {
21 "description": "second anyOf valid",
22 "data": 2.5,
23 "valid": true
24 },
25 {
26 "description": "both anyOf valid",
27 "data": 3,
28 "valid": true
29 },
30 {
31 "description": "neither anyOf valid",
32 "data": 1.5,
33 "valid": false
34 }
35 ]
36 },
37 {
38 "description": "anyOf with base schema",
39 "schema": {
40 "type": "string",
41 "anyOf" : [
42 {
43 "maxLength": 2
44 },
45 {
46 "minLength": 4
47 }
48 ]
49 },
50 "tests": [
51 {
52 "description": "mismatch base schema",
53 "data": 3,
54 "valid": false
55 },
56 {
57 "description": "one anyOf valid",
58 "data": "foobar",
59 "valid": true
60 },
61 {
62 "description": "both anyOf invalid",
63 "data": "foo",
64 "valid": false
65 }
66 ]
67 },
68 {
69 "description": "anyOf with boolean schemas, all true",
70 "schema": {"anyOf": [true, true]},
71 "tests": [
72 {
73 "description": "any value is valid",
74 "data": "foo",
75 "valid": true
76 }
77 ]
78 },
79 {
80 "description": "anyOf with boolean schemas, some true",
81 "schema": {"anyOf": [true, false]},
82 "tests": [
83 {
84 "description": "any value is valid",
85 "data": "foo",
86 "valid": true
87 }
88 ]
89 },
90 {
91 "description": "anyOf with boolean schemas, all false",
92 "schema": {"anyOf": [false, false]},
93 "tests": [
94 {
95 "description": "any value is invalid",
96 "data": "foo",
97 "valid": false
98 }
99 ]
100 },
101 {
102 "description": "anyOf complex types",
103 "schema": {
104 "anyOf": [
105 {
106 "properties": {
107 "bar": {"type": "integer"}
108 },
109 "required": ["bar"]
110 },
111 {
112 "properties": {
113 "foo": {"type": "string"}
114 },
115 "required": ["foo"]
116 }
117 ]
118 },
119 "tests": [
120 {
121 "description": "first anyOf valid (complex)",
122 "data": {"bar": 2},
123 "valid": true
124 },
125 {
126 "description": "second anyOf valid (complex)",
127 "data": {"foo": "baz"},
128 "valid": true
129 },
130 {
131 "description": "both anyOf valid (complex)",
132 "data": {"foo": "baz", "bar": 2},
133 "valid": true
134 },
135 {
136 "description": "neither anyOf valid (complex)",
137 "data": {"foo": 2, "bar": "quux"},
138 "valid": false
139 }
140 ]
141 },
142 {
143 "description": "anyOf with one empty schema",
144 "schema": {
145 "anyOf": [
146 { "type": "number" },
147 {}
148 ]
149 },
150 "tests": [
151 {
152 "description": "string is valid",
153 "data": "foo",
154 "valid": true
155 },
156 {
157 "description": "number is valid",
158 "data": 123,
159 "valid": true
160 }
161 ]
162 },
163 {
164 "description": "nested anyOf, to check validation semantics",
165 "schema": {
166 "anyOf": [
167 {
168 "anyOf": [
169 {
170 "type": "null"
171 }
172 ]
173 }
174 ]
175 },
176 "tests": [
177 {
178 "description": "null is valid",
179 "data": null,
180 "valid": true
181 },
182 {
183 "description": "anything non-null is invalid",
184 "data": 123,
185 "valid": false
186 }
187 ]
188 },
189 {
190 "description": "nested anyOf, to check validation semantics",
191 "schema": {
192 "anyOf": [
193 {
194 "anyOf": [
195 {
196 "type": "null"
197 }
198 ]
199 }
200 ]
201 },
202 "tests": [
203 {
204 "description": "null is valid",
205 "data": null,
206 "valid": true
207 },
208 {
209 "description": "anything non-null is invalid",
210 "data": 123,
211 "valid": false
212 }
213 ]
214 }
215]
View as plain text