Skip to content

Commit a6e836c

Browse files
authored
Merge pull request #2 from json-schema-org/master
Straight up copy Draft 7 tests to Draft 2019-06.
2 parents 366f15b + e68ff51 commit a6e836c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5062
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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": "items is schema, no additionalItems",
23+
"schema": {
24+
"items": {},
25+
"additionalItems": false
26+
},
27+
"tests": [
28+
{
29+
"description": "all items match schema",
30+
"data": [ 1, 2, 3, 4, 5 ],
31+
"valid": true
32+
}
33+
]
34+
},
35+
{
36+
"description": "array of items with no additionalItems",
37+
"schema": {
38+
"items": [{}, {}, {}],
39+
"additionalItems": false
40+
},
41+
"tests": [
42+
{
43+
"description": "fewer number of items present",
44+
"data": [ 1, 2 ],
45+
"valid": true
46+
},
47+
{
48+
"description": "equal number of items present",
49+
"data": [ 1, 2, 3 ],
50+
"valid": true
51+
},
52+
{
53+
"description": "additional items are not permitted",
54+
"data": [ 1, 2, 3, 4 ],
55+
"valid": false
56+
}
57+
]
58+
},
59+
{
60+
"description": "additionalItems as false without items",
61+
"schema": {"additionalItems": false},
62+
"tests": [
63+
{
64+
"description":
65+
"items defaults to empty schema so everything is valid",
66+
"data": [ 1, 2, 3, 4, 5 ],
67+
"valid": true
68+
},
69+
{
70+
"description": "ignores non-arrays",
71+
"data": {"foo" : "bar"},
72+
"valid": true
73+
}
74+
]
75+
},
76+
{
77+
"description": "additionalItems are allowed by default",
78+
"schema": {"items": [{"type": "integer"}]},
79+
"tests": [
80+
{
81+
"description": "only the first item is validated",
82+
"data": [1, "foo", false],
83+
"valid": true
84+
}
85+
]
86+
}
87+
]
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
[
2+
{
3+
"description":
4+
"additionalProperties being false does not allow other properties",
5+
"schema": {
6+
"properties": {"foo": {}, "bar": {}},
7+
"patternProperties": { "^v": {} },
8+
"additionalProperties": false
9+
},
10+
"tests": [
11+
{
12+
"description": "no additional properties is valid",
13+
"data": {"foo": 1},
14+
"valid": true
15+
},
16+
{
17+
"description": "an additional property is invalid",
18+
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
19+
"valid": false
20+
},
21+
{
22+
"description": "ignores arrays",
23+
"data": [1, 2, 3],
24+
"valid": true
25+
},
26+
{
27+
"description": "ignores strings",
28+
"data": "foobarbaz",
29+
"valid": true
30+
},
31+
{
32+
"description": "ignores other non-objects",
33+
"data": 12,
34+
"valid": true
35+
},
36+
{
37+
"description": "patternProperties are not additional properties",
38+
"data": {"foo":1, "vroom": 2},
39+
"valid": true
40+
}
41+
]
42+
},
43+
{
44+
"description": "non-ASCII pattern with additionalProperties",
45+
"schema": {
46+
"patternProperties": {"^á": {}},
47+
"additionalProperties": false
48+
},
49+
"tests": [
50+
{
51+
"description": "matching the pattern is valid",
52+
"data": {"ármányos": 2},
53+
"valid": true
54+
},
55+
{
56+
"description": "not matching the pattern is invalid",
57+
"data": {"élmény": 2},
58+
"valid": false
59+
}
60+
]
61+
},
62+
{
63+
"description":
64+
"additionalProperties allows a schema which should validate",
65+
"schema": {
66+
"properties": {"foo": {}, "bar": {}},
67+
"additionalProperties": {"type": "boolean"}
68+
},
69+
"tests": [
70+
{
71+
"description": "no additional properties is valid",
72+
"data": {"foo": 1},
73+
"valid": true
74+
},
75+
{
76+
"description": "an additional valid property is valid",
77+
"data": {"foo" : 1, "bar" : 2, "quux" : true},
78+
"valid": true
79+
},
80+
{
81+
"description": "an additional invalid property is invalid",
82+
"data": {"foo" : 1, "bar" : 2, "quux" : 12},
83+
"valid": false
84+
}
85+
]
86+
},
87+
{
88+
"description":
89+
"additionalProperties can exist by itself",
90+
"schema": {
91+
"additionalProperties": {"type": "boolean"}
92+
},
93+
"tests": [
94+
{
95+
"description": "an additional valid property is valid",
96+
"data": {"foo" : true},
97+
"valid": true
98+
},
99+
{
100+
"description": "an additional invalid property is invalid",
101+
"data": {"foo" : 1},
102+
"valid": false
103+
}
104+
]
105+
},
106+
{
107+
"description": "additionalProperties are allowed by default",
108+
"schema": {"properties": {"foo": {}, "bar": {}}},
109+
"tests": [
110+
{
111+
"description": "additional properties are allowed",
112+
"data": {"foo": 1, "bar": 2, "quux": true},
113+
"valid": true
114+
}
115+
]
116+
},
117+
{
118+
"description": "additionalProperties should not look in applicators",
119+
"schema": {
120+
"allOf": [
121+
{"properties": {"foo": {}}}
122+
],
123+
"additionalProperties": {"type": "boolean"}
124+
},
125+
"tests": [
126+
{
127+
"description": "properties defined in allOf are not allowed",
128+
"data": {"foo": 1, "bar": true},
129+
"valid": false
130+
}
131+
]
132+
}
133+
]

0 commit comments

Comments
 (0)