Skip to content

Commit 07c45c0

Browse files
committed
Restore the dependencies tests as optional for 2019, 2020, and next
The specification allows implementations to implement a compatibility mode for this keyword (which was split into dependentRequired and dependentSchemas), so we offer this optional file for those implementations. Its contents essentially just cat togeter the two other keywords' files. Closes: #303 See also https://json-schema.org/draft/2019-09/release-notes.html#semi-incompatible-changes
1 parent cf78d97 commit 07c45c0

File tree

3 files changed

+807
-0
lines changed

3 files changed

+807
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
[
2+
{
3+
"description": "single dependency",
4+
"schema": {"dependencies": {"bar": ["foo"]}},
5+
"tests": [
6+
{
7+
"description": "neither",
8+
"data": {},
9+
"valid": true
10+
},
11+
{
12+
"description": "nondependant",
13+
"data": {"foo": 1},
14+
"valid": true
15+
},
16+
{
17+
"description": "with dependency",
18+
"data": {"foo": 1, "bar": 2},
19+
"valid": true
20+
},
21+
{
22+
"description": "missing dependency",
23+
"data": {"bar": 2},
24+
"valid": false
25+
},
26+
{
27+
"description": "ignores arrays",
28+
"data": ["bar"],
29+
"valid": true
30+
},
31+
{
32+
"description": "ignores strings",
33+
"data": "foobar",
34+
"valid": true
35+
},
36+
{
37+
"description": "ignores other non-objects",
38+
"data": 12,
39+
"valid": true
40+
}
41+
]
42+
},
43+
{
44+
"description": "empty dependents",
45+
"schema": {"dependencies": {"bar": []}},
46+
"tests": [
47+
{
48+
"description": "empty object",
49+
"data": {},
50+
"valid": true
51+
},
52+
{
53+
"description": "object with one property",
54+
"data": {"bar": 2},
55+
"valid": true
56+
},
57+
{
58+
"description": "non-object is valid",
59+
"data": 1,
60+
"valid": true
61+
}
62+
]
63+
},
64+
{
65+
"description": "multiple dependents required",
66+
"schema": {"dependencies": {"quux": ["foo", "bar"]}},
67+
"tests": [
68+
{
69+
"description": "neither",
70+
"data": {},
71+
"valid": true
72+
},
73+
{
74+
"description": "nondependants",
75+
"data": {"foo": 1, "bar": 2},
76+
"valid": true
77+
},
78+
{
79+
"description": "with dependencies",
80+
"data": {"foo": 1, "bar": 2, "quux": 3},
81+
"valid": true
82+
},
83+
{
84+
"description": "missing dependency",
85+
"data": {"foo": 1, "quux": 2},
86+
"valid": false
87+
},
88+
{
89+
"description": "missing other dependency",
90+
"data": {"bar": 1, "quux": 2},
91+
"valid": false
92+
},
93+
{
94+
"description": "missing both dependencies",
95+
"data": {"quux": 1},
96+
"valid": false
97+
}
98+
]
99+
},
100+
{
101+
"description": "dependencies with escaped characters",
102+
"schema": {
103+
"dependencies": {
104+
"foo\nbar": ["foo\rbar"],
105+
"foo\"bar": ["foo'bar"]
106+
}
107+
},
108+
"tests": [
109+
{
110+
"description": "CRLF",
111+
"data": {
112+
"foo\nbar": 1,
113+
"foo\rbar": 2
114+
},
115+
"valid": true
116+
},
117+
{
118+
"description": "quoted quotes",
119+
"data": {
120+
"foo'bar": 1,
121+
"foo\"bar": 2
122+
},
123+
"valid": true
124+
},
125+
{
126+
"description": "CRLF missing dependent",
127+
"data": {
128+
"foo\nbar": 1,
129+
"foo": 2
130+
},
131+
"valid": false
132+
},
133+
{
134+
"description": "quoted quotes missing dependent",
135+
"data": {
136+
"foo\"bar": 2
137+
},
138+
"valid": false
139+
}
140+
]
141+
},
142+
{
143+
"description": "single schema dependency",
144+
"schema": {
145+
"dependencies": {
146+
"bar": {
147+
"properties": {
148+
"foo": {"type": "integer"},
149+
"bar": {"type": "integer"}
150+
}
151+
}
152+
}
153+
},
154+
"tests": [
155+
{
156+
"description": "valid",
157+
"data": {"foo": 1, "bar": 2},
158+
"valid": true
159+
},
160+
{
161+
"description": "no dependency",
162+
"data": {"foo": "quux"},
163+
"valid": true
164+
},
165+
{
166+
"description": "wrong type",
167+
"data": {"foo": "quux", "bar": 2},
168+
"valid": false
169+
},
170+
{
171+
"description": "wrong type other",
172+
"data": {"foo": 2, "bar": "quux"},
173+
"valid": false
174+
},
175+
{
176+
"description": "wrong type both",
177+
"data": {"foo": "quux", "bar": "quux"},
178+
"valid": false
179+
},
180+
{
181+
"description": "ignores arrays",
182+
"data": ["bar"],
183+
"valid": true
184+
},
185+
{
186+
"description": "ignores strings",
187+
"data": "foobar",
188+
"valid": true
189+
},
190+
{
191+
"description": "ignores other non-objects",
192+
"data": 12,
193+
"valid": true
194+
}
195+
]
196+
},
197+
{
198+
"description": "boolean subschemas",
199+
"schema": {
200+
"dependencies": {
201+
"foo": true,
202+
"bar": false
203+
}
204+
},
205+
"tests": [
206+
{
207+
"description": "object with property having schema true is valid",
208+
"data": {"foo": 1},
209+
"valid": true
210+
},
211+
{
212+
"description": "object with property having schema false is invalid",
213+
"data": {"bar": 2},
214+
"valid": false
215+
},
216+
{
217+
"description": "object with both properties is invalid",
218+
"data": {"foo": 1, "bar": 2},
219+
"valid": false
220+
},
221+
{
222+
"description": "empty object is valid",
223+
"data": {},
224+
"valid": true
225+
}
226+
]
227+
},
228+
{
229+
"description": "schema dependencies with escaped characters",
230+
"schema": {
231+
"dependencies": {
232+
"foo\tbar": {"minProperties": 4},
233+
"foo'bar": {"required": ["foo\"bar"]}
234+
}
235+
},
236+
"tests": [
237+
{
238+
"description": "quoted tab",
239+
"data": {
240+
"foo\tbar": 1,
241+
"a": 2,
242+
"b": 3,
243+
"c": 4
244+
},
245+
"valid": true
246+
},
247+
{
248+
"description": "quoted quote",
249+
"data": {
250+
"foo'bar": {"foo\"bar": 1}
251+
},
252+
"valid": false
253+
},
254+
{
255+
"description": "quoted tab invalid under dependent schema",
256+
"data": {
257+
"foo\tbar": 1,
258+
"a": 2
259+
},
260+
"valid": false
261+
},
262+
{
263+
"description": "quoted quote invalid under dependent schema",
264+
"data": {"foo'bar": 1},
265+
"valid": false
266+
}
267+
]
268+
}
269+
]

0 commit comments

Comments
 (0)