Skip to content

Commit 8025fc0

Browse files
authored
Merge pull request #128 from iainbeeston/foundations-of-json-schema-paper
Added test cases from Foundations of JSON Schema research paper
2 parents cf76770 + 07fd389 commit 8025fc0

12 files changed

+258
-0
lines changed

tests/draft-next/dependentSchemas.json

+38
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,43 @@
128128
"valid": false
129129
}
130130
]
131+
},
132+
{
133+
"description": "dependent subschema incompatible with root",
134+
"schema": {
135+
"properties": {
136+
"foo": {}
137+
},
138+
"dependentSchemas": {
139+
"foo": {
140+
"properties": {
141+
"bar": {}
142+
},
143+
"additionalProperties": false
144+
}
145+
}
146+
},
147+
"tests": [
148+
{
149+
"description": "matches root",
150+
"data": {"foo": 1},
151+
"valid": false
152+
},
153+
{
154+
"description": "matches dependency",
155+
"data": {"bar": 1},
156+
"valid": true
157+
},
158+
{
159+
"description": "matches both",
160+
"data": {"foo": 1, "bar": 2},
161+
"valid": false
162+
},
163+
{
164+
"description": "no dependency",
165+
"data": {"baz": 1},
166+
"valid": true
167+
}
168+
]
131169
}
132170
]

tests/draft-next/uniqueItems.json

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
"data": [{"foo": "bar"}, {"foo": "bar"}],
5757
"valid": false
5858
},
59+
{
60+
"description": "property order of array of objects is ignored",
61+
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
62+
"valid": false
63+
},
5964
{
6065
"description": "unique array of nested objects is valid",
6166
"data": [

tests/draft2019-09/dependentSchemas.json

+38
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,43 @@
128128
"valid": false
129129
}
130130
]
131+
},
132+
{
133+
"description": "dependent subschema incompatible with root",
134+
"schema": {
135+
"properties": {
136+
"foo": {}
137+
},
138+
"dependentSchemas": {
139+
"foo": {
140+
"properties": {
141+
"bar": {}
142+
},
143+
"additionalProperties": false
144+
}
145+
}
146+
},
147+
"tests": [
148+
{
149+
"description": "matches root",
150+
"data": {"foo": 1},
151+
"valid": false
152+
},
153+
{
154+
"description": "matches dependency",
155+
"data": {"bar": 1},
156+
"valid": true
157+
},
158+
{
159+
"description": "matches both",
160+
"data": {"foo": 1, "bar": 2},
161+
"valid": false
162+
},
163+
{
164+
"description": "no dependency",
165+
"data": {"baz": 1},
166+
"valid": true
167+
}
168+
]
131169
}
132170
]

tests/draft2019-09/uniqueItems.json

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
"data": [{"foo": "bar"}, {"foo": "bar"}],
5757
"valid": false
5858
},
59+
{
60+
"description": "property order of array of objects is ignored",
61+
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
62+
"valid": false
63+
},
5964
{
6065
"description": "unique array of nested objects is valid",
6166
"data": [

tests/draft2020-12/dependentSchemas.json

+38
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,43 @@
128128
"valid": false
129129
}
130130
]
131+
},
132+
{
133+
"description": "dependent subschema incompatible with root",
134+
"schema": {
135+
"properties": {
136+
"foo": {}
137+
},
138+
"dependentSchemas": {
139+
"foo": {
140+
"properties": {
141+
"bar": {}
142+
},
143+
"additionalProperties": false
144+
}
145+
}
146+
},
147+
"tests": [
148+
{
149+
"description": "matches root",
150+
"data": {"foo": 1},
151+
"valid": false
152+
},
153+
{
154+
"description": "matches dependency",
155+
"data": {"bar": 1},
156+
"valid": true
157+
},
158+
{
159+
"description": "matches both",
160+
"data": {"foo": 1, "bar": 2},
161+
"valid": false
162+
},
163+
{
164+
"description": "no dependency",
165+
"data": {"baz": 1},
166+
"valid": true
167+
}
168+
]
131169
}
132170
]

