Skip to content

Commit 1079aeb

Browse files
committed
Squashed 'json/' changes from 86f965e..cb2b906
cb2b906 Merge pull request #219 from mohawk2/fix-typo 99452e4 fix typo b242817 Merge pull request #213 from davishmcclurg/ipv6-iri-format 2146b02 Fix invalid IPv6 IRI 71843cb Merge pull request #211 from deBhal/add-complex-selection-tests f415a88 Duplicate complex tests for anyOf,oneOf into draft6 and draft7 7c518b4 add complex types test for oneOf, anyOf efb704f Merge pull request #212 from json-schema-org/update-ajv a8f9f82 fix: ajv test to use id/$id correctly git-subtree-dir: json git-subtree-split: cb2b9069653ea2d0e90bc02ee084b08489a87dfd
1 parent 6f29c6b commit 1079aeb

File tree

11 files changed

+259
-7
lines changed

11 files changed

+259
-7
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: python
22
python: "2.7"
3-
node_js: "6"
3+
node_js: "9"
44
install:
55
- pip install tox
66
- npm install

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const SKIP = {
2727
if (draft == 7) {
2828
ajv = new Ajv({format: 'full'});
2929
} else {
30-
ajv = new Ajv({format: 'full', meta: false});
30+
const schemaId = draft == 4 ? 'id' : '$id';
31+
ajv = new Ajv({format: 'full', meta: false, schemaId});
3132
ajv.addMetaSchema(require(`ajv/lib/refs/json-schema-draft-0${draft}.json`));
3233
ajv._opts.defaultMeta = `http://json-schema.org/draft-0${draft}/schema#`;
3334
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme",
2323
"devDependencies": {
24-
"ajv": "^6.0.0-rc.0",
24+
"ajv": "^6.0.0-rc.1",
2525
"json-schema-test": "^2.0.0",
2626
"mocha": "^3.2.0"
2727
}

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
]

tests/draft6/anyOf.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,46 @@
9797
"valid": false
9898
}
9999
]
100+
},
101+
{
102+
"description": "anyOf complex types",
103+
"schema": {
104+
"anyOf": [
105+
{
106+
"properties": {
107+
"bar": {"type": "integer"}
108+
},
109+
"required": ["bar"]
110+
},
111+
{
112+
"properties": {
113+
"foo": {"type": "string"}
114+
},
115+
"required": ["foo"]
116+
}
117+
]
118+
},
119+
"tests": [
120+
{
121+
"description": "first anyOf valid (complex)",
122+
"data": {"bar": 2},
123+
"valid": true
124+
},
125+
{
126+
"description": "second anyOf valid (complex)",
127+
"data": {"foo": "baz"},
128+
"valid": true
129+
},
130+
{
131+
"description": "both anyOf valid (complex)",
132+
"data": {"foo": "baz", "bar": 2},
133+
"valid": true
134+
},
135+
{
136+
"description": "neither anyOf valid (complex)",
137+
"data": {"foo": 2, "bar": "quux"},
138+
"valid": false
139+
}
140+
]
100141
}
101142
]

tests/draft6/oneOf.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,46 @@
108108
"valid": false
109109
}
110110
]
111+
},
112+
{
113+
"description": "oneOf complex types",
114+
"schema": {
115+
"oneOf": [
116+
{
117+
"properties": {
118+
"bar": {"type": "integer"}
119+
},
120+
"required": ["bar"]
121+
},
122+
{
123+
"properties": {
124+
"foo": {"type": "string"}
125+
},
126+
"required": ["foo"]
127+
}
128+
]
129+
},
130+
"tests": [
131+
{
132+
"description": "first oneOf valid (complex)",
133+
"data": {"bar": 2},
134+
"valid": true
135+
},
136+
{
137+
"description": "second oneOf valid (complex)",
138+
"data": {"foo": "baz"},
139+
"valid": true
140+
},
141+
{
142+
"description": "both oneOf valid (complex)",
143+
"data": {"foo": "baz", "bar": 2},
144+
"valid": false
145+
},
146+
{
147+
"description": "neither oneOf valid (complex)",
148+
"data": {"foo": 2, "bar": "quux"},
149+
"valid": false
150+
}
151+
]
111152
}
112153
]

