Skip to content

Commit e0a2a71

Browse files
committed
Squashed 'json/' changes from 8e2a05a9..d17e1ba2
d17e1ba2 [242] Add pattern tests for numbers, objects, arrays, and null a5302a46 [329] Add tests for uniqueItems=false 0bf6358f [166] Add null-in-enum test 807591f0 Merge pull request #340 from karenetheridge/ether/markdown-conflict-markers e4c82f21 disambiguate underline from git conflict marker c4d3e0f9 Merge pull request #333 from zhxiaogg/tests-for-duration-format 618b30dc not all duration impl support year and month 926d0b3d tests for duration format 22eaffcd Merge pull request #331 from jdanyow/patch-2 b2e553e9 Merge pull request #330 from jdanyow/patch-1 9db34a17 remove unused constant cbf4654d fix typo in ref test description 44517887 Merge pull request #326 from awwright/master 0da2aaa1 Backport nested allOf/anyOf/oneOf tests 34a2dfa3 Add nested allOf, oneOf tests git-subtree-dir: json git-subtree-split: d17e1ba218bbd023d45182e014c0ce341bb36b16
1 parent da5b73d commit e0a2a71

30 files changed

+1398
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
JSON Schema Test Suite [![Build Status](https://github.com/json-schema-org/JSON-Schema-Test-Suite/workflows/Test%20Suite%20Sanity%20Checking/badge.svg)](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
2-
======================
2+
======
33

44
This repository contains a set of JSON objects that implementors of JSON Schema
55
validation libraries can use to test their validators.

index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const Ajv = require('ajv');
44
const jsonSchemaTest = require('json-schema-test');
5-
const assert = require('assert');
65

76
const refs = {
87
'http://localhost:1234/integer.json': require('./remotes/integer.json'),

tests/draft2019-09/allOf.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,31 @@
214214
"valid": false
215215
}
216216
]
217+
},
218+
{
219+
"description": "nested allOf, to check validation semantics",
220+
"schema": {
221+
"allOf": [
222+
{
223+
"allOf": [
224+
{
225+
"type": "null"
226+
}
227+
]
228+
}
229+
]
230+
},
231+
"tests": [
232+
{
233+
"description": "null is valid",
234+
"data": null,
235+
"valid": true
236+
},
237+
{
238+
"description": "anything non-null is invalid",
239+
"data": 123,
240+
"valid": false
241+
}
242+
]
217243
}
218244
]

tests/draft2019-09/enum.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@
3636
}
3737
]
3838
},
39+
{
40+
"description": "heterogeneous enum-with-null validation",
41+
"schema": { "enum": [6, null] },
42+
"tests": [
43+
{
44+
"description": "null is valid",
45+
"data": null,
46+
"valid": true
47+
},
48+
{
49+
"description": "number is valid",
50+
"data": 6,
51+
"valid": true
52+
},
53+
{
54+
"description": "something else is invalid",
55+
"data": "test",
56+
"valid": false
57+
}
58+
]
59+
},
3960
{
4061
"description": "enums in properties",
4162
"schema": {

tests/draft2019-09/oneOf.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,31 @@
244244
"valid": false
245245
}
246246
]
247+
},
248+
{
249+
"description": "nested oneOf, to check validation semantics",
250+
"schema": {
251+
"oneOf": [
252+
{
253+
"oneOf": [
254+
{
255+
"type": "null"
256+
}
257+
]
258+
}
259+
]
260+
},
261+
"tests": [
262+
{
263+
"description": "null is valid",
264+
"data": null,
265+
"valid": true
266+
},
267+
{
268+
"description": "anything non-null is invalid",
269+
"data": 123,
270+
"valid": false
271+
}
272+
]
247273
}
248274
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"description": "validation of duration strings",
4+
"schema": {"format": "duration"},
5+
"tests": [
6+
{
7+
"description": "a valid duration string",
8+
"data": "P4DT12H30M5S",
9+
"valid": true
10+
},
11+
{
12+
"description": "an invalid duration string",
13+
"data": "PT1D",
14+
"valid": false
15+
}
16+
]
17+
}
18+
]

