Skip to content

Commit a1ade0a

Browse files
committed
Squashed 'json/' changes from 8982b0b..3c3881a
3c3881a Merge pull request #257 from epoberezkin/epoberezkin/keyword-tests 53fe9c7 type: additional tests 4193ca8 oneOf with empty schema and with required fe94275 nested items 14a2922 dependencies with empty array cee698e anyOf with empty schema 648fa65 allOf with empty schemas git-subtree-dir: json git-subtree-split: 3c3881a8cf4b287744bc22345e6fac692512663b
1 parent d2eb79f commit a1ade0a

17 files changed

+1205
-6
lines changed

tests/draft4/allOf.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,78 @@
108108
"valid": false
109109
}
110110
]
111+
},
112+
{
113+
"description": "allOf with one empty schema",
114+
"schema": {
115+
"allOf": [
116+
{}
117+
]
118+
},
119+
"tests": [
120+
{
121+
"description": "any data is valid",
122+
"data": 1,
123+
"valid": true
124+
}
125+
]
126+
},
127+
{
128+
"description": "allOf with two empty schemas",
129+
"schema": {
130+
"allOf": [
131+
{},
132+
{}
133+
]
134+
},
135+
"tests": [
136+
{
137+
"description": "any data is valid",
138+
"data": 1,
139+
"valid": true
140+
}
141+
]
142+
},
143+
{
144+
"description": "allOf with the first empty schema",
145+
"schema": {
146+
"allOf": [
147+
{},
148+
{ "type": "number" }
149+
]
150+
},
151+
"tests": [
152+
{
153+
"description": "number is valid",
154+
"data": 1,
155+
"valid": true
156+
},
157+
{
158+
"description": "string is invalid",
159+
"data": "foo",
160+
"valid": false
161+
}
162+
]
163+
},
164+
{
165+
"description": "allOf with the last empty schema",
166+
"schema": {
167+
"allOf": [
168+
{ "type": "number" },
169+
{}
170+
]
171+
},
172+
"tests": [
173+
{
174+
"description": "number is valid",
175+
"data": 1,
176+
"valid": true
177+
},
178+
{
179+
"description": "string is invalid",
180+
"data": "foo",
181+
"valid": false
182+
}
183+
]
111184
}
112185
]

tests/draft4/anyOf.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,26 @@
105105
"valid": false
106106
}
107107
]
108+
},
109+
{
110+
"description": "anyOf with one empty schema",
111+
"schema": {
112+
"anyOf": [
113+
{ "type": "number" },
114+
{}
115+
]
116+
},
117+
"tests": [
118+
{
119+
"description": "string is valid",
120+
"data": "foo",
121+
"valid": true
122+
},
123+
{
124+
"description": "number is valid",
125+
"data": 123,
126+
"valid": true
127+
}
128+
]
108129
}
109130
]