tests/draft7/anyOf.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,46 @@
9797
"valid": false
9898
}
9999
]
100+
},
101+
{
102+
"description": "anyOf complex types",
103+
"schema": {
104+
"anyOf": [
105+
{
106+
"properties": {
107+
"bar": {"type": "integer"}
108+
},
109+
"required": ["bar"]
110+
},
111+
{
112+
"properties": {
113+
"foo": {"type": "string"}
114+
},
115+
"required": ["foo"]
116+
}
117+
]
118+
},
119+
"tests": [
120+
{
121+
"description": "first anyOf valid (complex)",
122+
"data": {"bar": 2},
123+
"valid": true
124+
},
125+
{
126+
"description": "second anyOf valid (complex)",
127+
"data": {"foo": "baz"},
128+
"valid": true
129+
},
130+
{
131+
"description": "both anyOf valid (complex)",
132+
"data": {"foo": "baz", "bar": 2},
133+
"valid": true
134+
},
135+
{
136+
"description": "neither anyOf valid (complex)",
137+
"data": {"foo": 2, "bar": "quux"},
138+
"valid": false
139+
}
140+
]
100141
}
101142
]

tests/draft7/if-then-else.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"valid": true
1414
},
1515
{
16-
"description": "valid when invailid against lone if",
16+
"description": "valid when invalid against lone if",
1717
"data": "hello",
1818
"valid": true
1919
}
@@ -33,7 +33,7 @@
3333
"valid": true
3434
},
3535
{
36-
"description": "valid when invailid against lone then",
36+
"description": "valid when invalid against lone then",
3737
"data": "hello",
3838
"valid": true
3939
}
@@ -53,7 +53,7 @@
5353
"valid": true
5454
},
5555
{
56-
"description": "valid when invailid against lone else",
56+
"description": "valid when invalid against lone else",
5757
"data": "hello",
5858
"valid": true
5959
}

tests/draft7/oneOf.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,46 @@
108108
"valid": false
109109
}
110110
]
111+
},
112+
{
113+
"description": "oneOf complex types",
114+
"schema": {
115+
"oneOf": [
116+
{
117+
"properties": {
118+
"bar": {"type": "integer"}
119+
},
120+
"required": ["bar"]
121+
},
122+
{
123+
"properties": {
124+
"foo": {"type": "string"}
125+
},
126+
"required": ["foo"]
127+
}
128+
]
129+
},
130+
"tests": [
131+
{
132+
"description": "first oneOf valid (complex)",
133+
"data": {"bar": 2},
134+
"valid": true
135+
},
136+
{
137+
"description": "second oneOf valid (complex)",
138+
"data": {"foo": "baz"},
139+
"valid": true
140+
},
141+
{
142+
"description": "both oneOf valid (complex)",
143+
"data": {"foo": "baz", "bar": 2},
144+
"valid": false
145+
},
146+
{
147+
"description": "neither oneOf valid (complex)",
148+
"data": {"foo": 2, "bar": "quux"},
149+
"valid": false
150+
}
151+
]
111152
}
112153
]

tests/draft7/optional/format/iri.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@
2525
},
2626
{
2727
"description": "a valid IRI based on IPv6",
28-
"data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334",
28+
"data": "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
2929
"valid": true
3030
},
31+
{
32+
"description": "an invalid IRI based on IPv6",
33+
"data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334",
34+
"valid": false
35+
},
3136
{
3237
"description": "an invalid relative IRI Reference",
3338
"data": "/abc",

0 commit comments

Comments
 (0)