Skip to content

Commit ec9f933

Browse files
author
Matti Hansson
committed
Aligned tests with JSON-Schema-Test-Suite.
1 parent a6c35aa commit ec9f933

File tree

3 files changed

+129
-6
lines changed

3 files changed

+129
-6
lines changed

src/test/resources/draft2019-09/oneOf.json

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@
115115
"oneOf": [
116116
{
117117
"properties": {
118-
"bar": {"type": "integer"},
119-
"baz": {"type": "integer"}
118+
"bar": {"type": "integer"}
120119
},
121120
"required": ["bar"]
122121
},
@@ -203,5 +202,47 @@
203202
"valid": false
204203
}
205204
]
205+
},
206+
{
207+
"description": "oneOf with missing optional property",
208+
"schema": {
209+
"oneOf": [
210+
{
211+
"properties": {
212+
"bar": true,
213+
"baz": true
214+
},
215+
"required": ["bar"]
216+
},
217+
{
218+
"properties": {
219+
"foo": true
220+
},
221+
"required": ["foo"]
222+
}
223+
]
224+
},
225+
"tests": [
226+
{
227+
"description": "first oneOf valid",
228+
"data": {"bar": 8},
229+
"valid": true
230+
},
231+
{
232+
"description": "second oneOf valid",
233+
"data": {"foo": "foo"},
234+
"valid": true
235+
},
236+
{
237+
"description": "both oneOf valid",
238+
"data": {"foo": "foo", "bar": 8},
239+
"valid": false
240+
},
241+
{
242+
"description": "neither oneOf valid",
243+
"data": {"baz": "quux"},
244+
"valid": false
245+
}
246+
]
206247
}
207248
]

src/test/resources/draft6/oneOf.json

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@
115115
"oneOf": [
116116
{
117117
"properties": {
118-
"bar": {"type": "integer"},
119-
"baz": {"type": "integer"}
118+
"bar": {"type": "integer"}
120119
},
121120
"required": ["bar"]
122121
},
@@ -203,5 +202,47 @@
203202
"valid": false
204203
}
205204
]
205+
},
206+
{
207+
"description": "oneOf with missing optional property",
208+
"schema": {
209+
"oneOf": [
210+
{
211+
"properties": {
212+
"bar": true,
213+
"baz": true
214+
},
215+
"required": ["bar"]
216+
},
217+
{
218+
"properties": {
219+
"foo": true
220+
},
221+
"required": ["foo"]
222+
}
223+
]
224+
},
225+
"tests": [
226+
{
227+
"description": "first oneOf valid",
228+
"data": {"bar": 8},
229+
"valid": true
230+
},
231+
{
232+
"description": "second oneOf valid",
233+
"data": {"foo": "foo"},
234+
"valid": true
235+
},
236+
{
237+
"description": "both oneOf valid",
238+
"data": {"foo": "foo", "bar": 8},
239+
"valid": false
240+
},
241+
{
242+
"description": "neither oneOf valid",
243+
"data": {"baz": "quux"},
244+
"valid": false
245+
}
246+
]
206247
}
207248
]

src/test/resources/draft7/oneOf.json

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@
115115
"oneOf": [
116116
{
117117
"properties": {
118-
"bar": {"type": "integer"},
119-
"baz": {"type": "integer"}
118+
"bar": {"type": "integer"}
120119
},
121120
"required": ["bar"]
122121
},
@@ -203,5 +202,47 @@
203202
"valid": false
204203
}
205204
]
205+
},
206+
{
207+
"description": "oneOf with missing optional property",
208+
"schema": {
209+
"oneOf": [
210+
{
211+
"properties": {
212+
"bar": true,
213+
"baz": true
214+
},
215+
"required": ["bar"]
216+
},
217+
{
218+
"properties": {
219+
"foo": true
220+
},
221+
"required": ["foo"]
222+
}
223+
]
224+
},
225+
"tests": [
226+
{
227+
"description": "first oneOf valid",
228+
"data": {"bar": 8},
229+
"valid": true
230+
},
231+
{
232+
"description": "second oneOf valid",
233+
"data": {"foo": "foo"},
234+
"valid": true
235+
},
236+
{
237+
"description": "both oneOf valid",
238+
"data": {"foo": "foo", "bar": 8},
239+
"valid": false
240+
},
241+
{
242+
"description": "neither oneOf valid",
243+
"data": {"baz": "quux"},
244+
"valid": false
245+
}
246+
]
206247
}
207248
]

0 commit comments

Comments
 (0)