tests/draft2019-09/pattern.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,34 @@
1414
"valid": false
1515
},
1616
{
17-
"description": "ignores non-strings",
17+
"description": "ignores booleans",
1818
"data": true,
1919
"valid": true
20+
},
21+
{
22+
"description": "ignores integers",
23+
"data": 123,
24+
"valid": true
25+
},
26+
{
27+
"description": "ignores floats",
28+
"data": 1.0,
29+
"valid": true
30+
},
31+
{
32+
"description": "ignores objects",
33+
"data": {},
34+
"valid": true
35+
},
36+
{
37+
"description": "ignores arrays",
38+
"data": [],
39+
"valid": true
40+
},
41+
{
42+
"description": "ignores null",
43+
"data": null,
44+
"valid": true
2045
}
2146
]
2247
},

tests/draft2019-09/ref.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@
375375
},
376376
"tests": [
377377
{
378-
"description": "referenced subschema doesn't see annoations from properties",
378+
"description": "referenced subschema doesn't see annotations from properties",
379379
"data": {
380380
"prop1": "match"
381381
},

tests/draft2019-09/uniqueItems.json

Lines changed: 174 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
{
9090
"description": "uniqueItems with an array of items",
9191
"schema": {
92-
"items": [{"type": "boolean"}, {"type": "boolean"}],
92+
"items": [{"type": "boolean"}, {"type": "boolean"}],
9393
"uniqueItems": true
9494
},
9595
"tests": [
@@ -138,8 +138,8 @@
138138
{
139139
"description": "uniqueItems with an array of items and additionalItems=false",
140140
"schema": {
141-
"items": [{"type": "boolean"}, {"type": "boolean"}],
142-
"uniqueItems": true,
141+
"items": [{"type": "boolean"}, {"type": "boolean"}],
142+
"uniqueItems": true,
143143
"additionalItems": false
144144
},
145145
"tests": [
@@ -169,5 +169,176 @@
169169
"valid": false
170170
}
171171
]
172+
},
173+
{
174+
"description": "uniqueItems=false validation",
175+
"schema": { "uniqueItems": false },
176+
"tests": [
177+
{
178+
"description": "unique array of integers is valid",
179+
"data": [1, 2],
180+
"valid": true
181+
},
182+
{
183+
"description": "non-unique array of integers is valid",
184+
"data": [1, 1],
185+
"valid": true
186+
},
187+
{
188+
"description": "numbers are unique if mathematically unequal",
189+
"data": [1.0, 1.00, 1],
190+
"valid": true
191+
},
192+
{
193+
"description": "false is not equal to zero",
194+
"data": [0, false],
195+
"valid": true
196+
},
197+
{
198+
"description": "true is not equal to one",
199+
"data": [1, true],
200+
"valid": true
201+
},
202+
{
203+
"description": "unique array of objects is valid",
204+
"data": [{"foo": "bar"}, {"foo": "baz"}],
205+
"valid": true
206+
},
207+
{
208+
"description": "non-unique array of objects is valid",
209+
"data": [{"foo": "bar"}, {"foo": "bar"}],
210+
"valid": true
211+
},
212+
{
213+
"description": "unique array of nested objects is valid",
214+
"data": [
215+
{"foo": {"bar" : {"baz" : true}}},
216+
{"foo": {"bar" : {"baz" : false}}}
217+
],
218+
"valid": true
219+
},
220+
{
221+
"description": "non-unique array of nested objects is valid",
222+
"data": [
223+
{"foo": {"bar" : {"baz" : true}}},
224+
{"foo": {"bar" : {"baz" : true}}}
225+
],
226+
"valid": true
227+
},
228+
{
229+
"description": "unique array of arrays is valid",
230+
"data": [["foo"], ["bar"]],
231+
"valid": true
232+
},
233+
{
234+
"description": "non-unique array of arrays is valid",
235+
"data": [["foo"], ["foo"]],
236+
"valid": true
237+
},
238+
{
239+
"description": "1 and true are unique",
240+
"data": [1, true],
241+
"valid": true
242+
},
243+
{
244+
"description": "0 and false are unique",
245+
"data": [0, false],
246+
"valid": true
247+
},
248+
{
249+
"description": "unique heterogeneous types are valid",
250+
"data": [{}, [1], true, null, 1],
251+
"valid": true
252+
},
253+
{
254+
"description": "non-unique heterogeneous types are valid",
255+
"data": [{}, [1], true, null, {}, 1],
256+
"valid": true
257+
}
258+
]
259+
},
260+
{
261+
"description": "uniqueItems=false with an array of items",
262+
"schema": {
263+
"items": [{"type": "boolean"}, {"type": "boolean"}],
264+
"uniqueItems": false
265+
},
266+
"tests": [
267+
{
268+
"description": "[false, true] from items array is valid",
269+
"data": [false, true],
270+
"valid": true
271+
},
272+
{
273+
"description": "[true, false] from items array is valid",
274+
"data": [true, false],
275+
"valid": true
276+
},
277+
{
278+
"description": "[false, false] from items array is valid",
279+
"data": [false, false],
280+
"valid": true
281+
},
282+
{
283+
"description": "[true, true] from items array is valid",
284+
"data": [true, true],
285+
"valid": true
286+
},
287+
{
288+
"description": "unique array extended from [false, true] is valid",
289+
"data": [false, true, "foo", "bar"],
290+
"valid": true
291+
},
292+
{
293+
"description": "unique array extended from [true, false] is valid",
294+
"data": [true, false, "foo", "bar"],
295+
"valid": true
296+
},
297+
{
298+
"description": "non-unique array extended from [false, true] is valid",
299+
"data": [false, true, "foo", "foo"],
300+
"valid": true
301+
},
302+
{
303+
"description": "non-unique array extended from [true, false] is valid",
304+
"data": [true, false, "foo", "foo"],
305+
"valid": true
306+
}
307+
]
308+
},
309+
{
310+
"description": "uniqueItems=false with an array of items and additionalItems=false",
311+
"schema": {
312+
"items": [{"type": "boolean"}, {"type": "boolean"}],
313+
"uniqueItems": false,
314+
"additionalItems": false
315+
},
316+
"tests": [
317+
{
318+
"description": "[false, true] from items array is valid",
319+
"data": [false, true],
320+
"valid": true
321+
},
322+
{
323+
"description": "[true, false] from items array is valid",
324+
"data": [true, false],
325+
"valid": true
326+
},
327+
{
328+
"description": "[false, false] from items array is valid",
329+
"data": [false, false],
330+
"valid": true
331+
},
332+
{
333+
"description": "[true, true] from items array is valid",
334+
"data": [true, true],
335+
"valid": true
336+
},
337+
{
338+
"description": "extra items are invalid even if unique",
339+
"data": [false, true, null],
340+
"valid": false
341+
}
342+
]
172343
}
173344
]

tests/draft3/enum.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@
3636
}
3737
]
3838
},
39+
{
40+
"description": "heterogeneous enum-with-null validation",
41+
"schema": { "enum": [6, null] },
42+
"tests": [
43+
{
44+
"description": "null is valid",
45+
"data": null,
46+
"valid": true
47+
},
48+
{
49+
"description": "number is valid",
50+
"data": 6,
51+
"valid": true
52+
},
53+
{
54+
"description": "something else is invalid",
55+
"data": "test",
56+
"valid": false
57+
}
58+
]
59+
},
3960
{
4061
"description": "enums in properties",
4162
"schema": {

0 commit comments

Comments
 (0)