tests/draft2020-12/uniqueItems.json

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@
5656
"data": [{"foo": "bar"}, {"foo": "bar"}],
5757
"valid": false
5858
},
59+
{
60+
"description": "property order of array of objects is ignored",
61+
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
62+
"valid": false
63+
},
5964
{
6065
"description": "unique array of nested objects is valid",
6166
"data": [

tests/draft4/dependencies.json

+38
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,43 @@
190190
"valid": false
191191
}
192192
]
193+
},
194+
{
195+
"description": "dependent subschema incompatible with root",
196+
"schema": {
197+
"properties": {
198+
"foo": {}
199+
},
200+
"dependencies": {
201+
"foo": {
202+
"properties": {
203+
"bar": {}
204+
},
205+
"additionalProperties": false
206+
}
207+
}
208+
},
209+
"tests": [
210+
{
211+
"description": "matches root",
212+
"data": {"foo": 1},
213+
"valid": false
214+
},
215+
{
216+
"description": "matches dependency",
217+
"data": {"bar": 1},
218+
"valid": true
219+
},
220+
{
221+
"description": "matches both",
222+
"data": {"foo": 1, "bar": 2},
223+
"valid": false
224+
},
225+
{
226+
"description": "no dependency",
227+
"data": {"baz": 1},
228+
"valid": true
229+
}
230+
]
193231
}
194232
]

tests/draft4/uniqueItems.json

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
"data": [{"foo": "bar"}, {"foo": "bar"}],
5454
"valid": false
5555
},
56+
{
57+
"description": "property order of array of objects is ignored",
58+
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
59+
"valid": false
60+
},
5661
{
5762
"description": "unique array of nested objects is valid",
5863
"data": [

tests/draft6/dependencies.json

+38
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,43 @@
244244
"valid": false
245245
}
246246
]
247+
},
248+
{
249+
"description": "dependent subschema incompatible with root",
250+
"schema": {
251+
"properties": {
252+
"foo": {}
253+
},
254+
"dependencies": {
255+
"foo": {
256+
"properties": {
257+
"bar": {}
258+
},
259+
"additionalProperties": false
260+
}
261+
}
262+
},
263+
"tests": [
264+
{
265+
"description": "matches root",
266+
"data": {"foo": 1},
267+
"valid": false
268+
},
269+
{
270+
"description": "matches dependency",
271+
"data": {"bar": 1},
272+
"valid": true
273+
},
274+
{
275+
"description": "matches both",
276+
"data": {"foo": 1, "bar": 2},
277+
"valid": false
278+
},
279+
{
280+
"description": "no dependency",
281+
"data": {"baz": 1},
282+
"valid": true
283+
}
284+
]
247285
}
248286
]

tests/draft6/uniqueItems.json

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
"data": [{"foo": "bar"}, {"foo": "bar"}],
5454
"valid": false
5555
},
56+
{
57+
"description": "property order of array of objects is ignored",
58+
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
59+
"valid": false
60+
},
5661
{
5762
"description": "unique array of nested objects is valid",
5863
"data": [

tests/draft7/dependencies.json

+38
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,43 @@
244244
"valid": false
245245
}
246246
]
247+
},
248+
{
249+
"description": "dependent subschema incompatible with root",
250+
"schema": {
251+
"properties": {
252+
"foo": {}
253+
},
254+
"dependencies": {
255+
"foo": {
256+
"properties": {
257+
"bar": {}
258+
},
259+
"additionalProperties": false
260+
}
261+
}
262+
},
263+
"tests": [
264+
{
265+
"description": "matches root",
266+
"data": {"foo": 1},
267+
"valid": false
268+
},
269+
{
270+
"description": "matches dependency",
271+
"data": {"bar": 1},
272+
"valid": true
273+
},
274+
{
275+
"description": "matches both",
276+
"data": {"foo": 1, "bar": 2},
277+
"valid": false
278+
},
279+
{
280+
"description": "no dependency",
281+
"data": {"baz": 1},
282+
"valid": true
283+
}
284+
]
247285
}
248286
]

tests/draft7/uniqueItems.json

+5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
"data": [{"foo": "bar"}, {"foo": "bar"}],
5454
"valid": false
5555
},
56+
{
57+
"description": "property order of array of objects is ignored",
58+
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
59+
"valid": false
60+
},
5661
{
5762
"description": "unique array of nested objects is valid",
5863
"data": [

0 commit comments

Comments
 (0)