summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2018-04-10 15:24:59 -0400
committerJulian Berman <Julian@GrayVines.com>2018-04-10 15:24:59 -0400
commit27eafe851370f3fc81453de518dace67ca313293 (patch)
treee647216078b277eaab9c7ebf1289f9aadea5627c
parent9b7776ffca7ccc1d3abcacc63ebff24cc0796a9a (diff)
parent1079aeb60d28e058ef50b8eefb06b08f53a5438c (diff)
downloadjsonschema-27eafe851370f3fc81453de518dace67ca313293.tar.gz
Merge commit '1079aeb60d28e058ef50b8eefb06b08f53a5438c'
* commit '1079aeb60d28e058ef50b8eefb06b08f53a5438c': Squashed 'json/' changes from 86f965e..cb2b906
-rw-r--r--json/.travis.yml2
-rw-r--r--json/index.js3
-rw-r--r--json/package.json2
-rw-r--r--json/tests/draft4/anyOf.json41
-rw-r--r--json/tests/draft4/oneOf.json41
-rw-r--r--json/tests/draft6/anyOf.json41
-rw-r--r--json/tests/draft6/oneOf.json41
-rw-r--r--json/tests/draft7/anyOf.json41
-rw-r--r--json/tests/draft7/if-then-else.json6
-rw-r--r--json/tests/draft7/oneOf.json41
-rw-r--r--json/tests/draft7/optional/format/iri.json7
11 files changed, 259 insertions, 7 deletions
diff --git a/json/.travis.yml b/json/.travis.yml
index 0cd82ed..9c50823 100644
--- a/json/.travis.yml
+++ b/json/.travis.yml
@@ -1,6 +1,6 @@
language: python
python: "2.7"
-node_js: "6"
+node_js: "9"
install:
- pip install tox
- npm install
diff --git a/json/index.js b/json/index.js
index f164d0b..c44aa02 100644
--- a/json/index.js
+++ b/json/index.js
@@ -27,7 +27,8 @@ const SKIP = {
if (draft == 7) {
ajv = new Ajv({format: 'full'});
} else {
- ajv = new Ajv({format: 'full', meta: false});
+ const schemaId = draft == 4 ? 'id' : '$id';
+ ajv = new Ajv({format: 'full', meta: false, schemaId});
ajv.addMetaSchema(require(`ajv/lib/refs/json-schema-draft-0${draft}.json`));
ajv._opts.defaultMeta = `http://json-schema.org/draft-0${draft}/schema#`;
}
diff --git a/json/package.json b/json/package.json
index 387a5db..3980136 100644
--- a/json/package.json
+++ b/json/package.json
@@ -21,7 +21,7 @@
},
"homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme",
"devDependencies": {
- "ajv": "^6.0.0-rc.0",
+ "ajv": "^6.0.0-rc.1",
"json-schema-test": "^2.0.0",
"mocha": "^3.2.0"
}
diff --git a/json/tests/draft4/anyOf.json b/json/tests/draft4/anyOf.json
index a58714a..6c8b251 100644
--- a/json/tests/draft4/anyOf.json
+++ b/json/tests/draft4/anyOf.json
@@ -64,5 +64,46 @@
"valid": false
}
]
+ },
+ {
+ "description": "anyOf complex types",
+ "schema": {
+ "anyOf": [
+ {
+ "properties": {
+ "bar": {"type": "integer"}
+ },
+ "required": ["bar"]
+ },
+ {
+ "properties": {
+ "foo": {"type": "string"}
+ },
+ "required": ["foo"]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "first anyOf valid (complex)",
+ "data": {"bar": 2},
+ "valid": true
+ },
+ {
+ "description": "second anyOf valid (complex)",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "both anyOf valid (complex)",
+ "data": {"foo": "baz", "bar": 2},
+ "valid": true
+ },
+ {
+ "description": "neither anyOf valid (complex)",
+ "data": {"foo": 2, "bar": "quux"},
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/oneOf.json b/json/tests/draft4/oneOf.json
index 1eaa4e4..3a03ded 100644
--- a/json/tests/draft4/oneOf.json
+++ b/json/tests/draft4/oneOf.json
@@ -64,5 +64,46 @@
"valid": false
}
]
+ },
+ {
+ "description": "oneOf complex types",
+ "schema": {
+ "oneOf": [
+ {
+ "properties": {
+ "bar": {"type": "integer"}
+ },
+ "required": ["bar"]
+ },
+ {
+ "properties": {
+ "foo": {"type": "string"}
+ },
+ "required": ["foo"]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "first oneOf valid (complex)",
+ "data": {"bar": 2},
+ "valid": true
+ },
+ {
+ "description": "second oneOf valid (complex)",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "both oneOf valid (complex)",
+ "data": {"foo": "baz", "bar": 2},
+ "valid": false
+ },
+ {
+ "description": "neither oneOf valid (complex)",
+ "data": {"foo": 2, "bar": "quux"},
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/anyOf.json b/json/tests/draft6/anyOf.json
index 1ea31ed..4d05a9e 100644
--- a/json/tests/draft6/anyOf.json
+++ b/json/tests/draft6/anyOf.json
@@ -97,5 +97,46 @@
"valid": false
}
]
+ },
+ {
+ "description": "anyOf complex types",
+ "schema": {
+ "anyOf": [
+ {
+ "properties": {
+ "bar": {"type": "integer"}
+ },
+ "required": ["bar"]
+ },
+ {
+ "properties": {
+ "foo": {"type": "string"}
+ },
+ "required": ["foo"]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "first anyOf valid (complex)",
+ "data": {"bar": 2},
+ "valid": true
+ },
+ {
+ "description": "second anyOf valid (complex)",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "both anyOf valid (complex)",
+ "data": {"foo": "baz", "bar": 2},
+ "valid": true
+ },
+ {
+ "description": "neither anyOf valid (complex)",
+ "data": {"foo": 2, "bar": "quux"},
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/oneOf.json b/json/tests/draft6/oneOf.json
index df07e0b..bc4295c 100644
--- a/json/tests/draft6/oneOf.json
+++ b/json/tests/draft6/oneOf.json
@@ -108,5 +108,46 @@
"valid": false
}
]
+ },
+ {
+ "description": "oneOf complex types",
+ "schema": {
+ "oneOf": [
+ {
+ "properties": {
+ "bar": {"type": "integer"}
+ },
+ "required": ["bar"]
+ },
+ {
+ "properties": {
+ "foo": {"type": "string"}
+ },
+ "required": ["foo"]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "first oneOf valid (complex)",
+ "data": {"bar": 2},
+ "valid": true
+ },
+ {
+ "description": "second oneOf valid (complex)",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "both oneOf valid (complex)",
+ "data": {"foo": "baz", "bar": 2},
+ "valid": false
+ },
+ {
+ "description": "neither oneOf valid (complex)",
+ "data": {"foo": 2, "bar": "quux"},
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/anyOf.json b/json/tests/draft7/anyOf.json
index 1ea31ed..4d05a9e 100644
--- a/json/tests/draft7/anyOf.json
+++ b/json/tests/draft7/anyOf.json
@@ -97,5 +97,46 @@
"valid": false
}
]
+ },
+ {
+ "description": "anyOf complex types",
+ "schema": {
+ "anyOf": [
+ {
+ "properties": {
+ "bar": {"type": "integer"}
+ },
+ "required": ["bar"]
+ },
+ {
+ "properties": {
+ "foo": {"type": "string"}
+ },
+ "required": ["foo"]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "first anyOf valid (complex)",
+ "data": {"bar": 2},
+ "valid": true
+ },
+ {
+ "description": "second anyOf valid (complex)",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "both anyOf valid (complex)",
+ "data": {"foo": "baz", "bar": 2},
+ "valid": true
+ },
+ {
+ "description": "neither anyOf valid (complex)",
+ "data": {"foo": 2, "bar": "quux"},
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/if-then-else.json b/json/tests/draft7/if-then-else.json
index 18bd1f7..37a229c 100644
--- a/json/tests/draft7/if-then-else.json
+++ b/json/tests/draft7/if-then-else.json
@@ -13,7 +13,7 @@
"valid": true
},
{
- "description": "valid when invailid against lone if",
+ "description": "valid when invalid against lone if",
"data": "hello",
"valid": true
}
@@ -33,7 +33,7 @@
"valid": true
},
{
- "description": "valid when invailid against lone then",
+ "description": "valid when invalid against lone then",
"data": "hello",
"valid": true
}
@@ -53,7 +53,7 @@
"valid": true
},
{
- "description": "valid when invailid against lone else",
+ "description": "valid when invalid against lone else",
"data": "hello",
"valid": true
}
diff --git a/json/tests/draft7/oneOf.json b/json/tests/draft7/oneOf.json
index df07e0b..bc4295c 100644
--- a/json/tests/draft7/oneOf.json
+++ b/json/tests/draft7/oneOf.json
@@ -108,5 +108,46 @@
"valid": false
}
]
+ },
+ {
+ "description": "oneOf complex types",
+ "schema": {
+ "oneOf": [
+ {
+ "properties": {
+ "bar": {"type": "integer"}
+ },
+ "required": ["bar"]
+ },
+ {
+ "properties": {
+ "foo": {"type": "string"}
+ },
+ "required": ["foo"]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "first oneOf valid (complex)",
+ "data": {"bar": 2},
+ "valid": true
+ },
+ {
+ "description": "second oneOf valid (complex)",
+ "data": {"foo": "baz"},
+ "valid": true
+ },
+ {
+ "description": "both oneOf valid (complex)",
+ "data": {"foo": "baz", "bar": 2},
+ "valid": false
+ },
+ {
+ "description": "neither oneOf valid (complex)",
+ "data": {"foo": 2, "bar": "quux"},
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/optional/format/iri.json b/json/tests/draft7/optional/format/iri.json
index f9c8715..ed54094 100644
--- a/json/tests/draft7/optional/format/iri.json
+++ b/json/tests/draft7/optional/format/iri.json
@@ -25,10 +25,15 @@
},
{
"description": "a valid IRI based on IPv6",
- "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334",
+ "data": "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]",
"valid": true
},
{
+ "description": "an invalid IRI based on IPv6",
+ "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334",
+ "valid": false
+ },
+ {
"description": "an invalid relative IRI Reference",
"data": "/abc",
"valid": false