summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2020-06-09 19:00:09 -0400
committerJulian Berman <Julian@GrayVines.com>2020-06-09 19:00:09 -0400
commit3f58e36754b3e2872a256874c1ffdd30c677f709 (patch)
tree157cf84b5880faee6fab531f6e90d36e326b99e7 /json
parent3b85db9769390b4dc713fbf09ab76a760e48fea3 (diff)
parent4a4930a09fa25251ad0f02395f3c6aa0fd7e3a82 (diff)
downloadjsonschema-3f58e36754b3e2872a256874c1ffdd30c677f709.tar.gz
Merge commit '4a4930a09fa25251ad0f02395f3c6aa0fd7e3a82'
* commit '4a4930a09fa25251ad0f02395f3c6aa0fd7e3a82': Squashed 'json/' changes from 9d0e0eb..817b724
Diffstat (limited to 'json')
-rw-r--r--json/README.md145
-rw-r--r--json/test-schema.json4
-rw-r--r--json/tests/draft2019-09/additionalItems.json12
-rw-r--r--json/tests/draft2019-09/allOf.json50
-rw-r--r--json/tests/draft2019-09/anchor.json12
-rw-r--r--json/tests/draft2019-09/const.json16
-rw-r--r--json/tests/draft2019-09/contains.json34
-rw-r--r--json/tests/draft2019-09/enum.json16
-rw-r--r--json/tests/draft2019-09/id.json206
-rw-r--r--json/tests/draft2019-09/if-then-else.json40
-rw-r--r--json/tests/draft2019-09/maxContains.json79
-rw-r--r--json/tests/draft2019-09/maxProperties.json16
-rw-r--r--json/tests/draft2019-09/minContains.json172
-rw-r--r--json/tests/draft2019-09/optional/format/hostname.json35
-rw-r--r--json/tests/draft2019-09/optional/format/idn-hostname.json62
-rw-r--r--json/tests/draft2019-09/ref.json12
-rw-r--r--json/tests/draft2019-09/unevaluatedItems.json20
-rw-r--r--json/tests/draft2019-09/unevaluatedProperties.json24
-rw-r--r--json/tests/draft2019-09/uniqueItems.json32
-rw-r--r--json/tests/draft3/additionalItems.json21
-rw-r--r--json/tests/draft3/enum.json16
-rw-r--r--json/tests/draft3/optional/format.json227
-rw-r--r--json/tests/draft3/optional/format/color.json38
-rw-r--r--json/tests/draft3/optional/format/date-time.json28
-rw-r--r--json/tests/draft3/optional/format/date.json18
-rw-r--r--json/tests/draft3/optional/format/email.json18
-rw-r--r--json/tests/draft3/optional/format/host-name.json63
-rw-r--r--json/tests/draft3/optional/format/ip-address.json23
-rw-r--r--json/tests/draft3/optional/format/ipv6.json28
-rw-r--r--json/tests/draft3/optional/format/regex.json18
-rw-r--r--json/tests/draft3/optional/format/time.json18
-rw-r--r--json/tests/draft3/optional/format/uri.json28
-rw-r--r--json/tests/draft3/ref.json12
-rw-r--r--json/tests/draft3/uniqueItems.json20
-rw-r--r--json/tests/draft4/additionalItems.json12
-rw-r--r--json/tests/draft4/allOf.json50
-rw-r--r--json/tests/draft4/enum.json16
-rw-r--r--json/tests/draft4/maxProperties.json16
-rw-r--r--json/tests/draft4/optional/format.json253
-rw-r--r--json/tests/draft4/optional/format/date-time.json53
-rw-r--r--json/tests/draft4/optional/format/email.json18
-rw-r--r--json/tests/draft4/optional/format/hostname.json64
-rw-r--r--json/tests/draft4/optional/format/ipv4.json33
-rw-r--r--json/tests/draft4/optional/format/ipv6.json28
-rw-r--r--json/tests/draft4/optional/format/uri.json103
-rw-r--r--json/tests/draft4/ref.json12
-rw-r--r--json/tests/draft4/uniqueItems.json32
-rw-r--r--json/tests/draft6/additionalItems.json12
-rw-r--r--json/tests/draft6/allOf.json50
-rw-r--r--json/tests/draft6/const.json16
-rw-r--r--json/tests/draft6/contains.json29
-rw-r--r--json/tests/draft6/enum.json16
-rw-r--r--json/tests/draft6/maxProperties.json16
-rw-r--r--json/tests/draft6/optional/format.json491
-rw-r--r--json/tests/draft6/optional/format/date-time.json58
-rw-r--r--json/tests/draft6/optional/format/email.json18
-rw-r--r--json/tests/draft6/optional/format/hostname.json63
-rw-r--r--json/tests/draft6/optional/format/ipv4.json33
-rw-r--r--json/tests/draft6/optional/format/ipv6.json28
-rw-r--r--json/tests/draft6/optional/format/json-pointer.json168
-rw-r--r--json/tests/draft6/optional/format/uri-reference.json43
-rw-r--r--json/tests/draft6/optional/format/uri-template.json28
-rw-r--r--json/tests/draft6/optional/format/uri.json103
-rw-r--r--json/tests/draft6/ref.json12
-rw-r--r--json/tests/draft6/uniqueItems.json32
-rw-r--r--json/tests/draft7/additionalItems.json12
-rw-r--r--json/tests/draft7/allOf.json50
-rw-r--r--json/tests/draft7/const.json16
-rw-r--r--json/tests/draft7/contains.json29
-rw-r--r--json/tests/draft7/enum.json16
-rw-r--r--json/tests/draft7/if-then-else.json40
-rw-r--r--json/tests/draft7/maxProperties.json16
-rw-r--r--json/tests/draft7/optional/format/hostname.json35
-rw-r--r--json/tests/draft7/optional/format/idn-hostname.json60
-rw-r--r--json/tests/draft7/ref.json12
-rw-r--r--json/tests/draft7/uniqueItems.json32
76 files changed, 2698 insertions, 1089 deletions
diff --git a/json/README.md b/json/README.md
index 5c393d6..540ce60 100644
--- a/json/README.md
+++ b/json/README.md
@@ -1,5 +1,4 @@
-JSON Schema Test Suite [![Build Status](https://github.com/json-schema-org/JSON-Schema-Test-Suite/workflows/Test%20Suite%20Sanity%20Checking/badge.svg)](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
-======
+# JSON Schema Test Suite [![Build Status](https://github.com/json-schema-org/JSON-Schema-Test-Suite/workflows/Test%20Suite%20Sanity%20Checking/badge.svg)](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
This repository contains a set of JSON objects that implementors of JSON Schema
validation libraries can use to test their validators.
@@ -9,108 +8,118 @@ It is meant to be language agnostic and should require only a JSON parser.
The conversion of the JSON objects into tests within your test framework of
choice is still the job of the validator implementor.
-Structure of a Test
--------------------
+## Structure of a Test
-The tests in this suite are contained in the `tests` directory at the
-root of this repository.
+The tests in this suite are contained in the `tests` directory at the root of
+this repository. Inside that directory is a subdirectory for each draft or
+version of the specification.
-Inside that directory is a subdirectory for each draft or version of the
-specification.
+Inside each draft directory, there are a number of `.json` files and one or more
+special subdirectories. The subdirectories contain `.json` files meant for a
+specific testing purpose, and each `.json` file logically groups a set of test
+cases together. Often the grouping is by property under test, but not always.
-Inside each draft directory, there are a number of `.json` files, which
-logically group a set of test cases together. Often the grouping is by
-property under test, but not always, especially within optional test
-files (discussed below).
+The subdirectories are described in the next section.
Inside each `.json` file is a single array containing objects. It's easiest to
illustrate the structure of these with an example:
```json
- {
- "description": "the description of the test case",
- "schema": {"the schema that should" : "be validated against"},
- "tests": [
- {
- "description": "a specific test of a valid instance",
- "data": "the instance",
- "valid": true
- },
- {
- "description": "another specific test this time, invalid",
- "data": 15,
- "valid": false
- }
- ]
- }
+{
+ "description": "The description of the test case",
+ "schema": {
+ "description": "The schema against which the data in each test is validated",
+ "type": "string"
+ },
+ "tests": [
+ {
+ "description": "Test for a valid instance",
+ "data": "the instance to validate",
+ "valid": true
+ },
+ {
+ "description": "Test for an invalid instance",
+ "data": 15,
+ "valid": false
+ }
+ ]
+}
```
-In short: a description, a schema under test, and some tests, where each
-test in the `tests` array is an objects with a description of the case
-itself, the instance under test, and a boolean indicating whether it
-should be valid or invalid.
+In short: a description, a schema under test, and some tests, where each test
+in the `tests` array is an objects with a description of the case itself, the
+instance under test, and a boolean indicating whether it should be valid
+or invalid.
-Coverage
---------
+## Test Subdirectories
-Drafts 07, 06, 04 and 03 should have full coverage, with drafts 06 and
-07 being considered current and actively supported.
+There is currently only one subdirectory that may exist within each draft
+directory. This is:
-Draft 2019-09 support is under development. Contributions are very
-welcome, especially from implementers as they add support to their own
-implementations.
+1. `optional/`: Contains tests that are considered optional.
-If you see anything missing from the current supported drafts, or incorrect
-on any draft still accepting bug fixes, please file an issue or submit a PR.
+## Coverage
-Who Uses the Test Suite
------------------------
+Drafts 07, 06, 04, and 03 should have full coverage, with tests for drafts 06,
+07, and 2019-09 being considered current and actively supported. Draft 2019-09
+is almost fully covered.
+
+Contributions are very welcome, especially from implementers as they add support
+to their own implementations.
+
+If you see anything missing from the current supported drafts, or incorrect on
+any draft still accepting bug fixes, please
+[file an issue](https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues)
+or [submit a PR](https://github.com/json-schema-org/JSON-Schema-Test-Suite).
+
+## Who Uses the Test Suite
This suite is being used by:
-### Clojure ###
+### Clojure
* [jinx](https://github.com/juxt/jinx)
* [json-schema](https://github.com/tatut/json-schema)
-### Coffeescript ###
+### Coffeescript
* [jsck](https://github.com/pandastrike/jsck)
-### C++ ###
+### C++
* [Modern C++ JSON schema validator](https://github.com/pboettch/json-schema-validator)
-### Dart ###
+### Dart
* [json_schema](https://github.com/patefacio/json_schema)
-### Elixir ###
+### Elixir
* [ex_json_schema](https://github.com/jonasschmidt/ex_json_schema)
-### Erlang ###
+### Erlang
* [jesse](https://github.com/for-GET/jesse)
-### Go ###
+### Go
* [gojsonschema](https://github.com/sigu-399/gojsonschema)
* [validate-json](https://github.com/cesanta/validate-json)
-### Haskell ###
+### Haskell
* [aeson-schema](https://github.com/timjb/aeson-schema)
* [hjsonschema](https://github.com/seagreen/hjsonschema)
-### Java ###
+### Java
* [json-schema-validator](https://github.com/daveclayton/json-schema-validator)
* [everit-org/json-schema](https://github.com/everit-org/json-schema)
* [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator)
* [Justify](https://github.com/leadpony/justify)
+* [Snow](https://github.com/ssilverman/snowy-json)
-### JavaScript ###
+### JavaScript
* [json-schema-benchmark](https://github.com/Muscula/json-schema-benchmark)
* [direct-schema](https://github.com/IreneKnapp/direct-schema)
@@ -128,7 +137,7 @@ This suite is being used by:
* [ajv](https://github.com/epoberezkin/ajv)
* [djv](https://github.com/korzio/djv)
-### Node.js ###
+### Node.js
For node.js developers, the suite is also available as an
[npm](https://www.npmjs.com/package/@json-schema-org/tests) package.
@@ -137,49 +146,53 @@ Node-specific support is maintained in a [separate
repository](https://github.com/json-schema-org/json-schema-test-suite-npm)
which also welcomes your contributions!
-### .NET ###
+### .NET
* [Newtonsoft.Json.Schema](https://github.com/JamesNK/Newtonsoft.Json.Schema)
* [Manatee.Json](https://github.com/gregsdennis/Manatee.Json)
-### PHP ###
+### Perl
+
+* [JSON::Schema::Draft201909](https://github.com/karenetheridge/JSON-Schema-Draft201909)
+* [Test::JSON::Schema::Acceptance](https://github.com/karenetheridge/Test-JSON-Schema-Acceptance)
+
+### PHP
* [json-schema](https://github.com/justinrainbow/json-schema)
* [json-guard](https://github.com/thephpleague/json-guard)
-### PostgreSQL ###
+### PostgreSQL
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
* [is_jsonb_valid](https://github.com/furstenheim/is_jsonb_valid)
-### Python ###
+### Python
* [jsonschema](https://github.com/Julian/jsonschema)
* [fastjsonschema](https://github.com/seznam/python-fastjsonschema)
* [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema)
-### Ruby ###
+### Ruby
* [json-schema](https://github.com/hoxworth/json-schema)
* [json_schemer](https://github.com/davishmcclurg/json_schemer)
-### Rust ###
+### Rust
* [valico](https://github.com/rustless/valico)
-### Swift ###
+### Swift
* [JSONSchema](https://github.com/kylef/JSONSchema.swift)
If you use it as well, please fork and send a pull request adding yourself to
the list :).
-Contributing
-------------
+## Contributing
If you see something missing or incorrect, a pull request is most welcome!
-There are some sanity checks in place for testing the test suite. You
-can run them with `bin/jsonschema_suite check` or `tox`. They will be
-run automatically by [GitHub Actions](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
+There are some sanity checks in place for testing the test suite. You can run
+them with `bin/jsonschema_suite check` or `tox`. They will be run automatically
+by [GitHub Actions](https://github.com/json-schema-org/JSON-Schema-Test-Suite/actions?query=workflow%3A%22Test+Suite+Sanity+Checking%22)
as well.
diff --git a/json/test-schema.json b/json/test-schema.json
index 877d381..11b1e8d 100644
--- a/json/test-schema.json
+++ b/json/test-schema.json
@@ -71,7 +71,9 @@
"description": "Any additional comments about the test",
"type": "string"
},
- "data": {},
+ "data": {
+ "description": "This is the instance to be validated against the schema in \"schema\"."
+ },
"valid": { "type": "boolean" },
"output": {
"type": "object",
diff --git a/json/tests/draft2019-09/additionalItems.json b/json/tests/draft2019-09/additionalItems.json
index abecc57..69ea5e3 100644
--- a/json/tests/draft2019-09/additionalItems.json
+++ b/json/tests/draft2019-09/additionalItems.json
@@ -40,7 +40,17 @@
},
"tests": [
{
- "description": "fewer number of items present",
+ "description": "empty array",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (1)",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (2)",
"data": [ 1, 2 ],
"valid": true
},
diff --git a/json/tests/draft2019-09/allOf.json b/json/tests/draft2019-09/allOf.json
index cff8251..ec9319e 100644
--- a/json/tests/draft2019-09/allOf.json
+++ b/json/tests/draft2019-09/allOf.json
@@ -240,5 +240,55 @@
"valid": false
}
]
+ },
+ {
+ "description": "allOf combined with anyOf, oneOf",
+ "schema": {
+ "allOf": [ { "multipleOf": 2 } ],
+ "anyOf": [ { "multipleOf": 3 } ],
+ "oneOf": [ { "multipleOf": 5 } ]
+ },
+ "tests": [
+ {
+ "description": "allOf: false, anyOf: false, oneOf: false",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: false, oneOf: true",
+ "data": 5,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: false",
+ "data": 3,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: true",
+ "data": 15,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: false",
+ "data": 2,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: true",
+ "data": 10,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: false",
+ "data": 6,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: true",
+ "data": 30,
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/anchor.json b/json/tests/draft2019-09/anchor.json
index 06b0ba4..42dde7e 100644
--- a/json/tests/draft2019-09/anchor.json
+++ b/json/tests/draft2019-09/anchor.json
@@ -2,9 +2,7 @@
{
"description": "Location-independent identifier",
"schema": {
- "allOf": [{
- "$ref": "#foo"
- }],
+ "$ref": "#foo",
"$defs": {
"A": {
"$anchor": "foo",
@@ -28,9 +26,7 @@
{
"description": "Location-independent identifier with absolute URI",
"schema": {
- "allOf": [{
- "$ref": "http://localhost:1234/bar#foo"
- }],
+ "$ref": "http://localhost:1234/bar#foo",
"$defs": {
"A": {
"$id": "http://localhost:1234/bar",
@@ -56,9 +52,7 @@
"description": "Location-independent identifier with base URI change in subschema",
"schema": {
"$id": "http://localhost:1234/root",
- "allOf": [{
- "$ref": "http://localhost:1234/nested.json#foo"
- }],
+ "$ref": "http://localhost:1234/nested.json#foo",
"$defs": {
"A": {
"$id": "nested.json",
diff --git a/json/tests/draft2019-09/const.json b/json/tests/draft2019-09/const.json
index 1a55235..c53d04d 100644
--- a/json/tests/draft2019-09/const.json
+++ b/json/tests/draft2019-09/const.json
@@ -238,5 +238,21 @@
"valid": false
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "const": "hello\u0000there" },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/contains.json b/json/tests/draft2019-09/contains.json
index b7ae5a2..c5471cc 100644
--- a/json/tests/draft2019-09/contains.json
+++ b/json/tests/draft2019-09/contains.json
@@ -89,6 +89,40 @@
"description": "empty array is invalid",
"data": [],
"valid": false
+ },
+ {
+ "description": "non-arrays are valid",
+ "data": "contains does not apply to strings",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "items + contains",
+ "schema": {
+ "items": { "multipleOf": 2 },
+ "contains": { "multipleOf": 3 }
+ },
+ "tests": [
+ {
+ "description": "matches items, does not match contains",
+ "data": [ 2, 4, 8 ],
+ "valid": false
+ },
+ {
+ "description": "does not match items, matches contains",
+ "data": [ 3, 6, 9 ],
+ "valid": false
+ },
+ {
+ "description": "matches both items and contains",
+ "data": [ 6, 12 ],
+ "valid": true
+ },
+ {
+ "description": "matches neither items nor contains",
+ "data": [ 1, 5 ],
+ "valid": false
}
]
}
diff --git a/json/tests/draft2019-09/enum.json b/json/tests/draft2019-09/enum.json
index 0191b55..6844578 100644
--- a/json/tests/draft2019-09/enum.json
+++ b/json/tests/draft2019-09/enum.json
@@ -206,5 +206,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "enum": [ "hello\u0000there" ] },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/id.json b/json/tests/draft2019-09/id.json
new file mode 100644
index 0000000..cd97d59
--- /dev/null
+++ b/json/tests/draft2019-09/id.json
@@ -0,0 +1,206 @@
+[
+ {
+ "description": "Invalid use of fragments in location-independent $id",
+ "schema": {"$ref": "https://json-schema.org/draft/2019-09/schema"},
+ "tests": [
+ {
+ "description": "Identifier name",
+ "data": {
+ "$ref": "#foo",
+ "$defs": {
+ "A": {
+ "$id": "#foo",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier name and no ref",
+ "data": {
+ "$defs": {
+ "A": { "$id": "#foo" }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier path",
+ "data": {
+ "$ref": "#/a/b",
+ "$defs": {
+ "A": {
+ "$id": "#/a/b",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier name with absolute URI",
+ "data": {
+ "$ref": "http://localhost:1234/bar#foo",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/bar#foo",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier path with absolute URI",
+ "data": {
+ "$ref": "http://localhost:1234/bar#/a/b",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/bar#/a/b",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier name with base URI change in subschema",
+ "data": {
+ "$id": "http://localhost:1234/root",
+ "$ref": "http://localhost:1234/nested.json#foo",
+ "$defs": {
+ "A": {
+ "$id": "nested.json",
+ "$defs": {
+ "B": {
+ "$id": "#foo",
+ "type": "integer"
+ }
+ }
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier path with base URI change in subschema",
+ "data": {
+ "$id": "http://localhost:1234/root",
+ "$ref": "http://localhost:1234/nested.json#/a/b",
+ "$defs": {
+ "A": {
+ "$id": "nested.json",
+ "$defs": {
+ "B": {
+ "$id": "#/a/b",
+ "type": "integer"
+ }
+ }
+ }
+ }
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "Valid use of empty fragments in location-independent $id",
+ "comment": "These are allowed but discouraged",
+ "schema": {
+ "$ref": "https://json-schema.org/draft/2019-09/schema"
+ },
+ "tests": [
+ {
+ "description": "Identifier name with absolute URI",
+ "data": {
+ "$ref": "http://localhost:1234/bar",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/bar#",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Identifier name with base URI change in subschema",
+ "data": {
+ "$id": "http://localhost:1234/root",
+ "$ref": "http://localhost:1234/nested.json#/$defs/B",
+ "$defs": {
+ "A": {
+ "$id": "nested.json",
+ "$defs": {
+ "B": {
+ "$id": "#",
+ "type": "integer"
+ }
+ }
+ }
+ }
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "Unnormalized $ids are allowed but discouraged",
+ "schema": {
+ "$ref": "https://json-schema.org/draft/2019-09/schema"
+ },
+ "tests": [
+ {
+ "description": "Unnormalized identifier",
+ "data": {
+ "$ref": "http://localhost:1234/foo/baz",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/foo/bar/../baz",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Unnormalized identifier and no ref",
+ "data": {
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/foo/bar/../baz",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Unnormalized identifier with empty fragment",
+ "data": {
+ "$ref": "http://localhost:1234/foo/baz",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/foo/bar/../baz#",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Unnormalized identifier with empty fragment and no ref",
+ "data": {
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/foo/bar/../baz#",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft2019-09/if-then-else.json b/json/tests/draft2019-09/if-then-else.json
index be73281..e0b873e 100644
--- a/json/tests/draft2019-09/if-then-else.json
+++ b/json/tests/draft2019-09/if-then-else.json
@@ -184,5 +184,45 @@
"valid": true
}
]
+ },
+ {
+ "description": "if with boolean schema true",
+ "schema": {
+ "if": true,
+ "then": { "const": "then" },
+ "else": { "const": "else" }
+ },
+ "tests": [
+ {
+ "description": "boolean schema true in if always chooses the then path (valid)",
+ "data": "then",
+ "valid": true
+ },
+ {
+ "description": "boolean schema true in if always chooses the then path (invalid)",
+ "data": "else",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "if with boolean schema false",
+ "schema": {
+ "if": false,
+ "then": { "const": "then" },
+ "else": { "const": "else" }
+ },
+ "tests": [
+ {
+ "description": "boolean schema false in if always chooses the else path (invalid)",
+ "data": "then",
+ "valid": false
+ },
+ {
+ "description": "boolean schema false in if always chooses the else path (valid)",
+ "data": "else",
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/maxContains.json b/json/tests/draft2019-09/maxContains.json
new file mode 100644
index 0000000..3c42fb3
--- /dev/null
+++ b/json/tests/draft2019-09/maxContains.json
@@ -0,0 +1,79 @@
+[
+ {
+ "description": "maxContains without contains is ignored",
+ "schema": {
+ "maxContains": 1
+ },
+ "tests": [
+ {
+ "description": "one item valid against lone maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "two items still valid against lone maxContains",
+ "data": [ 1, 2 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "maxContains with contains",
+ "schema": {
+ "contains": {"const": 1},
+ "maxContains": 1
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, valid maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "all elements match, invalid maxContains",
+ "data": [ 1, 1 ],
+ "valid": false
+ },
+ {
+ "description": "some elements match, valid maxContains",
+ "data": [ 1, 2 ],
+ "valid": true
+ },
+ {
+ "description": "some elements match, invalid maxContains",
+ "data": [ 1, 2, 1 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "minContains < maxContains",
+ "schema": {
+ "contains": {"const": 1},
+ "minContains": 1,
+ "maxContains": 3
+ },
+ "tests": [
+ {
+ "description": "actual < minContains < maxContains",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "minContains < actual < maxContains",
+ "data": [ 1, 1 ],
+ "valid": true
+ },
+ {
+ "description": "minContains < maxContains < actual",
+ "data": [ 1, 1, 1, 1 ],
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft2019-09/maxProperties.json b/json/tests/draft2019-09/maxProperties.json
index 513731e..aa7209f 100644
--- a/json/tests/draft2019-09/maxProperties.json
+++ b/json/tests/draft2019-09/maxProperties.json
@@ -34,5 +34,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "maxProperties = 0 means the object is empty",
+ "schema": { "maxProperties": 0 },
+ "tests": [
+ {
+ "description": "no properties is valid",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "one property is invalid",
+ "data": { "foo": 1 },
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/minContains.json b/json/tests/draft2019-09/minContains.json
new file mode 100644
index 0000000..f359de0
--- /dev/null
+++ b/json/tests/draft2019-09/minContains.json
@@ -0,0 +1,172 @@
+[
+ {
+ "description": "minContains without contains is ignored",
+ "schema": {
+ "minContains": 1
+ },
+ "tests": [
+ {
+ "description": "one item valid against lone minContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "zero items still valid against lone minContains",
+ "data": [],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "minContains=1 with contains",
+ "schema": {
+ "contains": {"const": 1},
+ "minContains": 1
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "no elements match",
+ "data": [ 2 ],
+ "valid": false
+ },
+ {
+ "description": "single element matches, valid minContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "some elements match, valid minContains",
+ "data": [ 1, 2 ],
+ "valid": true
+ },
+ {
+ "description": "all elements match, valid minContains",
+ "data": [ 1, 1 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "minContains=2 with contains",
+ "schema": {
+ "contains": {"const": 1},
+ "minContains": 2
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, invalid minContains",
+ "data": [ 1 ],
+ "valid": false
+ },
+ {
+ "description": "some elements match, invalid minContains",
+ "data": [ 1, 2 ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, valid minContains (exactly as needed)",
+ "data": [ 1, 1 ],
+ "valid": true
+ },
+ {
+ "description": "all elements match, valid minContains (more than needed)",
+ "data": [ 1, 1, 1 ],
+ "valid": true
+ },
+ {
+ "description": "some elements match, valid minContains",
+ "data": [ 1, 2, 1 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "maxContains = minContains",
+ "schema": {
+ "contains": {"const": 1},
+ "maxContains": 2,
+ "minContains": 2
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, invalid minContains",
+ "data": [ 1 ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, invalid maxContains",
+ "data": [ 1, 1, 1 ],
+ "valid": false
+ },
+ {
+ "description": "all elements match, valid maxContains and minContains",
+ "data": [ 1, 1 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "maxContains < minContains",
+ "schema": {
+ "contains": {"const": 1},
+ "maxContains": 1,
+ "minContains": 3
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": false
+ },
+ {
+ "description": "invalid minContains",
+ "data": [ 1 ],
+ "valid": false
+ },
+ {
+ "description": "invalid maxContains",
+ "data": [ 1, 1, 1 ],
+ "valid": false
+ },
+ {
+ "description": "invalid maxContains and minContains",
+ "data": [ 1, 1 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "minContains = 0",
+ "schema": {
+ "contains": {"const": 1},
+ "minContains": 0
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "minContains = 0 makes contains always pass",
+ "data": [ 2 ],
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft2019-09/optional/format/hostname.json b/json/tests/draft2019-09/optional/format/hostname.json
index d22e57d..476541a 100644
--- a/json/tests/draft2019-09/optional/format/hostname.json
+++ b/json/tests/draft2019-09/optional/format/hostname.json
@@ -27,6 +27,41 @@
"description": "a host name with a component too long",
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
"valid": false
+ },
+ {
+ "description": "starts with hyphen",
+ "data": "-hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with hyphen",
+ "data": "hostname-",
+ "valid": false
+ },
+ {
+ "description": "starts with underscore",
+ "data": "_hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with underscore",
+ "data": "hostname_",
+ "valid": false
+ },
+ {
+ "description": "contains underscore",
+ "data": "host_name",
+ "valid": false
+ },
+ {
+ "description": "maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
+ "valid": true
+ },
+ {
+ "description": "exceeds maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
+ "valid": false
}
]
}
diff --git a/json/tests/draft2019-09/optional/format/idn-hostname.json b/json/tests/draft2019-09/optional/format/idn-hostname.json
index 3291820..32203d7 100644
--- a/json/tests/draft2019-09/optional/format/idn-hostname.json
+++ b/json/tests/draft2019-09/optional/format/idn-hostname.json
@@ -1,7 +1,7 @@
[
{
"description": "validation of internationalized host names",
- "schema": {"format": "idn-hostname"},
+ "schema": { "format": "idn-hostname" },
"tests": [
{
"description": "a valid host name (example.test in Hangul)",
@@ -22,6 +22,66 @@
"description": "a host name with a component too long",
"data": "실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실례례테스트례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례테스트례례실례.테스트",
"valid": false
+ },
+ {
+ "description": "invalid label, correct Punycode",
+ "comment": "https://tools.ietf.org/html/rfc5890#section-2.3.2.1 https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc3492#section-7.1",
+ "data": "-> $1.00 <--",
+ "valid": false
+ },
+ {
+ "description": "valid Chinese Punycode",
+ "comment": "https://tools.ietf.org/html/rfc5890#section-2.3.2.1 https://tools.ietf.org/html/rfc5891#section-4.4",
+ "data": "xn--ihqwcrb4cv8a8dqg056pqjye",
+ "valid": true
+ },
+ {
+ "description": "invalid Punycode",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc5890#section-2.3.2.1",
+ "data": "xn--X",
+ "valid": false
+ },
+ {
+ "description": "U-label contains \"--\" in the 3rd and 4th position",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1 https://tools.ietf.org/html/rfc5890#section-2.3.2.1",
+ "data": "XN--aa---o47jg78q",
+ "valid": false
+ },
+ {
+ "description": "U-label starts with a dash",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1",
+ "data": "-hello",
+ "valid": false
+ },
+ {
+ "description": "U-label ends with a dash",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1",
+ "data": "hello-",
+ "valid": false
+ },
+ {
+ "description": "U-label starts and ends with a dash",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1",
+ "data": "-hello-",
+ "valid": false
+ },
+ {
+ "description": "Begins with a Spacing Combining Mark",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
+ "data": "\u0903hello",
+ "valid": false
+ },
+ {
+ "description": "Begins with a Nonspacing Mark",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
+ "data": "\u0300hello",
+ "valid": false
+ },
+ {
+ "description": "Begins with an Enclosing Mark",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
+ "data": "\u0488hello",
+ "valid": false
}
]
}
diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json
index 1761346..a756eb0 100644
--- a/json/tests/draft2019-09/ref.json
+++ b/json/tests/draft2019-09/ref.json
@@ -76,12 +76,12 @@
"description": "escaped pointer ref",
"schema": {
"$defs": {
- "tilda~field": {"type": "integer"},
+ "tilde~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"}
},
"properties": {
- "tilda": {"$ref": "#/$defs/tilda~0field"},
+ "tilde": {"$ref": "#/$defs/tilde~0field"},
"slash": {"$ref": "#/$defs/slash~1field"},
"percent": {"$ref": "#/$defs/percent%25field"}
}
@@ -93,8 +93,8 @@
"valid": false
},
{
- "description": "tilda invalid",
- "data": {"tilda": "aoeu"},
+ "description": "tilde invalid",
+ "data": {"tilde": "aoeu"},
"valid": false
},
{
@@ -108,8 +108,8 @@
"valid": true
},
{
- "description": "tilda valid",
- "data": {"tilda": 123},
+ "description": "tilde valid",
+ "data": {"tilde": 123},
"valid": true
},
{
diff --git a/json/tests/draft2019-09/unevaluatedItems.json b/json/tests/draft2019-09/unevaluatedItems.json
index de285b0..01c07be 100644
--- a/json/tests/draft2019-09/unevaluatedItems.json
+++ b/json/tests/draft2019-09/unevaluatedItems.json
@@ -413,5 +413,25 @@
"valid": false
}
]
+ },
+ {
+ "description": "unevaluatedItems can't see inside cousins",
+ "schema": {
+ "allOf": [
+ {
+ "items": [ true ]
+ },
+ {
+ "unevaluatedItems": false
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "always fails",
+ "data": [ 1 ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/unevaluatedProperties.json b/json/tests/draft2019-09/unevaluatedProperties.json
index bae54cc..e315b4f 100644
--- a/json/tests/draft2019-09/unevaluatedProperties.json
+++ b/json/tests/draft2019-09/unevaluatedProperties.json
@@ -589,5 +589,29 @@
"valid": false
}
]
+ },
+ {
+ "description": "unevaluatedProperties can't see inside cousins",
+ "schema": {
+ "allOf": [
+ {
+ "properties": {
+ "foo": true
+ }
+ },
+ {
+ "unevaluatedProperties": false
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "always fails",
+ "data": {
+ "foo": 1
+ },
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/uniqueItems.json b/json/tests/draft2019-09/uniqueItems.json
index ea256a0..fb1ddb5 100644
--- a/json/tests/draft2019-09/uniqueItems.json
+++ b/json/tests/draft2019-09/uniqueItems.json
@@ -75,14 +75,44 @@
"valid": true
},
{
+ "description": "[1] and [true] are unique",
+ "data": [[1], [true]],
+ "valid": true
+ },
+ {
+ "description": "[0] and [false] are unique",
+ "data": [[0], [false]],
+ "valid": true
+ },
+ {
+ "description": "nested [1] and [true] are unique",
+ "data": [[[1], "foo"], [[true], "foo"]],
+ "valid": true
+ },
+ {
+ "description": "nested [0] and [false] are unique",
+ "data": [[[0], "foo"], [[false], "foo"]],
+ "valid": true
+ },
+ {
"description": "unique heterogeneous types are valid",
- "data": [{}, [1], true, null, 1],
+ "data": [{}, [1], true, null, 1, "{}"],
"valid": true
},
{
"description": "non-unique heterogeneous types are invalid",
"data": [{}, [1], true, null, {}, 1],
"valid": false
+ },
+ {
+ "description": "different objects are unique",
+ "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}],
+ "valid": true
+ },
+ {
+ "description": "objects are non-unique despite key order",
+ "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
+ "valid": false
}
]
},
diff --git a/json/tests/draft3/additionalItems.json b/json/tests/draft3/additionalItems.json
index 6d4bff5..3868cb4 100644
--- a/json/tests/draft3/additionalItems.json
+++ b/json/tests/draft3/additionalItems.json
@@ -40,7 +40,22 @@
},
"tests": [
{
- "description": "no additional items present",
+ "description": "empty array",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (1)",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (2)",
+ "data": [ 1, 2 ],
+ "valid": true
+ },
+ {
+ "description": "equal number of items present",
"data": [ 1, 2, 3 ],
"valid": true
},
@@ -70,10 +85,10 @@
},
{
"description": "additionalItems are allowed by default",
- "schema": {"items": []},
+ "schema": {"items": [{"type": "integer"}]},
"tests": [
{
- "description": "only the first items are validated",
+ "description": "only the first item is validated",
"data": [1, "foo", false],
"valid": true
}
diff --git a/json/tests/draft3/enum.json b/json/tests/draft3/enum.json
index 1cc111b..5a1ab3b 100644
--- a/json/tests/draft3/enum.json
+++ b/json/tests/draft3/enum.json
@@ -98,5 +98,21 @@
"valid": false
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "enum": [ "hello\u0000there" ] },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft3/optional/format.json b/json/tests/draft3/optional/format.json
deleted file mode 100644
index 9864589..0000000
--- a/json/tests/draft3/optional/format.json
+++ /dev/null
@@ -1,227 +0,0 @@
-[
- {
- "description": "validation of regular expressions",
- "schema": {"format": "regex"},
- "tests": [
- {
- "description": "a valid regular expression",
- "data": "([abc])+\\s+$",
- "valid": true
- },
- {
- "description": "a regular expression with unclosed parens is invalid",
- "data": "^(abc]",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of date-time strings",
- "schema": {"format": "date-time"},
- "tests": [
- {
- "description": "a valid date-time string",
- "data": "1963-06-19T08:30:06.283185Z",
- "valid": true
- },
- {
- "description": "an invalid date-time string",
- "data": "06/19/1963 08:30:06 PST",
- "valid": false
- },
- {
- "description": "case-insensitive T and Z",
- "data": "1963-06-19t08:30:06.283185z",
- "valid": true
- },
- {
- "description": "only RFC3339 not all of ISO 8601 are valid",
- "data": "2013-350T01:01:01",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of date strings",
- "schema": {"format": "date"},
- "tests": [
- {
- "description": "a valid date string",
- "data": "1963-06-19",
- "valid": true
- },
- {
- "description": "an invalid date string",
- "data": "06/19/1963",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of time strings",
- "schema": {"format": "time"},
- "tests": [
- {
- "description": "a valid time string",
- "data": "08:30:06",
- "valid": true
- },
- {
- "description": "an invalid time string",
- "data": "8:30 AM",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of URIs",
- "schema": {"format": "uri"},
- "tests": [
- {
- "description": "a valid URI",
- "data": "http://foo.bar/?baz=qux#quux",
- "valid": true
- },
- {
- "description": "an invalid protocol-relative URI Reference",
- "data": "//foo.bar/?baz=qux#quux",
- "valid": false
- },
- {
- "description": "an invalid URI",
- "data": "\\\\WINDOWS\\fileshare",
- "valid": false
- },
- {
- "description": "an invalid URI though valid URI reference",
- "data": "abc",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of e-mail addresses",
- "schema": {"format": "email"},
- "tests": [
- {
- "description": "a valid e-mail address",
- "data": "joe.bloggs@example.com",
- "valid": true
- },
- {
- "description": "an invalid e-mail address",
- "data": "2962",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IP addresses",
- "schema": {"format": "ip-address"},
- "tests": [
- {
- "description": "a valid IP address",
- "data": "192.168.0.1",
- "valid": true
- },
- {
- "description": "an IP address with too many components",
- "data": "127.0.0.0.1",
- "valid": false
- },
- {
- "description": "an IP address with out-of-range values",
- "data": "256.256.256.256",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IPv6 addresses",
- "schema": {"format": "ipv6"},
- "tests": [
- {
- "description": "a valid IPv6 address",
- "data": "::1",
- "valid": true
- },
- {
- "description": "an IPv6 address with out-of-range values",
- "data": "12345::",
- "valid": false
- },
- {
- "description": "an IPv6 address with too many components",
- "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
- "valid": false
- },
- {
- "description": "an IPv6 address containing illegal characters",
- "data": "::laptop",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of host names",
- "schema": {"format": "host-name"},
- "tests": [
- {
- "description": "a valid host name",
- "data": "www.example.com",
- "valid": true
- },
- {
- "description": "a host name starting with an illegal character",
- "data": "-a-host-name-that-starts-with--",
- "valid": false
- },
- {
- "description": "a host name containing illegal characters",
- "data": "not_a_valid_host_name",
- "valid": false
- },
- {
- "description": "a host name with a component too long",
- "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of CSS colors",
- "schema": {"format": "color"},
- "tests": [
- {
- "description": "a valid CSS color name",
- "data": "fuchsia",
- "valid": true
- },
- {
- "description": "a valid six-digit CSS color code",
- "data": "#CC8899",
- "valid": true
- },
- {
- "description": "a valid three-digit CSS color code",
- "data": "#C89",
- "valid": true
- },
- {
- "description": "an invalid CSS color code",
- "data": "#00332520",
- "valid": false
- },
- {
- "description": "an invalid CSS color name",
- "data": "puce",
- "valid": false
- },
- {
- "description": "a CSS color name containing invalid characters",
- "data": "light_grayish_red-violet",
- "valid": false
- }
- ]
- }
-]
diff --git a/json/tests/draft3/optional/format/color.json b/json/tests/draft3/optional/format/color.json
new file mode 100644
index 0000000..e80cb69
--- /dev/null
+++ b/json/tests/draft3/optional/format/color.json
@@ -0,0 +1,38 @@
+[
+ {
+ "description": "validation of CSS colors",
+ "schema": {"format": "color"},
+ "tests": [
+ {
+ "description": "a valid CSS color name",
+ "data": "fuchsia",
+ "valid": true
+ },
+ {
+ "description": "a valid six-digit CSS color code",
+ "data": "#CC8899",
+ "valid": true
+ },
+ {
+ "description": "a valid three-digit CSS color code",
+ "data": "#C89",
+ "valid": true
+ },
+ {
+ "description": "an invalid CSS color code",
+ "data": "#00332520",
+ "valid": false
+ },
+ {
+ "description": "an invalid CSS color name",
+ "data": "puce",
+ "valid": false
+ },
+ {
+ "description": "a CSS color name containing invalid characters",
+ "data": "light_grayish_red-violet",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/date-time.json b/json/tests/draft3/optional/format/date-time.json
new file mode 100644
index 0000000..90279ba
--- /dev/null
+++ b/json/tests/draft3/optional/format/date-time.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of date-time strings",
+ "schema": {"format": "date-time"},
+ "tests": [
+ {
+ "description": "a valid date-time string",
+ "data": "1963-06-19T08:30:06.283185Z",
+ "valid": true
+ },
+ {
+ "description": "an invalid date-time string",
+ "data": "06/19/1963 08:30:06 PST",
+ "valid": false
+ },
+ {
+ "description": "case-insensitive T and Z",
+ "data": "1963-06-19t08:30:06.283185z",
+ "valid": true
+ },
+ {
+ "description": "only RFC3339 not all of ISO 8601 are valid",
+ "data": "2013-350T01:01:01",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/date.json b/json/tests/draft3/optional/format/date.json
new file mode 100644
index 0000000..bd83042
--- /dev/null
+++ b/json/tests/draft3/optional/format/date.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of date strings",
+ "schema": {"format": "date"},
+ "tests": [
+ {
+ "description": "a valid date string",
+ "data": "1963-06-19",
+ "valid": true
+ },
+ {
+ "description": "an invalid date string",
+ "data": "06/19/1963",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/email.json b/json/tests/draft3/optional/format/email.json
new file mode 100644
index 0000000..c837c84
--- /dev/null
+++ b/json/tests/draft3/optional/format/email.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of e-mail addresses",
+ "schema": {"format": "email"},
+ "tests": [
+ {
+ "description": "a valid e-mail address",
+ "data": "joe.bloggs@example.com",
+ "valid": true
+ },
+ {
+ "description": "an invalid e-mail address",
+ "data": "2962",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/host-name.json b/json/tests/draft3/optional/format/host-name.json
new file mode 100644
index 0000000..8f6e28a
--- /dev/null
+++ b/json/tests/draft3/optional/format/host-name.json
@@ -0,0 +1,63 @@
+[
+ {
+ "description": "validation of host names",
+ "schema": {"format": "host-name"},
+ "tests": [
+ {
+ "description": "a valid host name",
+ "data": "www.example.com",
+ "valid": true
+ },
+ {
+ "description": "a host name starting with an illegal character",
+ "data": "-a-host-name-that-starts-with--",
+ "valid": false
+ },
+ {
+ "description": "a host name containing illegal characters",
+ "data": "not_a_valid_host_name",
+ "valid": false
+ },
+ {
+ "description": "a host name with a component too long",
+ "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
+ "valid": false
+ },
+ {
+ "description": "starts with hyphen",
+ "data": "-hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with hyphen",
+ "data": "hostname-",
+ "valid": false
+ },
+ {
+ "description": "starts with underscore",
+ "data": "_hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with underscore",
+ "data": "hostname_",
+ "valid": false
+ },
+ {
+ "description": "contains underscore",
+ "data": "host_name",
+ "valid": false
+ },
+ {
+ "description": "maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
+ "valid": true
+ },
+ {
+ "description": "exceeds maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/ip-address.json b/json/tests/draft3/optional/format/ip-address.json
new file mode 100644
index 0000000..c868bfb
--- /dev/null
+++ b/json/tests/draft3/optional/format/ip-address.json
@@ -0,0 +1,23 @@
+[
+ {
+ "description": "validation of IP addresses",
+ "schema": {"format": "ip-address"},
+ "tests": [
+ {
+ "description": "a valid IP address",
+ "data": "192.168.0.1",
+ "valid": true
+ },
+ {
+ "description": "an IP address with too many components",
+ "data": "127.0.0.0.1",
+ "valid": false
+ },
+ {
+ "description": "an IP address with out-of-range values",
+ "data": "256.256.256.256",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/ipv6.json b/json/tests/draft3/optional/format/ipv6.json
new file mode 100644
index 0000000..f67559b
--- /dev/null
+++ b/json/tests/draft3/optional/format/ipv6.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of IPv6 addresses",
+ "schema": {"format": "ipv6"},
+ "tests": [
+ {
+ "description": "a valid IPv6 address",
+ "data": "::1",
+ "valid": true
+ },
+ {
+ "description": "an IPv6 address with out-of-range values",
+ "data": "12345::",
+ "valid": false
+ },
+ {
+ "description": "an IPv6 address with too many components",
+ "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
+ "valid": false
+ },
+ {
+ "description": "an IPv6 address containing illegal characters",
+ "data": "::laptop",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/regex.json b/json/tests/draft3/optional/format/regex.json
new file mode 100644
index 0000000..d99d021
--- /dev/null
+++ b/json/tests/draft3/optional/format/regex.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of regular expressions",
+ "schema": {"format": "regex"},
+ "tests": [
+ {
+ "description": "a valid regular expression",
+ "data": "([abc])+\\s+$",
+ "valid": true
+ },
+ {
+ "description": "a regular expression with unclosed parens is invalid",
+ "data": "^(abc]",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/time.json b/json/tests/draft3/optional/format/time.json
new file mode 100644
index 0000000..e97160d
--- /dev/null
+++ b/json/tests/draft3/optional/format/time.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of time strings",
+ "schema": {"format": "time"},
+ "tests": [
+ {
+ "description": "a valid time string",
+ "data": "08:30:06",
+ "valid": true
+ },
+ {
+ "description": "an invalid time string",
+ "data": "8:30 AM",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/optional/format/uri.json b/json/tests/draft3/optional/format/uri.json
new file mode 100644
index 0000000..9c4de35
--- /dev/null
+++ b/json/tests/draft3/optional/format/uri.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of URIs",
+ "schema": {"format": "uri"},
+ "tests": [
+ {
+ "description": "a valid URI",
+ "data": "http://foo.bar/?baz=qux#quux",
+ "valid": true
+ },
+ {
+ "description": "an invalid protocol-relative URI Reference",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI though valid URI reference",
+ "data": "abc",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft3/ref.json b/json/tests/draft3/ref.json
index 31414ad..bd6b777 100644
--- a/json/tests/draft3/ref.json
+++ b/json/tests/draft3/ref.json
@@ -75,11 +75,11 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilda~field": {"type": "integer"},
+ "tilde~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
- "tilda": {"$ref": "#/tilda~0field"},
+ "tilde": {"$ref": "#/tilde~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
@@ -91,8 +91,8 @@
"valid": false
},
{
- "description": "tilda invalid",
- "data": {"tilda": "aoeu"},
+ "description": "tilde invalid",
+ "data": {"tilde": "aoeu"},
"valid": false
},
{
@@ -106,8 +106,8 @@
"valid": true
},
{
- "description": "tilda valid",
- "data": {"tilda": 123},
+ "description": "tilde valid",
+ "data": {"tilde": 123},
"valid": true
},
{
diff --git a/json/tests/draft3/uniqueItems.json b/json/tests/draft3/uniqueItems.json
index 58722b8..8f8dbdd 100644
--- a/json/tests/draft3/uniqueItems.json
+++ b/json/tests/draft3/uniqueItems.json
@@ -65,6 +65,26 @@
"valid": true
},
{
+ "description": "[1] and [true] are unique",
+ "data": [[1], [true]],
+ "valid": true
+ },
+ {
+ "description": "[0] and [false] are unique",
+ "data": [[0], [false]],
+ "valid": true
+ },
+ {
+ "description": "nested [1] and [true] are unique",
+ "data": [[[1], "foo"], [[true], "foo"]],
+ "valid": true
+ },
+ {
+ "description": "nested [0] and [false] are unique",
+ "data": [[[0], "foo"], [[false], "foo"]],
+ "valid": true
+ },
+ {
"description": "unique heterogeneous types are valid",
"data": [{}, [1], true, null, 1],
"valid": true
diff --git a/json/tests/draft4/additionalItems.json b/json/tests/draft4/additionalItems.json
index abecc57..69ea5e3 100644
--- a/json/tests/draft4/additionalItems.json
+++ b/json/tests/draft4/additionalItems.json
@@ -40,7 +40,17 @@
},
"tests": [
{
- "description": "fewer number of items present",
+ "description": "empty array",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (1)",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (2)",
"data": [ 1, 2 ],
"valid": true
},
diff --git a/json/tests/draft4/allOf.json b/json/tests/draft4/allOf.json
index 02d5f06..fc7dec5 100644
--- a/json/tests/draft4/allOf.json
+++ b/json/tests/draft4/allOf.json
@@ -207,5 +207,55 @@
"valid": false
}
]
+ },
+ {
+ "description": "allOf combined with anyOf, oneOf",
+ "schema": {
+ "allOf": [ { "multipleOf": 2 } ],
+ "anyOf": [ { "multipleOf": 3 } ],
+ "oneOf": [ { "multipleOf": 5 } ]
+ },
+ "tests": [
+ {
+ "description": "allOf: false, anyOf: false, oneOf: false",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: false, oneOf: true",
+ "data": 5,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: false",
+ "data": 3,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: true",
+ "data": 15,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: false",
+ "data": 2,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: true",
+ "data": 10,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: false",
+ "data": 6,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: true",
+ "data": 30,
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/enum.json b/json/tests/draft4/enum.json
index 0191b55..6844578 100644
--- a/json/tests/draft4/enum.json
+++ b/json/tests/draft4/enum.json
@@ -206,5 +206,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "enum": [ "hello\u0000there" ] },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/maxProperties.json b/json/tests/draft4/maxProperties.json
index 513731e..aa7209f 100644
--- a/json/tests/draft4/maxProperties.json
+++ b/json/tests/draft4/maxProperties.json
@@ -34,5 +34,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "maxProperties = 0 means the object is empty",
+ "schema": { "maxProperties": 0 },
+ "tests": [
+ {
+ "description": "no properties is valid",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "one property is invalid",
+ "data": { "foo": 1 },
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/optional/format.json b/json/tests/draft4/optional/format.json
deleted file mode 100644
index 4bf4ea8..0000000
--- a/json/tests/draft4/optional/format.json
+++ /dev/null
@@ -1,253 +0,0 @@
-[
- {
- "description": "validation of date-time strings",
- "schema": {"format": "date-time"},
- "tests": [
- {
- "description": "a valid date-time string",
- "data": "1963-06-19T08:30:06.283185Z",
- "valid": true
- },
- {
- "description": "a valid date-time string without second fraction",
- "data": "1963-06-19T08:30:06Z",
- "valid": true
- },
- {
- "description": "a valid date-time string with plus offset",
- "data": "1937-01-01T12:00:27.87+00:20",
- "valid": true
- },
- {
- "description": "a valid date-time string with minus offset",
- "data": "1990-12-31T15:59:50.123-08:00",
- "valid": true
- },
- {
- "description": "a invalid day in date-time string",
- "data": "1990-02-31T15:59:60.123-08:00",
- "valid": false
- },
- {
- "description": "an invalid offset in date-time string",
- "data": "1990-12-31T15:59:60-24:00",
- "valid": false
- },
- {
- "description": "an invalid date-time string",
- "data": "06/19/1963 08:30:06 PST",
- "valid": false
- },
- {
- "description": "case-insensitive T and Z",
- "data": "1963-06-19t08:30:06.283185z",
- "valid": true
- },
- {
- "description": "only RFC3339 not all of ISO 8601 are valid",
- "data": "2013-350T01:01:01",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of URIs",
- "schema": {"format": "uri"},
- "tests": [
- {
- "description": "a valid URL with anchor tag",
- "data": "http://foo.bar/?baz=qux#quux",
- "valid": true
- },
- {
- "description": "a valid URL with anchor tag and parantheses",
- "data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
- "valid": true
- },
- {
- "description": "a valid URL with URL-encoded stuff",
- "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
- "valid": true
- },
- {
- "description": "a valid puny-coded URL ",
- "data": "http://xn--nw2a.xn--j6w193g/",
- "valid": true
- },
- {
- "description": "a valid URL with many special characters",
- "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
- "valid": true
- },
- {
- "description": "a valid URL based on IPv4",
- "data": "http://223.255.255.254",
- "valid": true
- },
- {
- "description": "a valid URL with ftp scheme",
- "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
- "valid": true
- },
- {
- "description": "a valid URL for a simple text file",
- "data": "http://www.ietf.org/rfc/rfc2396.txt",
- "valid": true
- },
- {
- "description": "a valid URL ",
- "data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
- "valid": true
- },
- {
- "description": "a valid mailto URI",
- "data": "mailto:John.Doe@example.com",
- "valid": true
- },
- {
- "description": "a valid newsgroup URI",
- "data": "news:comp.infosystems.www.servers.unix",
- "valid": true
- },
- {
- "description": "a valid tel URI",
- "data": "tel:+1-816-555-1212",
- "valid": true
- },
- {
- "description": "a valid URN",
- "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
- "valid": true
- },
- {
- "description": "an invalid protocol-relative URI Reference",
- "data": "//foo.bar/?baz=qux#quux",
- "valid": false
- },
- {
- "description": "an invalid relative URI Reference",
- "data": "/abc",
- "valid": false
- },
- {
- "description": "an invalid URI",
- "data": "\\\\WINDOWS\\fileshare",
- "valid": false
- },
- {
- "description": "an invalid URI though valid URI reference",
- "data": "abc",
- "valid": false
- },
- {
- "description": "an invalid URI with spaces",
- "data": "http:// shouldfail.com",
- "valid": false
- },
- {
- "description": "an invalid URI with spaces and missing scheme",
- "data": ":// should fail",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of e-mail addresses",
- "schema": {"format": "email"},
- "tests": [
- {
- "description": "a valid e-mail address",
- "data": "joe.bloggs@example.com",
- "valid": true
- },
- {
- "description": "an invalid e-mail address",
- "data": "2962",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IP addresses",
- "schema": {"format": "ipv4"},
- "tests": [
- {
- "description": "a valid IP address",
- "data": "192.168.0.1",
- "valid": true
- },
- {
- "description": "an IP address with too many components",
- "data": "127.0.0.0.1",
- "valid": false
- },
- {
- "description": "an IP address with out-of-range values",
- "data": "256.256.256.256",
- "valid": false
- },
- {
- "description": "an IP address without 4 components",
- "data": "127.0",
- "valid": false
- },
- {
- "description": "an IP address as an integer",
- "data": "0x7f000001",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IPv6 addresses",
- "schema": {"format": "ipv6"},
- "tests": [
- {
- "description": "a valid IPv6 address",
- "data": "::1",
- "valid": true
- },
- {
- "description": "an IPv6 address with out-of-range values",
- "data": "12345::",
- "valid": false
- },
- {
- "description": "an IPv6 address with too many components",
- "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
- "valid": false
- },
- {
- "description": "an IPv6 address containing illegal characters",
- "data": "::laptop",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of host names",
- "schema": {"format": "hostname"},
- "tests": [
- {
- "description": "a valid host name",
- "data": "www.example.com",
- "valid": true
- },
- {
- "description": "a host name starting with an illegal character",
- "data": "-a-host-name-that-starts-with--",
- "valid": false
- },
- {
- "description": "a host name containing illegal characters",
- "data": "not_a_valid_host_name",
- "valid": false
- },
- {
- "description": "a host name with a component too long",
- "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
- "valid": false
- }
- ]
- }
-]
diff --git a/json/tests/draft4/optional/format/date-time.json b/json/tests/draft4/optional/format/date-time.json
new file mode 100644
index 0000000..dfccee6
--- /dev/null
+++ b/json/tests/draft4/optional/format/date-time.json
@@ -0,0 +1,53 @@
+[
+ {
+ "description": "validation of date-time strings",
+ "schema": {"format": "date-time"},
+ "tests": [
+ {
+ "description": "a valid date-time string",
+ "data": "1963-06-19T08:30:06.283185Z",
+ "valid": true
+ },
+ {
+ "description": "a valid date-time string without second fraction",
+ "data": "1963-06-19T08:30:06Z",
+ "valid": true
+ },
+ {
+ "description": "a valid date-time string with plus offset",
+ "data": "1937-01-01T12:00:27.87+00:20",
+ "valid": true
+ },
+ {
+ "description": "a valid date-time string with minus offset",
+ "data": "1990-12-31T15:59:50.123-08:00",
+ "valid": true
+ },
+ {
+ "description": "a invalid day in date-time string",
+ "data": "1990-02-31T15:59:60.123-08:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid offset in date-time string",
+ "data": "1990-12-31T15:59:60-24:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid date-time string",
+ "data": "06/19/1963 08:30:06 PST",
+ "valid": false
+ },
+ {
+ "description": "case-insensitive T and Z",
+ "data": "1963-06-19t08:30:06.283185z",
+ "valid": true
+ },
+ {
+ "description": "only RFC3339 not all of ISO 8601 are valid",
+ "data": "2013-350T01:01:01",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft4/optional/format/email.json b/json/tests/draft4/optional/format/email.json
new file mode 100644
index 0000000..c837c84
--- /dev/null
+++ b/json/tests/draft4/optional/format/email.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of e-mail addresses",
+ "schema": {"format": "email"},
+ "tests": [
+ {
+ "description": "a valid e-mail address",
+ "data": "joe.bloggs@example.com",
+ "valid": true
+ },
+ {
+ "description": "an invalid e-mail address",
+ "data": "2962",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft4/optional/format/hostname.json b/json/tests/draft4/optional/format/hostname.json
new file mode 100644
index 0000000..e913aba
--- /dev/null
+++ b/json/tests/draft4/optional/format/hostname.json
@@ -0,0 +1,64 @@
+[
+ {
+ "description": "validation of host names",
+ "schema": {"format": "hostname"},
+ "tests": [
+ {
+ "description": "a valid host name",
+ "data": "www.example.com",
+ "valid": true
+ },
+ {
+ "description": "a host name starting with an illegal character",
+ "data": "-a-host-name-that-starts-with--",
+ "valid": false
+ },
+ {
+ "description": "a host name containing illegal characters",
+ "data": "not_a_valid_host_name",
+ "valid": false
+ },
+ {
+ "description": "a host name with a component too long",
+ "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
+ "valid": false
+ },
+ {
+ "description": "starts with hyphen",
+ "data": "-hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with hyphen",
+ "data": "hostname-",
+ "valid": false
+ },
+ {
+ "description": "starts with underscore",
+ "data": "_hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with underscore",
+ "data": "hostname_",
+ "valid": false
+ },
+ {
+ "description": "contains underscore",
+ "data": "host_name",
+ "valid": false
+ },
+ {
+ "description": "maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
+ "valid": true
+ },
+ {
+ "description": "exceeds maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
+ "valid": false
+ }
+ ]
+ }
+]
+
diff --git a/json/tests/draft4/optional/format/ipv4.json b/json/tests/draft4/optional/format/ipv4.json
new file mode 100644
index 0000000..661148a
--- /dev/null
+++ b/json/tests/draft4/optional/format/ipv4.json
@@ -0,0 +1,33 @@
+[
+ {
+ "description": "validation of IP addresses",
+ "schema": {"format": "ipv4"},
+ "tests": [
+ {
+ "description": "a valid IP address",
+ "data": "192.168.0.1",
+ "valid": true
+ },
+ {
+ "description": "an IP address with too many components",
+ "data": "127.0.0.0.1",
+ "valid": false
+ },
+ {
+ "description": "an IP address with out-of-range values",
+ "data": "256.256.256.256",
+ "valid": false
+ },
+ {
+ "description": "an IP address without 4 components",
+ "data": "127.0",
+ "valid": false
+ },
+ {
+ "description": "an IP address as an integer",
+ "data": "0x7f000001",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft4/optional/format/ipv6.json b/json/tests/draft4/optional/format/ipv6.json
new file mode 100644
index 0000000..f67559b
--- /dev/null
+++ b/json/tests/draft4/optional/format/ipv6.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of IPv6 addresses",
+ "schema": {"format": "ipv6"},
+ "tests": [
+ {
+ "description": "a valid IPv6 address",
+ "data": "::1",
+ "valid": true
+ },
+ {
+ "description": "an IPv6 address with out-of-range values",
+ "data": "12345::",
+ "valid": false
+ },
+ {
+ "description": "an IPv6 address with too many components",
+ "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
+ "valid": false
+ },
+ {
+ "description": "an IPv6 address containing illegal characters",
+ "data": "::laptop",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft4/optional/format/uri.json b/json/tests/draft4/optional/format/uri.json
new file mode 100644
index 0000000..25cc40c
--- /dev/null
+++ b/json/tests/draft4/optional/format/uri.json
@@ -0,0 +1,103 @@
+[
+ {
+ "description": "validation of URIs",
+ "schema": {"format": "uri"},
+ "tests": [
+ {
+ "description": "a valid URL with anchor tag",
+ "data": "http://foo.bar/?baz=qux#quux",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with anchor tag and parantheses",
+ "data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with URL-encoded stuff",
+ "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
+ "valid": true
+ },
+ {
+ "description": "a valid puny-coded URL ",
+ "data": "http://xn--nw2a.xn--j6w193g/",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with many special characters",
+ "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
+ "valid": true
+ },
+ {
+ "description": "a valid URL based on IPv4",
+ "data": "http://223.255.255.254",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with ftp scheme",
+ "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
+ "valid": true
+ },
+ {
+ "description": "a valid URL for a simple text file",
+ "data": "http://www.ietf.org/rfc/rfc2396.txt",
+ "valid": true
+ },
+ {
+ "description": "a valid URL ",
+ "data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
+ "valid": true
+ },
+ {
+ "description": "a valid mailto URI",
+ "data": "mailto:John.Doe@example.com",
+ "valid": true
+ },
+ {
+ "description": "a valid newsgroup URI",
+ "data": "news:comp.infosystems.www.servers.unix",
+ "valid": true
+ },
+ {
+ "description": "a valid tel URI",
+ "data": "tel:+1-816-555-1212",
+ "valid": true
+ },
+ {
+ "description": "a valid URN",
+ "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
+ "valid": true
+ },
+ {
+ "description": "an invalid protocol-relative URI Reference",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": false
+ },
+ {
+ "description": "an invalid relative URI Reference",
+ "data": "/abc",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI though valid URI reference",
+ "data": "abc",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI with spaces",
+ "data": "http:// shouldfail.com",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI with spaces and missing scheme",
+ "data": ":// should fail",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft4/ref.json b/json/tests/draft4/ref.json
index 51e750f..895c880 100644
--- a/json/tests/draft4/ref.json
+++ b/json/tests/draft4/ref.json
@@ -75,11 +75,11 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilda~field": {"type": "integer"},
+ "tilde~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
- "tilda": {"$ref": "#/tilda~0field"},
+ "tilde": {"$ref": "#/tilde~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
@@ -91,8 +91,8 @@
"valid": false
},
{
- "description": "tilda invalid",
- "data": {"tilda": "aoeu"},
+ "description": "tilde invalid",
+ "data": {"tilde": "aoeu"},
"valid": false
},
{
@@ -106,8 +106,8 @@
"valid": true
},
{
- "description": "tilda valid",
- "data": {"tilda": 123},
+ "description": "tilde valid",
+ "data": {"tilde": 123},
"valid": true
},
{
diff --git a/json/tests/draft4/uniqueItems.json b/json/tests/draft4/uniqueItems.json
index ea256a0..fb1ddb5 100644
--- a/json/tests/draft4/uniqueItems.json
+++ b/json/tests/draft4/uniqueItems.json
@@ -75,14 +75,44 @@
"valid": true
},
{
+ "description": "[1] and [true] are unique",
+ "data": [[1], [true]],
+ "valid": true
+ },
+ {
+ "description": "[0] and [false] are unique",
+ "data": [[0], [false]],
+ "valid": true
+ },
+ {
+ "description": "nested [1] and [true] are unique",
+ "data": [[[1], "foo"], [[true], "foo"]],
+ "valid": true
+ },
+ {
+ "description": "nested [0] and [false] are unique",
+ "data": [[[0], "foo"], [[false], "foo"]],
+ "valid": true
+ },
+ {
"description": "unique heterogeneous types are valid",
- "data": [{}, [1], true, null, 1],
+ "data": [{}, [1], true, null, 1, "{}"],
"valid": true
},
{
"description": "non-unique heterogeneous types are invalid",
"data": [{}, [1], true, null, {}, 1],
"valid": false
+ },
+ {
+ "description": "different objects are unique",
+ "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}],
+ "valid": true
+ },
+ {
+ "description": "objects are non-unique despite key order",
+ "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
+ "valid": false
}
]
},
diff --git a/json/tests/draft6/additionalItems.json b/json/tests/draft6/additionalItems.json
index abecc57..69ea5e3 100644
--- a/json/tests/draft6/additionalItems.json
+++ b/json/tests/draft6/additionalItems.json
@@ -40,7 +40,17 @@
},
"tests": [
{
- "description": "fewer number of items present",
+ "description": "empty array",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (1)",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (2)",
"data": [ 1, 2 ],
"valid": true
},
diff --git a/json/tests/draft6/allOf.json b/json/tests/draft6/allOf.json
index cff8251..ec9319e 100644
--- a/json/tests/draft6/allOf.json
+++ b/json/tests/draft6/allOf.json
@@ -240,5 +240,55 @@
"valid": false
}
]
+ },
+ {
+ "description": "allOf combined with anyOf, oneOf",
+ "schema": {
+ "allOf": [ { "multipleOf": 2 } ],
+ "anyOf": [ { "multipleOf": 3 } ],
+ "oneOf": [ { "multipleOf": 5 } ]
+ },
+ "tests": [
+ {
+ "description": "allOf: false, anyOf: false, oneOf: false",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: false, oneOf: true",
+ "data": 5,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: false",
+ "data": 3,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: true",
+ "data": 15,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: false",
+ "data": 2,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: true",
+ "data": 10,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: false",
+ "data": 6,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: true",
+ "data": 30,
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/const.json b/json/tests/draft6/const.json
index 1a55235..c53d04d 100644
--- a/json/tests/draft6/const.json
+++ b/json/tests/draft6/const.json
@@ -238,5 +238,21 @@
"valid": false
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "const": "hello\u0000there" },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/contains.json b/json/tests/draft6/contains.json
index 67ecbd9..c5471cc 100644
--- a/json/tests/draft6/contains.json
+++ b/json/tests/draft6/contains.json
@@ -96,5 +96,34 @@
"valid": true
}
]
+ },
+ {
+ "description": "items + contains",
+ "schema": {
+ "items": { "multipleOf": 2 },
+ "contains": { "multipleOf": 3 }
+ },
+ "tests": [
+ {
+ "description": "matches items, does not match contains",
+ "data": [ 2, 4, 8 ],
+ "valid": false
+ },
+ {
+ "description": "does not match items, matches contains",
+ "data": [ 3, 6, 9 ],
+ "valid": false
+ },
+ {
+ "description": "matches both items and contains",
+ "data": [ 6, 12 ],
+ "valid": true
+ },
+ {
+ "description": "matches neither items nor contains",
+ "data": [ 1, 5 ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/enum.json b/json/tests/draft6/enum.json
index 0191b55..6844578 100644
--- a/json/tests/draft6/enum.json
+++ b/json/tests/draft6/enum.json
@@ -206,5 +206,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "enum": [ "hello\u0000there" ] },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/maxProperties.json b/json/tests/draft6/maxProperties.json
index 513731e..aa7209f 100644
--- a/json/tests/draft6/maxProperties.json
+++ b/json/tests/draft6/maxProperties.json
@@ -34,5 +34,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "maxProperties = 0 means the object is empty",
+ "schema": { "maxProperties": 0 },
+ "tests": [
+ {
+ "description": "no properties is valid",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "one property is invalid",
+ "data": { "foo": 1 },
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/optional/format.json b/json/tests/draft6/optional/format.json
deleted file mode 100644
index 3dd265f..0000000
--- a/json/tests/draft6/optional/format.json
+++ /dev/null
@@ -1,491 +0,0 @@
-[
- {
- "description": "validation of date-time strings",
- "schema": {"format": "date-time"},
- "tests": [
- {
- "description": "a valid date-time string",
- "data": "1963-06-19T08:30:06.283185Z",
- "valid": true
- },
- {
- "description": "a valid date-time string without second fraction",
- "data": "1963-06-19T08:30:06Z",
- "valid": true
- },
- {
- "description": "a valid date-time string with plus offset",
- "data": "1937-01-01T12:00:27.87+00:20",
- "valid": true
- },
- {
- "description": "a valid date-time string with minus offset",
- "data": "1990-12-31T15:59:50.123-08:00",
- "valid": true
- },
- {
- "description": "a invalid day in date-time string",
- "data": "1990-02-31T15:59:60.123-08:00",
- "valid": false
- },
- {
- "description": "an invalid offset in date-time string",
- "data": "1990-12-31T15:59:60-24:00",
- "valid": false
- },
- {
- "description": "an invalid closing Z after time-zone offset",
- "data": "1963-06-19T08:30:06.28123+01:00Z",
- "valid": false
- },
- {
- "description": "an invalid date-time string",
- "data": "06/19/1963 08:30:06 PST",
- "valid": false
- },
- {
- "description": "case-insensitive T and Z",
- "data": "1963-06-19t08:30:06.283185z",
- "valid": true
- },
- {
- "description": "only RFC3339 not all of ISO 8601 are valid",
- "data": "2013-350T01:01:01",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of URIs",
- "schema": {"format": "uri"},
- "tests": [
- {
- "description": "a valid URL with anchor tag",
- "data": "http://foo.bar/?baz=qux#quux",
- "valid": true
- },
- {
- "description": "a valid URL with anchor tag and parantheses",
- "data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
- "valid": true
- },
- {
- "description": "a valid URL with URL-encoded stuff",
- "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
- "valid": true
- },
- {
- "description": "a valid puny-coded URL ",
- "data": "http://xn--nw2a.xn--j6w193g/",
- "valid": true
- },
- {
- "description": "a valid URL with many special characters",
- "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
- "valid": true
- },
- {
- "description": "a valid URL based on IPv4",
- "data": "http://223.255.255.254",
- "valid": true
- },
- {
- "description": "a valid URL with ftp scheme",
- "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
- "valid": true
- },
- {
- "description": "a valid URL for a simple text file",
- "data": "http://www.ietf.org/rfc/rfc2396.txt",
- "valid": true
- },
- {
- "description": "a valid URL ",
- "data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
- "valid": true
- },
- {
- "description": "a valid mailto URI",
- "data": "mailto:John.Doe@example.com",
- "valid": true
- },
- {
- "description": "a valid newsgroup URI",
- "data": "news:comp.infosystems.www.servers.unix",
- "valid": true
- },
- {
- "description": "a valid tel URI",
- "data": "tel:+1-816-555-1212",
- "valid": true
- },
- {
- "description": "a valid URN",
- "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
- "valid": true
- },
- {
- "description": "an invalid protocol-relative URI Reference",
- "data": "//foo.bar/?baz=qux#quux",
- "valid": false
- },
- {
- "description": "an invalid relative URI Reference",
- "data": "/abc",
- "valid": false
- },
- {
- "description": "an invalid URI",
- "data": "\\\\WINDOWS\\fileshare",
- "valid": false
- },
- {
- "description": "an invalid URI though valid URI reference",
- "data": "abc",
- "valid": false
- },
- {
- "description": "an invalid URI with spaces",
- "data": "http:// shouldfail.com",
- "valid": false
- },
- {
- "description": "an invalid URI with spaces and missing scheme",
- "data": ":// should fail",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of URI References",
- "schema": {"format": "uri-reference"},
- "tests": [
- {
- "description": "a valid URI",
- "data": "http://foo.bar/?baz=qux#quux",
- "valid": true
- },
- {
- "description": "a valid protocol-relative URI Reference",
- "data": "//foo.bar/?baz=qux#quux",
- "valid": true
- },
- {
- "description": "a valid relative URI Reference",
- "data": "/abc",
- "valid": true
- },
- {
- "description": "an invalid URI Reference",
- "data": "\\\\WINDOWS\\fileshare",
- "valid": false
- },
- {
- "description": "a valid URI Reference",
- "data": "abc",
- "valid": true
- },
- {
- "description": "a valid URI fragment",
- "data": "#fragment",
- "valid": true
- },
- {
- "description": "an invalid URI fragment",
- "data": "#frag\\ment",
- "valid": false
- }
- ]
- },
- {
- "description": "format: uri-template",
- "schema": {"format": "uri-template"},
- "tests": [
- {
- "description": "a valid uri-template",
- "data": "http://example.com/dictionary/{term:1}/{term}",
- "valid": true
- },
- {
- "description": "an invalid uri-template",
- "data": "http://example.com/dictionary/{term:1}/{term",
- "valid": false
- },
- {
- "description": "a valid uri-template without variables",
- "data": "http://example.com/dictionary",
- "valid": true
- },
- {
- "description": "a valid relative uri-template",
- "data": "dictionary/{term:1}/{term}",
- "valid": true
- }
- ]
- },
- {
- "description": "validation of e-mail addresses",
- "schema": {"format": "email"},
- "tests": [
- {
- "description": "a valid e-mail address",
- "data": "joe.bloggs@example.com",
- "valid": true
- },
- {
- "description": "an invalid e-mail address",
- "data": "2962",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IP addresses",
- "schema": {"format": "ipv4"},
- "tests": [
- {
- "description": "a valid IP address",
- "data": "192.168.0.1",
- "valid": true
- },
- {
- "description": "an IP address with too many components",
- "data": "127.0.0.0.1",
- "valid": false
- },
- {
- "description": "an IP address with out-of-range values",
- "data": "256.256.256.256",
- "valid": false
- },
- {
- "description": "an IP address without 4 components",
- "data": "127.0",
- "valid": false
- },
- {
- "description": "an IP address as an integer",
- "data": "0x7f000001",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of IPv6 addresses",
- "schema": {"format": "ipv6"},
- "tests": [
- {
- "description": "a valid IPv6 address",
- "data": "::1",
- "valid": true
- },
- {
- "description": "an IPv6 address with out-of-range values",
- "data": "12345::",
- "valid": false
- },
- {
- "description": "an IPv6 address with too many components",
- "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
- "valid": false
- },
- {
- "description": "an IPv6 address containing illegal characters",
- "data": "::laptop",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of host names",
- "schema": {"format": "hostname"},
- "tests": [
- {
- "description": "a valid host name",
- "data": "www.example.com",
- "valid": true
- },
- {
- "description": "a host name starting with an illegal character",
- "data": "-a-host-name-that-starts-with--",
- "valid": false
- },
- {
- "description": "a host name containing illegal characters",
- "data": "not_a_valid_host_name",
- "valid": false
- },
- {
- "description": "a host name with a component too long",
- "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
- "valid": false
- }
- ]
- },
- {
- "description": "validation of JSON-pointers (JSON String Representation)",
- "schema": {"format": "json-pointer"},
- "tests": [
- {
- "description": "a valid JSON-pointer",
- "data": "/foo/bar~0/baz~1/%a",
- "valid": true
- },
- {
- "description": "not a valid JSON-pointer (~ not escaped)",
- "data": "/foo/bar~",
- "valid": false
- },
- {
- "description": "valid JSON-pointer with empty segment",
- "data": "/foo//bar",
- "valid": true
- },
- {
- "description": "valid JSON-pointer with the last empty segment",
- "data": "/foo/bar/",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #1",
- "data": "",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #2",
- "data": "/foo",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #3",
- "data": "/foo/0",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #4",
- "data": "/",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #5",
- "data": "/a~1b",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #6",
- "data": "/c%d",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #7",
- "data": "/e^f",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #8",
- "data": "/g|h",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #9",
- "data": "/i\\j",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #10",
- "data": "/k\"l",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #11",
- "data": "/ ",
- "valid": true
- },
- {
- "description": "valid JSON-pointer as stated in RFC 6901 #12",
- "data": "/m~0n",
- "valid": true
- },
- {
- "description": "valid JSON-pointer used adding to the last array position",
- "data": "/foo/-",
- "valid": true
- },
- {
- "description": "valid JSON-pointer (- used as object member name)",
- "data": "/foo/-/bar",
- "valid": true
- },
- {
- "description": "valid JSON-pointer (multiple escaped characters)",
- "data": "/~1~0~0~1~1",
- "valid": true
- },
- {
- "description": "valid JSON-pointer (escaped with fraction part) #1",
- "data": "/~1.1",
- "valid": true
- },
- {
- "description": "valid JSON-pointer (escaped with fraction part) #2",
- "data": "/~0.1",
- "valid": true
- },
- {
- "description": "not a valid JSON-pointer (URI Fragment Identifier) #1",
- "data": "#",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (URI Fragment Identifier) #2",
- "data": "#/",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (URI Fragment Identifier) #3",
- "data": "#a",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (some escaped, but not all) #1",
- "data": "/~0~",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (some escaped, but not all) #2",
- "data": "/~0/~",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (wrong escape character) #1",
- "data": "/~2",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (wrong escape character) #2",
- "data": "/~-1",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (multiple characters not escaped)",
- "data": "/~~",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (isn't empty nor starts with /) #1",
- "data": "a",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2",
- "data": "0",
- "valid": false
- },
- {
- "description": "not a valid JSON-pointer (isn't empty nor starts with /) #3",
- "data": "a/a",
- "valid": false
- }
- ]
- }
-]
diff --git a/json/tests/draft6/optional/format/date-time.json b/json/tests/draft6/optional/format/date-time.json
new file mode 100644
index 0000000..fc949e9
--- /dev/null
+++ b/json/tests/draft6/optional/format/date-time.json
@@ -0,0 +1,58 @@
+[
+ {
+ "description": "validation of date-time strings",
+ "schema": {"format": "date-time"},
+ "tests": [
+ {
+ "description": "a valid date-time string",
+ "data": "1963-06-19T08:30:06.283185Z",
+ "valid": true
+ },
+ {
+ "description": "a valid date-time string without second fraction",
+ "data": "1963-06-19T08:30:06Z",
+ "valid": true
+ },
+ {
+ "description": "a valid date-time string with plus offset",
+ "data": "1937-01-01T12:00:27.87+00:20",
+ "valid": true
+ },
+ {
+ "description": "a valid date-time string with minus offset",
+ "data": "1990-12-31T15:59:50.123-08:00",
+ "valid": true
+ },
+ {
+ "description": "a invalid day in date-time string",
+ "data": "1990-02-31T15:59:60.123-08:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid offset in date-time string",
+ "data": "1990-12-31T15:59:60-24:00",
+ "valid": false
+ },
+ {
+ "description": "an invalid closing Z after time-zone offset",
+ "data": "1963-06-19T08:30:06.28123+01:00Z",
+ "valid": false
+ },
+ {
+ "description": "an invalid date-time string",
+ "data": "06/19/1963 08:30:06 PST",
+ "valid": false
+ },
+ {
+ "description": "case-insensitive T and Z",
+ "data": "1963-06-19t08:30:06.283185z",
+ "valid": true
+ },
+ {
+ "description": "only RFC3339 not all of ISO 8601 are valid",
+ "data": "2013-350T01:01:01",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/email.json b/json/tests/draft6/optional/format/email.json
new file mode 100644
index 0000000..c837c84
--- /dev/null
+++ b/json/tests/draft6/optional/format/email.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of e-mail addresses",
+ "schema": {"format": "email"},
+ "tests": [
+ {
+ "description": "a valid e-mail address",
+ "data": "joe.bloggs@example.com",
+ "valid": true
+ },
+ {
+ "description": "an invalid e-mail address",
+ "data": "2962",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/hostname.json b/json/tests/draft6/optional/format/hostname.json
new file mode 100644
index 0000000..d7654e0
--- /dev/null
+++ b/json/tests/draft6/optional/format/hostname.json
@@ -0,0 +1,63 @@
+[
+ {
+ "description": "validation of host names",
+ "schema": {"format": "hostname"},
+ "tests": [
+ {
+ "description": "a valid host name",
+ "data": "www.example.com",
+ "valid": true
+ },
+ {
+ "description": "a host name starting with an illegal character",
+ "data": "-a-host-name-that-starts-with--",
+ "valid": false
+ },
+ {
+ "description": "a host name containing illegal characters",
+ "data": "not_a_valid_host_name",
+ "valid": false
+ },
+ {
+ "description": "a host name with a component too long",
+ "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
+ "valid": false
+ },
+ {
+ "description": "starts with hyphen",
+ "data": "-hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with hyphen",
+ "data": "hostname-",
+ "valid": false
+ },
+ {
+ "description": "starts with underscore",
+ "data": "_hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with underscore",
+ "data": "hostname_",
+ "valid": false
+ },
+ {
+ "description": "contains underscore",
+ "data": "host_name",
+ "valid": false
+ },
+ {
+ "description": "maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
+ "valid": true
+ },
+ {
+ "description": "exceeds maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/ipv4.json b/json/tests/draft6/optional/format/ipv4.json
new file mode 100644
index 0000000..661148a
--- /dev/null
+++ b/json/tests/draft6/optional/format/ipv4.json
@@ -0,0 +1,33 @@
+[
+ {
+ "description": "validation of IP addresses",
+ "schema": {"format": "ipv4"},
+ "tests": [
+ {
+ "description": "a valid IP address",
+ "data": "192.168.0.1",
+ "valid": true
+ },
+ {
+ "description": "an IP address with too many components",
+ "data": "127.0.0.0.1",
+ "valid": false
+ },
+ {
+ "description": "an IP address with out-of-range values",
+ "data": "256.256.256.256",
+ "valid": false
+ },
+ {
+ "description": "an IP address without 4 components",
+ "data": "127.0",
+ "valid": false
+ },
+ {
+ "description": "an IP address as an integer",
+ "data": "0x7f000001",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/ipv6.json b/json/tests/draft6/optional/format/ipv6.json
new file mode 100644
index 0000000..f67559b
--- /dev/null
+++ b/json/tests/draft6/optional/format/ipv6.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "validation of IPv6 addresses",
+ "schema": {"format": "ipv6"},
+ "tests": [
+ {
+ "description": "a valid IPv6 address",
+ "data": "::1",
+ "valid": true
+ },
+ {
+ "description": "an IPv6 address with out-of-range values",
+ "data": "12345::",
+ "valid": false
+ },
+ {
+ "description": "an IPv6 address with too many components",
+ "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
+ "valid": false
+ },
+ {
+ "description": "an IPv6 address containing illegal characters",
+ "data": "::laptop",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/json-pointer.json b/json/tests/draft6/optional/format/json-pointer.json
new file mode 100644
index 0000000..65c2f06
--- /dev/null
+++ b/json/tests/draft6/optional/format/json-pointer.json
@@ -0,0 +1,168 @@
+[
+ {
+ "description": "validation of JSON-pointers (JSON String Representation)",
+ "schema": {"format": "json-pointer"},
+ "tests": [
+ {
+ "description": "a valid JSON-pointer",
+ "data": "/foo/bar~0/baz~1/%a",
+ "valid": true
+ },
+ {
+ "description": "not a valid JSON-pointer (~ not escaped)",
+ "data": "/foo/bar~",
+ "valid": false
+ },
+ {
+ "description": "valid JSON-pointer with empty segment",
+ "data": "/foo//bar",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer with the last empty segment",
+ "data": "/foo/bar/",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #1",
+ "data": "",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #2",
+ "data": "/foo",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #3",
+ "data": "/foo/0",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #4",
+ "data": "/",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #5",
+ "data": "/a~1b",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #6",
+ "data": "/c%d",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #7",
+ "data": "/e^f",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #8",
+ "data": "/g|h",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #9",
+ "data": "/i\\j",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #10",
+ "data": "/k\"l",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #11",
+ "data": "/ ",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer as stated in RFC 6901 #12",
+ "data": "/m~0n",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer used adding to the last array position",
+ "data": "/foo/-",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer (- used as object member name)",
+ "data": "/foo/-/bar",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer (multiple escaped characters)",
+ "data": "/~1~0~0~1~1",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer (escaped with fraction part) #1",
+ "data": "/~1.1",
+ "valid": true
+ },
+ {
+ "description": "valid JSON-pointer (escaped with fraction part) #2",
+ "data": "/~0.1",
+ "valid": true
+ },
+ {
+ "description": "not a valid JSON-pointer (URI Fragment Identifier) #1",
+ "data": "#",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (URI Fragment Identifier) #2",
+ "data": "#/",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (URI Fragment Identifier) #3",
+ "data": "#a",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (some escaped, but not all) #1",
+ "data": "/~0~",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (some escaped, but not all) #2",
+ "data": "/~0/~",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (wrong escape character) #1",
+ "data": "/~2",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (wrong escape character) #2",
+ "data": "/~-1",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (multiple characters not escaped)",
+ "data": "/~~",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (isn't empty nor starts with /) #1",
+ "data": "a",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2",
+ "data": "0",
+ "valid": false
+ },
+ {
+ "description": "not a valid JSON-pointer (isn't empty nor starts with /) #3",
+ "data": "a/a",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/uri-reference.json b/json/tests/draft6/optional/format/uri-reference.json
new file mode 100644
index 0000000..e4c9eef
--- /dev/null
+++ b/json/tests/draft6/optional/format/uri-reference.json
@@ -0,0 +1,43 @@
+[
+ {
+ "description": "validation of URI References",
+ "schema": {"format": "uri-reference"},
+ "tests": [
+ {
+ "description": "a valid URI",
+ "data": "http://foo.bar/?baz=qux#quux",
+ "valid": true
+ },
+ {
+ "description": "a valid protocol-relative URI Reference",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": true
+ },
+ {
+ "description": "a valid relative URI Reference",
+ "data": "/abc",
+ "valid": true
+ },
+ {
+ "description": "an invalid URI Reference",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": false
+ },
+ {
+ "description": "a valid URI Reference",
+ "data": "abc",
+ "valid": true
+ },
+ {
+ "description": "a valid URI fragment",
+ "data": "#fragment",
+ "valid": true
+ },
+ {
+ "description": "an invalid URI fragment",
+ "data": "#frag\\ment",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/uri-template.json b/json/tests/draft6/optional/format/uri-template.json
new file mode 100644
index 0000000..33ab76e
--- /dev/null
+++ b/json/tests/draft6/optional/format/uri-template.json
@@ -0,0 +1,28 @@
+[
+ {
+ "description": "format: uri-template",
+ "schema": {"format": "uri-template"},
+ "tests": [
+ {
+ "description": "a valid uri-template",
+ "data": "http://example.com/dictionary/{term:1}/{term}",
+ "valid": true
+ },
+ {
+ "description": "an invalid uri-template",
+ "data": "http://example.com/dictionary/{term:1}/{term",
+ "valid": false
+ },
+ {
+ "description": "a valid uri-template without variables",
+ "data": "http://example.com/dictionary",
+ "valid": true
+ },
+ {
+ "description": "a valid relative uri-template",
+ "data": "dictionary/{term:1}/{term}",
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/optional/format/uri.json b/json/tests/draft6/optional/format/uri.json
new file mode 100644
index 0000000..25cc40c
--- /dev/null
+++ b/json/tests/draft6/optional/format/uri.json
@@ -0,0 +1,103 @@
+[
+ {
+ "description": "validation of URIs",
+ "schema": {"format": "uri"},
+ "tests": [
+ {
+ "description": "a valid URL with anchor tag",
+ "data": "http://foo.bar/?baz=qux#quux",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with anchor tag and parantheses",
+ "data": "http://foo.com/blah_(wikipedia)_blah#cite-1",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with URL-encoded stuff",
+ "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff",
+ "valid": true
+ },
+ {
+ "description": "a valid puny-coded URL ",
+ "data": "http://xn--nw2a.xn--j6w193g/",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with many special characters",
+ "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com",
+ "valid": true
+ },
+ {
+ "description": "a valid URL based on IPv4",
+ "data": "http://223.255.255.254",
+ "valid": true
+ },
+ {
+ "description": "a valid URL with ftp scheme",
+ "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt",
+ "valid": true
+ },
+ {
+ "description": "a valid URL for a simple text file",
+ "data": "http://www.ietf.org/rfc/rfc2396.txt",
+ "valid": true
+ },
+ {
+ "description": "a valid URL ",
+ "data": "ldap://[2001:db8::7]/c=GB?objectClass?one",
+ "valid": true
+ },
+ {
+ "description": "a valid mailto URI",
+ "data": "mailto:John.Doe@example.com",
+ "valid": true
+ },
+ {
+ "description": "a valid newsgroup URI",
+ "data": "news:comp.infosystems.www.servers.unix",
+ "valid": true
+ },
+ {
+ "description": "a valid tel URI",
+ "data": "tel:+1-816-555-1212",
+ "valid": true
+ },
+ {
+ "description": "a valid URN",
+ "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2",
+ "valid": true
+ },
+ {
+ "description": "an invalid protocol-relative URI Reference",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": false
+ },
+ {
+ "description": "an invalid relative URI Reference",
+ "data": "/abc",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI though valid URI reference",
+ "data": "abc",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI with spaces",
+ "data": "http:// shouldfail.com",
+ "valid": false
+ },
+ {
+ "description": "an invalid URI with spaces and missing scheme",
+ "data": ":// should fail",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/ref.json b/json/tests/draft6/ref.json
index 53f3a9e..6c29f22 100644
--- a/json/tests/draft6/ref.json
+++ b/json/tests/draft6/ref.json
@@ -75,11 +75,11 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilda~field": {"type": "integer"},
+ "tilde~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
- "tilda": {"$ref": "#/tilda~0field"},
+ "tilde": {"$ref": "#/tilde~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
@@ -91,8 +91,8 @@
"valid": false
},
{
- "description": "tilda invalid",
- "data": {"tilda": "aoeu"},
+ "description": "tilde invalid",
+ "data": {"tilde": "aoeu"},
"valid": false
},
{
@@ -106,8 +106,8 @@
"valid": true
},
{
- "description": "tilda valid",
- "data": {"tilda": 123},
+ "description": "tilde valid",
+ "data": {"tilde": 123},
"valid": true
},
{
diff --git a/json/tests/draft6/uniqueItems.json b/json/tests/draft6/uniqueItems.json
index ea256a0..fb1ddb5 100644
--- a/json/tests/draft6/uniqueItems.json
+++ b/json/tests/draft6/uniqueItems.json
@@ -75,14 +75,44 @@
"valid": true
},
{
+ "description": "[1] and [true] are unique",
+ "data": [[1], [true]],
+ "valid": true
+ },
+ {
+ "description": "[0] and [false] are unique",
+ "data": [[0], [false]],
+ "valid": true
+ },
+ {
+ "description": "nested [1] and [true] are unique",
+ "data": [[[1], "foo"], [[true], "foo"]],
+ "valid": true
+ },
+ {
+ "description": "nested [0] and [false] are unique",
+ "data": [[[0], "foo"], [[false], "foo"]],
+ "valid": true
+ },
+ {
"description": "unique heterogeneous types are valid",
- "data": [{}, [1], true, null, 1],
+ "data": [{}, [1], true, null, 1, "{}"],
"valid": true
},
{
"description": "non-unique heterogeneous types are invalid",
"data": [{}, [1], true, null, {}, 1],
"valid": false
+ },
+ {
+ "description": "different objects are unique",
+ "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}],
+ "valid": true
+ },
+ {
+ "description": "objects are non-unique despite key order",
+ "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
+ "valid": false
}
]
},
diff --git a/json/tests/draft7/additionalItems.json b/json/tests/draft7/additionalItems.json
index abecc57..69ea5e3 100644
--- a/json/tests/draft7/additionalItems.json
+++ b/json/tests/draft7/additionalItems.json
@@ -40,7 +40,17 @@
},
"tests": [
{
- "description": "fewer number of items present",
+ "description": "empty array",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (1)",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "fewer number of items present (2)",
"data": [ 1, 2 ],
"valid": true
},
diff --git a/json/tests/draft7/allOf.json b/json/tests/draft7/allOf.json
index cff8251..ec9319e 100644
--- a/json/tests/draft7/allOf.json
+++ b/json/tests/draft7/allOf.json
@@ -240,5 +240,55 @@
"valid": false
}
]
+ },
+ {
+ "description": "allOf combined with anyOf, oneOf",
+ "schema": {
+ "allOf": [ { "multipleOf": 2 } ],
+ "anyOf": [ { "multipleOf": 3 } ],
+ "oneOf": [ { "multipleOf": 5 } ]
+ },
+ "tests": [
+ {
+ "description": "allOf: false, anyOf: false, oneOf: false",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: false, oneOf: true",
+ "data": 5,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: false",
+ "data": 3,
+ "valid": false
+ },
+ {
+ "description": "allOf: false, anyOf: true, oneOf: true",
+ "data": 15,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: false",
+ "data": 2,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: false, oneOf: true",
+ "data": 10,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: false",
+ "data": 6,
+ "valid": false
+ },
+ {
+ "description": "allOf: true, anyOf: true, oneOf: true",
+ "data": 30,
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/const.json b/json/tests/draft7/const.json
index 1a55235..c53d04d 100644
--- a/json/tests/draft7/const.json
+++ b/json/tests/draft7/const.json
@@ -238,5 +238,21 @@
"valid": false
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "const": "hello\u0000there" },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/contains.json b/json/tests/draft7/contains.json
index 67ecbd9..c5471cc 100644
--- a/json/tests/draft7/contains.json
+++ b/json/tests/draft7/contains.json
@@ -96,5 +96,34 @@
"valid": true
}
]
+ },
+ {
+ "description": "items + contains",
+ "schema": {
+ "items": { "multipleOf": 2 },
+ "contains": { "multipleOf": 3 }
+ },
+ "tests": [
+ {
+ "description": "matches items, does not match contains",
+ "data": [ 2, 4, 8 ],
+ "valid": false
+ },
+ {
+ "description": "does not match items, matches contains",
+ "data": [ 3, 6, 9 ],
+ "valid": false
+ },
+ {
+ "description": "matches both items and contains",
+ "data": [ 6, 12 ],
+ "valid": true
+ },
+ {
+ "description": "matches neither items nor contains",
+ "data": [ 1, 5 ],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/enum.json b/json/tests/draft7/enum.json
index 0191b55..6844578 100644
--- a/json/tests/draft7/enum.json
+++ b/json/tests/draft7/enum.json
@@ -206,5 +206,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": { "enum": [ "hello\u0000there" ] },
+ "tests": [
+ {
+ "description": "match string with nul",
+ "data": "hello\u0000there",
+ "valid": true
+ },
+ {
+ "description": "do not match string lacking nul",
+ "data": "hellothere",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/if-then-else.json b/json/tests/draft7/if-then-else.json
index be73281..e0b873e 100644
--- a/json/tests/draft7/if-then-else.json
+++ b/json/tests/draft7/if-then-else.json
@@ -184,5 +184,45 @@
"valid": true
}
]
+ },
+ {
+ "description": "if with boolean schema true",
+ "schema": {
+ "if": true,
+ "then": { "const": "then" },
+ "else": { "const": "else" }
+ },
+ "tests": [
+ {
+ "description": "boolean schema true in if always chooses the then path (valid)",
+ "data": "then",
+ "valid": true
+ },
+ {
+ "description": "boolean schema true in if always chooses the then path (invalid)",
+ "data": "else",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "if with boolean schema false",
+ "schema": {
+ "if": false,
+ "then": { "const": "then" },
+ "else": { "const": "else" }
+ },
+ "tests": [
+ {
+ "description": "boolean schema false in if always chooses the else path (invalid)",
+ "data": "then",
+ "valid": false
+ },
+ {
+ "description": "boolean schema false in if always chooses the else path (valid)",
+ "data": "else",
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/maxProperties.json b/json/tests/draft7/maxProperties.json
index 513731e..aa7209f 100644
--- a/json/tests/draft7/maxProperties.json
+++ b/json/tests/draft7/maxProperties.json
@@ -34,5 +34,21 @@
"valid": true
}
]
+ },
+ {
+ "description": "maxProperties = 0 means the object is empty",
+ "schema": { "maxProperties": 0 },
+ "tests": [
+ {
+ "description": "no properties is valid",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "one property is invalid",
+ "data": { "foo": 1 },
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/optional/format/hostname.json b/json/tests/draft7/optional/format/hostname.json
index d22e57d..476541a 100644
--- a/json/tests/draft7/optional/format/hostname.json
+++ b/json/tests/draft7/optional/format/hostname.json
@@ -27,6 +27,41 @@
"description": "a host name with a component too long",
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
"valid": false
+ },
+ {
+ "description": "starts with hyphen",
+ "data": "-hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with hyphen",
+ "data": "hostname-",
+ "valid": false
+ },
+ {
+ "description": "starts with underscore",
+ "data": "_hostname",
+ "valid": false
+ },
+ {
+ "description": "ends with underscore",
+ "data": "hostname_",
+ "valid": false
+ },
+ {
+ "description": "contains underscore",
+ "data": "host_name",
+ "valid": false
+ },
+ {
+ "description": "maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com",
+ "valid": true
+ },
+ {
+ "description": "exceeds maximum label length",
+ "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com",
+ "valid": false
}
]
}
diff --git a/json/tests/draft7/optional/format/idn-hostname.json b/json/tests/draft7/optional/format/idn-hostname.json
index 3291820..6c0c22e 100644
--- a/json/tests/draft7/optional/format/idn-hostname.json
+++ b/json/tests/draft7/optional/format/idn-hostname.json
@@ -22,6 +22,66 @@
"description": "a host name with a component too long",
"data": "실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실례례테스트례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례테스트례례실례.테스트",
"valid": false
+ },
+ {
+ "description": "invalid label, correct Punycode",
+ "comment": "https://tools.ietf.org/html/rfc5890#section-2.3.2.1 https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc3492#section-7.1",
+ "data": "-> $1.00 <--",
+ "valid": false
+ },
+ {
+ "description": "valid Chinese Punycode",
+ "comment": "https://tools.ietf.org/html/rfc5890#section-2.3.2.1 https://tools.ietf.org/html/rfc5891#section-4.4",
+ "data": "xn--ihqwcrb4cv8a8dqg056pqjye",
+ "valid": true
+ },
+ {
+ "description": "invalid Punycode",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc5890#section-2.3.2.1",
+ "data": "xn--X",
+ "valid": false
+ },
+ {
+ "description": "U-label contains \"--\" in the 3rd and 4th position",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1 https://tools.ietf.org/html/rfc5890#section-2.3.2.1",
+ "data": "XN--aa---o47jg78q",
+ "valid": false
+ },
+ {
+ "description": "U-label starts with a dash",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1",
+ "data": "-hello",
+ "valid": false
+ },
+ {
+ "description": "U-label ends with a dash",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1",
+ "data": "hello-",
+ "valid": false
+ },
+ {
+ "description": "U-label starts and ends with a dash",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1",
+ "data": "-hello-",
+ "valid": false
+ },
+ {
+ "description": "Begins with a Spacing Combining Mark",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
+ "data": "\u0903hello",
+ "valid": false
+ },
+ {
+ "description": "Begins with a Nonspacing Mark",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
+ "data": "\u0300hello",
+ "valid": false
+ },
+ {
+ "description": "Begins with an Enclosing Mark",
+ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2",
+ "data": "\u0488hello",
+ "valid": false
}
]
}
diff --git a/json/tests/draft7/ref.json b/json/tests/draft7/ref.json
index 44b8ed2..9f1d81a 100644
--- a/json/tests/draft7/ref.json
+++ b/json/tests/draft7/ref.json
@@ -75,11 +75,11 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilda~field": {"type": "integer"},
+ "tilde~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
- "tilda": {"$ref": "#/tilda~0field"},
+ "tilde": {"$ref": "#/tilde~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
@@ -91,8 +91,8 @@
"valid": false
},
{
- "description": "tilda invalid",
- "data": {"tilda": "aoeu"},
+ "description": "tilde invalid",
+ "data": {"tilde": "aoeu"},
"valid": false
},
{
@@ -106,8 +106,8 @@
"valid": true
},
{
- "description": "tilda valid",
- "data": {"tilda": 123},
+ "description": "tilde valid",
+ "data": {"tilde": 123},
"valid": true
},
{
diff --git a/json/tests/draft7/uniqueItems.json b/json/tests/draft7/uniqueItems.json
index ea256a0..fb1ddb5 100644
--- a/json/tests/draft7/uniqueItems.json
+++ b/json/tests/draft7/uniqueItems.json
@@ -75,14 +75,44 @@
"valid": true
},
{
+ "description": "[1] and [true] are unique",
+ "data": [[1], [true]],
+ "valid": true
+ },
+ {
+ "description": "[0] and [false] are unique",
+ "data": [[0], [false]],
+ "valid": true
+ },
+ {
+ "description": "nested [1] and [true] are unique",
+ "data": [[[1], "foo"], [[true], "foo"]],
+ "valid": true
+ },
+ {
+ "description": "nested [0] and [false] are unique",
+ "data": [[[0], "foo"], [[false], "foo"]],
+ "valid": true
+ },
+ {
"description": "unique heterogeneous types are valid",
- "data": [{}, [1], true, null, 1],
+ "data": [{}, [1], true, null, 1, "{}"],
"valid": true
},
{
"description": "non-unique heterogeneous types are invalid",
"data": [{}, [1], true, null, {}, 1],
"valid": false
+ },
+ {
+ "description": "different objects are unique",
+ "data": [{"a": 1, "b": 2}, {"a": 2, "b": 1}],
+ "valid": true
+ },
+ {
+ "description": "objects are non-unique despite key order",
+ "data": [{"a": 1, "b": 2}, {"b": 2, "a": 1}],
+ "valid": false
}
]
},