tests/draft4/items.json

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,122 @@
7474
"valid": true
7575
}
7676
]
77+
},
78+
{
79+
"description": "items and subitems",
80+
"schema": {
81+
"definitions": {
82+
"item": {
83+
"type": "array",
84+
"additionalItems": false,
85+
"items": [
86+
{ "$ref": "#/definitions/sub-item" },
87+
{ "$ref": "#/definitions/sub-item" }
88+
]
89+
},
90+
"sub-item": {
91+
"type": "object",
92+
"required": ["foo"]
93+
}
94+
},
95+
"type": "array",
96+
"additionalItems": false,
97+
"items": [
98+
{ "$ref": "#/definitions/item" },
99+
{ "$ref": "#/definitions/item" },
100+
{ "$ref": "#/definitions/item" }
101+
]
102+
},
103+
"tests": [
104+
{
105+
"description": "valid items",
106+
"data": [
107+
[ {"foo": null}, {"foo": null} ],
108+
[ {"foo": null}, {"foo": null} ],
109+
[ {"foo": null}, {"foo": null} ]
110+
],
111+
"valid": true
112+
},
113+
{
114+
"description": "too many items",
115+
"data": [
116+
[ {"foo": null}, {"foo": null} ],
117+
[ {"foo": null}, {"foo": null} ],
118+
[ {"foo": null}, {"foo": null} ],
119+
[ {"foo": null}, {"foo": null} ]
120+
],
121+
"valid": false
122+
},
123+
{
124+
"description": "too many sub-items",
125+
"data": [
126+
[ {"foo": null}, {"foo": null}, {"foo": null} ],
127+
[ {"foo": null}, {"foo": null} ],
128+
[ {"foo": null}, {"foo": null} ]
129+
],
130+
"valid": false
131+
},
132+
{
133+
"description": "wrong item",
134+
"data": [
135+
{"foo": null},
136+
[ {"foo": null}, {"foo": null} ],
137+
[ {"foo": null}, {"foo": null} ]
138+
],
139+
"valid": false
140+
},
141+
{
142+
"description": "wrong sub-item",
143+
"data": [
144+
[ {}, {"foo": null} ],
145+
[ {"foo": null}, {"foo": null} ],
146+
[ {"foo": null}, {"foo": null} ]
147+
],
148+
"valid": false
149+
},
150+
{
151+
"description": "fewer items is valid",
152+
"data": [
153+
[ {"foo": null} ],
154+
[ {"foo": null} ]
155+
],
156+
"valid": true
157+
}
158+
]
159+
},
160+
{
161+
"description": "nested items",
162+
"schema": {
163+
"type": "array",
164+
"items": {
165+
"type": "array",
166+
"items": {
167+
"type": "array",
168+
"items": {
169+
"type": "array",
170+
"items": {
171+
"type": "number"
172+
}
173+
}
174+
}
175+
}
176+
},
177+
"tests": [
178+
{
179+
"description": "valid nested array",
180+
"data": [[[[1]], [[2],[3]]], [[[4], [5], [6]]]],
181+
"valid": true
182+
},
183+
{
184+
"description": "nested array with invalid type",
185+
"data": [[[["1"]], [[2],[3]]], [[[4], [5], [6]]]],
186+
"valid": false
187+
},
188+
{
189+
"description": "not deep enough",
190+
"data": [[[1], [2],[3]], [[4], [5], [6]]],
191+
"valid": false
192+
}
193+
]
77194
}
78195
]

tests/draft4/oneOf.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,58 @@
105105
"valid": false
106106
}
107107
]
108+
},
109+
{
110+
"description": "oneOf with empty schema",
111+
"schema": {
112+
"oneOf": [
113+
{ "type": "number" },
114+
{}
115+
]
116+
},
117+
"tests": [
118+
{
119+
"description": "one valid - valid",
120+
"data": "foo",
121+
"valid": true
122+
},
123+
{
124+
"description": "both valid - invalid",
125+
"data": 123,
126+
"valid": false
127+
}
128+
]
129+
},
130+
{
131+
"description": "oneOf with required",
132+
"schema": {
133+
"type": "object",
134+
"oneOf": [
135+
{ "required": ["foo", "bar"] },
136+
{ "required": ["foo", "baz"] }
137+
]
138+
},
139+
"tests": [
140+
{
141+
"description": "both invalid - invalid",
142+
"data": {"bar": 2},
143+
"valid": false
144+
},
145+
{
146+
"description": "first valid - valid",
147+
"data": {"foo": 1, "bar": 2},
148+
"valid": true
149+
},
150+
{
151+
"description": "second valid - valid",
152+
"data": {"foo": 1, "baz": 3},
153+
"valid": true
154+
},
155+
{
156+
"description": "both valid - invalid",
157+
"data": {"foo": 1, "bar": 2, "baz" : 3},
158+
"valid": false
159+
}
160+
]
108161
}
109162
]

0 commit comments

Comments
 (0)