Skip to content

Commit 0cca7f2

Browse files
author
Julian de Bhal
committed
add complex types test for oneOf, anyOf
1 parent 86f965e commit 0cca7f2

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

tests/draft4/anyOf.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,46 @@
6464
"valid": false
6565
}
6666
]
67+
},
68+
{
69+
"description": "anyOf complex types",
70+
"schema": {
71+
"anyOf": [
72+
{
73+
"properties": {
74+
"bar": {"type": "integer"}
75+
},
76+
"required": ["bar"]
77+
},
78+
{
79+
"properties": {
80+
"foo": {"type": "string"}
81+
},
82+
"required": ["foo"]
83+
}
84+
]
85+
},
86+
"tests": [
87+
{
88+
"description": "first anyOf valid (complex)",
89+
"data": {"bar": 2},
90+
"valid": true
91+
},
92+
{
93+
"description": "second anyOf valid (complex)",
94+
"data": {"foo": "baz"},
95+
"valid": true
96+
},
97+
{
98+
"description": "both anyOf valid (complex)",
99+
"data": {"foo": "baz", "bar": 2},
100+
"valid": true
101+
},
102+
{
103+
"description": "neither anyOf valid (complex)",
104+
"data": {"foo": 2, "bar": "quux"},
105+
"valid": false
106+
}
107+
]
67108
}
68109
]

tests/draft4/oneOf.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,46 @@
6464
"valid": false
6565
}
6666
]
67+
},
68+
{
69+
"description": "oneOf complex types",
70+
"schema": {
71+
"oneOf": [
72+
{
73+
"properties": {
74+
"bar": {"type": "integer"}
75+
},
76+
"required": ["bar"]
77+
},
78+
{
79+
"properties": {
80+
"foo": {"type": "string"}
81+
},
82+
"required": ["foo"]
83+
}
84+
]
85+
},
86+
"tests": [
87+
{
88+
"description": "first oneOf valid (complex)",
89+
"data": {"bar": 2},
90+
"valid": true
91+
},
92+
{
93+
"description": "second oneOf valid (complex)",
94+
"data": {"foo": "baz"},
95+
"valid": true
96+
},
97+
{
98+
"description": "both oneOf valid (complex)",
99+
"data": {"foo": "baz", "bar": 2},
100+
"valid": false
101+
},
102+
{
103+
"description": "neither oneOf valid (complex)",
104+
"data": {"foo": 2, "bar": "quux"},
105+
"valid": false
106+
}
107+
]
67108
}
68109
]

0 commit comments

Comments
 (0)