summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2020-04-25 08:29:20 -0400
committerJulian Berman <Julian@GrayVines.com>2020-04-25 08:29:20 -0400
commit12a5756a1cb0112878036aff1efd7cec2944367b (patch)
tree2273be6a21d1ddb7dd2a5fdee2390c206f1819b2 /json
parent171f91b56b3e22cb006600a0e74058674176c382 (diff)
parente0a2a712a90b92e95604c2bf0e8a3d6c748053d3 (diff)
downloadjsonschema-12a5756a1cb0112878036aff1efd7cec2944367b.tar.gz
Merge commit 'e0a2a712a90b92e95604c2bf0e8a3d6c748053d3'
* commit 'e0a2a712a90b92e95604c2bf0e8a3d6c748053d3': Squashed 'json/' changes from 8e2a05a9..d17e1ba2
Diffstat (limited to 'json')
-rw-r--r--json/README.md2
-rw-r--r--json/index.js1
-rw-r--r--json/tests/draft2019-09/allOf.json26
-rw-r--r--json/tests/draft2019-09/enum.json21
-rw-r--r--json/tests/draft2019-09/oneOf.json26
-rw-r--r--json/tests/draft2019-09/optional/format/duration.json18
-rw-r--r--json/tests/draft2019-09/pattern.json27
-rw-r--r--json/tests/draft2019-09/ref.json2
-rw-r--r--json/tests/draft2019-09/uniqueItems.json177
-rw-r--r--json/tests/draft3/enum.json21
-rw-r--r--json/tests/draft3/pattern.json27
-rw-r--r--json/tests/draft3/uniqueItems.json167
-rw-r--r--json/tests/draft4/allOf.json26
-rw-r--r--json/tests/draft4/anyOf.json26
-rw-r--r--json/tests/draft4/enum.json21
-rw-r--r--json/tests/draft4/oneOf.json26
-rw-r--r--json/tests/draft4/pattern.json27
-rw-r--r--json/tests/draft4/uniqueItems.json177
-rw-r--r--json/tests/draft6/allOf.json26
-rw-r--r--json/tests/draft6/anyOf.json26
-rw-r--r--json/tests/draft6/enum.json21
-rw-r--r--json/tests/draft6/oneOf.json26
-rw-r--r--json/tests/draft6/pattern.json27
-rw-r--r--json/tests/draft6/uniqueItems.json177
-rw-r--r--json/tests/draft7/allOf.json26
-rw-r--r--json/tests/draft7/anyOf.json26
-rw-r--r--json/tests/draft7/enum.json21
-rw-r--r--json/tests/draft7/oneOf.json26
-rw-r--r--json/tests/draft7/pattern.json27
-rw-r--r--json/tests/draft7/uniqueItems.json171
30 files changed, 1398 insertions, 20 deletions
diff --git a/json/README.md b/json/README.md
index baa88df..9d802cc 100644
--- a/json/README.md
+++ b/json/README.md
@@ -1,5 +1,5 @@
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.
diff --git a/json/index.js b/json/index.js
index b138226..16dc3a5 100644
--- a/json/index.js
+++ b/json/index.js
@@ -2,7 +2,6 @@
const Ajv = require('ajv');
const jsonSchemaTest = require('json-schema-test');
-const assert = require('assert');
const refs = {
'http://localhost:1234/integer.json': require('./remotes/integer.json'),
diff --git a/json/tests/draft2019-09/allOf.json b/json/tests/draft2019-09/allOf.json
index eb61209..cff8251 100644
--- a/json/tests/draft2019-09/allOf.json
+++ b/json/tests/draft2019-09/allOf.json
@@ -214,5 +214,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested allOf, to check validation semantics",
+ "schema": {
+ "allOf": [
+ {
+ "allOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/enum.json b/json/tests/draft2019-09/enum.json
index 9327a70..0191b55 100644
--- a/json/tests/draft2019-09/enum.json
+++ b/json/tests/draft2019-09/enum.json
@@ -37,6 +37,27 @@
]
},
{
+ "description": "heterogeneous enum-with-null validation",
+ "schema": { "enum": [6, null] },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "number is valid",
+ "data": 6,
+ "valid": true
+ },
+ {
+ "description": "something else is invalid",
+ "data": "test",
+ "valid": false
+ }
+ ]
+ },
+ {
"description": "enums in properties",
"schema": {
"type":"object",
diff --git a/json/tests/draft2019-09/oneOf.json b/json/tests/draft2019-09/oneOf.json
index 76ca96c..eeb7ae8 100644
--- a/json/tests/draft2019-09/oneOf.json
+++ b/json/tests/draft2019-09/oneOf.json
@@ -244,5 +244,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested oneOf, to check validation semantics",
+ "schema": {
+ "oneOf": [
+ {
+ "oneOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/optional/format/duration.json b/json/tests/draft2019-09/optional/format/duration.json
new file mode 100644
index 0000000..24f8fcc
--- /dev/null
+++ b/json/tests/draft2019-09/optional/format/duration.json
@@ -0,0 +1,18 @@
+[
+ {
+ "description": "validation of duration strings",
+ "schema": {"format": "duration"},
+ "tests": [
+ {
+ "description": "a valid duration string",
+ "data": "P4DT12H30M5S",
+ "valid": true
+ },
+ {
+ "description": "an invalid duration string",
+ "data": "PT1D",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft2019-09/pattern.json b/json/tests/draft2019-09/pattern.json
index 25e7299..92db0f9 100644
--- a/json/tests/draft2019-09/pattern.json
+++ b/json/tests/draft2019-09/pattern.json
@@ -14,9 +14,34 @@
"valid": false
},
{
- "description": "ignores non-strings",
+ "description": "ignores booleans",
"data": true,
"valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
}
]
},
diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json
index c4161d5..1761346 100644
--- a/json/tests/draft2019-09/ref.json
+++ b/json/tests/draft2019-09/ref.json
@@ -375,7 +375,7 @@
},
"tests": [
{
- "description": "referenced subschema doesn't see annoations from properties",
+ "description": "referenced subschema doesn't see annotations from properties",
"data": {
"prop1": "match"
},
diff --git a/json/tests/draft2019-09/uniqueItems.json b/json/tests/draft2019-09/uniqueItems.json
index d312ad7..ea256a0 100644
--- a/json/tests/draft2019-09/uniqueItems.json
+++ b/json/tests/draft2019-09/uniqueItems.json
@@ -89,7 +89,7 @@
{
"description": "uniqueItems with an array of items",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
"uniqueItems": true
},
"tests": [
@@ -138,8 +138,8 @@
{
"description": "uniqueItems with an array of items and additionalItems=false",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
- "uniqueItems": true,
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": true,
"additionalItems": false
},
"tests": [
@@ -169,5 +169,176 @@
"valid": false
}
]
+ },
+ {
+ "description": "uniqueItems=false validation",
+ "schema": { "uniqueItems": false },
+ "tests": [
+ {
+ "description": "unique array of integers is valid",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of integers is valid",
+ "data": [1, 1],
+ "valid": true
+ },
+ {
+ "description": "numbers are unique if mathematically unequal",
+ "data": [1.0, 1.00, 1],
+ "valid": true
+ },
+ {
+ "description": "false is not equal to zero",
+ "data": [0, false],
+ "valid": true
+ },
+ {
+ "description": "true is not equal to one",
+ "data": [1, true],
+ "valid": true
+ },
+ {
+ "description": "unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "baz"}],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "bar"}],
+ "valid": true
+ },
+ {
+ "description": "unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : false}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : true}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "unique array of arrays is valid",
+ "data": [["foo"], ["bar"]],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of arrays is valid",
+ "data": [["foo"], ["foo"]],
+ "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": "unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, 1],
+ "valid": true
+ },
+ {
+ "description": "non-unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, {}, 1],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "foo"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "foo"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items and additionalItems=false",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false,
+ "additionalItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "extra items are invalid even if unique",
+ "data": [false, true, null],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft3/enum.json b/json/tests/draft3/enum.json
index 6cb2961..1cc111b 100644
--- a/json/tests/draft3/enum.json
+++ b/json/tests/draft3/enum.json
@@ -37,6 +37,27 @@
]
},
{
+ "description": "heterogeneous enum-with-null validation",
+ "schema": { "enum": [6, null] },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "number is valid",
+ "data": 6,
+ "valid": true
+ },
+ {
+ "description": "something else is invalid",
+ "data": "test",
+ "valid": false
+ }
+ ]
+ },
+ {
"description": "enums in properties",
"schema": {
"type":"object",
diff --git a/json/tests/draft3/pattern.json b/json/tests/draft3/pattern.json
index 25e7299..92db0f9 100644
--- a/json/tests/draft3/pattern.json
+++ b/json/tests/draft3/pattern.json
@@ -14,9 +14,34 @@
"valid": false
},
{
- "description": "ignores non-strings",
+ "description": "ignores booleans",
"data": true,
"valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
}
]
},
diff --git a/json/tests/draft3/uniqueItems.json b/json/tests/draft3/uniqueItems.json
index 59e3542..58722b8 100644
--- a/json/tests/draft3/uniqueItems.json
+++ b/json/tests/draft3/uniqueItems.json
@@ -79,7 +79,7 @@
{
"description": "uniqueItems with an array of items",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
"uniqueItems": true
},
"tests": [
@@ -128,8 +128,8 @@
{
"description": "uniqueItems with an array of items and additionalItems=false",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
- "uniqueItems": true,
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": true,
"additionalItems": false
},
"tests": [
@@ -159,5 +159,166 @@
"valid": false
}
]
+ },
+ {
+ "description": "uniqueItems=false validation",
+ "schema": { "uniqueItems": false },
+ "tests": [
+ {
+ "description": "unique array of integers is valid",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of integers is valid",
+ "data": [1, 1],
+ "valid": true
+ },
+ {
+ "description": "numbers are unique if mathematically unequal",
+ "data": [1.0, 1.00, 1],
+ "valid": true
+ },
+ {
+ "description": "unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "baz"}],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "bar"}],
+ "valid": true
+ },
+ {
+ "description": "unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : false}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : true}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "unique array of arrays is valid",
+ "data": [["foo"], ["bar"]],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of arrays is valid",
+ "data": [["foo"], ["foo"]],
+ "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": "unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, 1],
+ "valid": true
+ },
+ {
+ "description": "non-unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, {}, 1],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "foo"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "foo"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items and additionalItems=false",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false,
+ "additionalItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "extra items are invalid even if unique",
+ "data": [false, true, null],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/allOf.json b/json/tests/draft4/allOf.json
index ce9fdd4..02d5f06 100644
--- a/json/tests/draft4/allOf.json
+++ b/json/tests/draft4/allOf.json
@@ -181,5 +181,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested allOf, to check validation semantics",
+ "schema": {
+ "allOf": [
+ {
+ "allOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/anyOf.json b/json/tests/draft4/anyOf.json
index 09cc3c2..f8d82e8 100644
--- a/json/tests/draft4/anyOf.json
+++ b/json/tests/draft4/anyOf.json
@@ -152,5 +152,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested anyOf, to check validation semantics",
+ "schema": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/enum.json b/json/tests/draft4/enum.json
index 9327a70..0191b55 100644
--- a/json/tests/draft4/enum.json
+++ b/json/tests/draft4/enum.json
@@ -37,6 +37,27 @@
]
},
{
+ "description": "heterogeneous enum-with-null validation",
+ "schema": { "enum": [6, null] },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "number is valid",
+ "data": 6,
+ "valid": true
+ },
+ {
+ "description": "something else is invalid",
+ "data": "test",
+ "valid": false
+ }
+ ]
+ },
+ {
"description": "enums in properties",
"schema": {
"type":"object",
diff --git a/json/tests/draft4/oneOf.json b/json/tests/draft4/oneOf.json
index bdb2519..fb63b08 100644
--- a/json/tests/draft4/oneOf.json
+++ b/json/tests/draft4/oneOf.json
@@ -200,5 +200,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested oneOf, to check validation semantics",
+ "schema": {
+ "oneOf": [
+ {
+ "oneOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/pattern.json b/json/tests/draft4/pattern.json
index 25e7299..92db0f9 100644
--- a/json/tests/draft4/pattern.json
+++ b/json/tests/draft4/pattern.json
@@ -14,9 +14,34 @@
"valid": false
},
{
- "description": "ignores non-strings",
+ "description": "ignores booleans",
"data": true,
"valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
}
]
},
diff --git a/json/tests/draft4/uniqueItems.json b/json/tests/draft4/uniqueItems.json
index d312ad7..ea256a0 100644
--- a/json/tests/draft4/uniqueItems.json
+++ b/json/tests/draft4/uniqueItems.json
@@ -89,7 +89,7 @@
{
"description": "uniqueItems with an array of items",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
"uniqueItems": true
},
"tests": [
@@ -138,8 +138,8 @@
{
"description": "uniqueItems with an array of items and additionalItems=false",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
- "uniqueItems": true,
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": true,
"additionalItems": false
},
"tests": [
@@ -169,5 +169,176 @@
"valid": false
}
]
+ },
+ {
+ "description": "uniqueItems=false validation",
+ "schema": { "uniqueItems": false },
+ "tests": [
+ {
+ "description": "unique array of integers is valid",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of integers is valid",
+ "data": [1, 1],
+ "valid": true
+ },
+ {
+ "description": "numbers are unique if mathematically unequal",
+ "data": [1.0, 1.00, 1],
+ "valid": true
+ },
+ {
+ "description": "false is not equal to zero",
+ "data": [0, false],
+ "valid": true
+ },
+ {
+ "description": "true is not equal to one",
+ "data": [1, true],
+ "valid": true
+ },
+ {
+ "description": "unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "baz"}],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "bar"}],
+ "valid": true
+ },
+ {
+ "description": "unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : false}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : true}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "unique array of arrays is valid",
+ "data": [["foo"], ["bar"]],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of arrays is valid",
+ "data": [["foo"], ["foo"]],
+ "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": "unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, 1],
+ "valid": true
+ },
+ {
+ "description": "non-unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, {}, 1],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "foo"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "foo"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items and additionalItems=false",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false,
+ "additionalItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "extra items are invalid even if unique",
+ "data": [false, true, null],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/allOf.json b/json/tests/draft6/allOf.json
index eb61209..cff8251 100644
--- a/json/tests/draft6/allOf.json
+++ b/json/tests/draft6/allOf.json
@@ -214,5 +214,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested allOf, to check validation semantics",
+ "schema": {
+ "allOf": [
+ {
+ "allOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/anyOf.json b/json/tests/draft6/anyOf.json
index ab5eb38..b720afa 100644
--- a/json/tests/draft6/anyOf.json
+++ b/json/tests/draft6/anyOf.json
@@ -185,5 +185,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested anyOf, to check validation semantics",
+ "schema": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/enum.json b/json/tests/draft6/enum.json
index 9327a70..0191b55 100644
--- a/json/tests/draft6/enum.json
+++ b/json/tests/draft6/enum.json
@@ -37,6 +37,27 @@
]
},
{
+ "description": "heterogeneous enum-with-null validation",
+ "schema": { "enum": [6, null] },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "number is valid",
+ "data": 6,
+ "valid": true
+ },
+ {
+ "description": "something else is invalid",
+ "data": "test",
+ "valid": false
+ }
+ ]
+ },
+ {
"description": "enums in properties",
"schema": {
"type":"object",
diff --git a/json/tests/draft6/oneOf.json b/json/tests/draft6/oneOf.json
index 76ca96c..eeb7ae8 100644
--- a/json/tests/draft6/oneOf.json
+++ b/json/tests/draft6/oneOf.json
@@ -244,5 +244,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested oneOf, to check validation semantics",
+ "schema": {
+ "oneOf": [
+ {
+ "oneOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/pattern.json b/json/tests/draft6/pattern.json
index 25e7299..92db0f9 100644
--- a/json/tests/draft6/pattern.json
+++ b/json/tests/draft6/pattern.json
@@ -14,9 +14,34 @@
"valid": false
},
{
- "description": "ignores non-strings",
+ "description": "ignores booleans",
"data": true,
"valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
}
]
},
diff --git a/json/tests/draft6/uniqueItems.json b/json/tests/draft6/uniqueItems.json
index d312ad7..ea256a0 100644
--- a/json/tests/draft6/uniqueItems.json
+++ b/json/tests/draft6/uniqueItems.json
@@ -89,7 +89,7 @@
{
"description": "uniqueItems with an array of items",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
"uniqueItems": true
},
"tests": [
@@ -138,8 +138,8 @@
{
"description": "uniqueItems with an array of items and additionalItems=false",
"schema": {
- "items": [{"type": "boolean"}, {"type": "boolean"}],
- "uniqueItems": true,
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": true,
"additionalItems": false
},
"tests": [
@@ -169,5 +169,176 @@
"valid": false
}
]
+ },
+ {
+ "description": "uniqueItems=false validation",
+ "schema": { "uniqueItems": false },
+ "tests": [
+ {
+ "description": "unique array of integers is valid",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of integers is valid",
+ "data": [1, 1],
+ "valid": true
+ },
+ {
+ "description": "numbers are unique if mathematically unequal",
+ "data": [1.0, 1.00, 1],
+ "valid": true
+ },
+ {
+ "description": "false is not equal to zero",
+ "data": [0, false],
+ "valid": true
+ },
+ {
+ "description": "true is not equal to one",
+ "data": [1, true],
+ "valid": true
+ },
+ {
+ "description": "unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "baz"}],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "bar"}],
+ "valid": true
+ },
+ {
+ "description": "unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : false}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : true}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "unique array of arrays is valid",
+ "data": [["foo"], ["bar"]],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of arrays is valid",
+ "data": [["foo"], ["foo"]],
+ "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": "unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, 1],
+ "valid": true
+ },
+ {
+ "description": "non-unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, {}, 1],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "foo"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "foo"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items and additionalItems=false",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false,
+ "additionalItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "extra items are invalid even if unique",
+ "data": [false, true, null],
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/allOf.json b/json/tests/draft7/allOf.json
index eb61209..cff8251 100644
--- a/json/tests/draft7/allOf.json
+++ b/json/tests/draft7/allOf.json
@@ -214,5 +214,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested allOf, to check validation semantics",
+ "schema": {
+ "allOf": [
+ {
+ "allOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/anyOf.json b/json/tests/draft7/anyOf.json
index ab5eb38..b720afa 100644
--- a/json/tests/draft7/anyOf.json
+++ b/json/tests/draft7/anyOf.json
@@ -185,5 +185,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested anyOf, to check validation semantics",
+ "schema": {
+ "anyOf": [
+ {
+ "anyOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/enum.json b/json/tests/draft7/enum.json
index 9327a70..0191b55 100644
--- a/json/tests/draft7/enum.json
+++ b/json/tests/draft7/enum.json
@@ -37,6 +37,27 @@
]
},
{
+ "description": "heterogeneous enum-with-null validation",
+ "schema": { "enum": [6, null] },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "number is valid",
+ "data": 6,
+ "valid": true
+ },
+ {
+ "description": "something else is invalid",
+ "data": "test",
+ "valid": false
+ }
+ ]
+ },
+ {
"description": "enums in properties",
"schema": {
"type":"object",
diff --git a/json/tests/draft7/oneOf.json b/json/tests/draft7/oneOf.json
index 76ca96c..eeb7ae8 100644
--- a/json/tests/draft7/oneOf.json
+++ b/json/tests/draft7/oneOf.json
@@ -244,5 +244,31 @@
"valid": false
}
]
+ },
+ {
+ "description": "nested oneOf, to check validation semantics",
+ "schema": {
+ "oneOf": [
+ {
+ "oneOf": [
+ {
+ "type": "null"
+ }
+ ]
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null is valid",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "anything non-null is invalid",
+ "data": 123,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/pattern.json b/json/tests/draft7/pattern.json
index 25e7299..92db0f9 100644
--- a/json/tests/draft7/pattern.json
+++ b/json/tests/draft7/pattern.json
@@ -14,9 +14,34 @@
"valid": false
},
{
- "description": "ignores non-strings",
+ "description": "ignores booleans",
"data": true,
"valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
}
]
},
diff --git a/json/tests/draft7/uniqueItems.json b/json/tests/draft7/uniqueItems.json
index d0a94d8..ea256a0 100644
--- a/json/tests/draft7/uniqueItems.json
+++ b/json/tests/draft7/uniqueItems.json
@@ -169,5 +169,176 @@
"valid": false
}
]
+ },
+ {
+ "description": "uniqueItems=false validation",
+ "schema": { "uniqueItems": false },
+ "tests": [
+ {
+ "description": "unique array of integers is valid",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of integers is valid",
+ "data": [1, 1],
+ "valid": true
+ },
+ {
+ "description": "numbers are unique if mathematically unequal",
+ "data": [1.0, 1.00, 1],
+ "valid": true
+ },
+ {
+ "description": "false is not equal to zero",
+ "data": [0, false],
+ "valid": true
+ },
+ {
+ "description": "true is not equal to one",
+ "data": [1, true],
+ "valid": true
+ },
+ {
+ "description": "unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "baz"}],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of objects is valid",
+ "data": [{"foo": "bar"}, {"foo": "bar"}],
+ "valid": true
+ },
+ {
+ "description": "unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : false}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of nested objects is valid",
+ "data": [
+ {"foo": {"bar" : {"baz" : true}}},
+ {"foo": {"bar" : {"baz" : true}}}
+ ],
+ "valid": true
+ },
+ {
+ "description": "unique array of arrays is valid",
+ "data": [["foo"], ["bar"]],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of arrays is valid",
+ "data": [["foo"], ["foo"]],
+ "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": "unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, 1],
+ "valid": true
+ },
+ {
+ "description": "non-unique heterogeneous types are valid",
+ "data": [{}, [1], true, null, {}, 1],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [false, true] is valid",
+ "data": [false, true, "foo", "foo"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array extended from [true, false] is valid",
+ "data": [true, false, "foo", "foo"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems=false with an array of items and additionalItems=false",
+ "schema": {
+ "items": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false,
+ "additionalItems": false
+ },
+ "tests": [
+ {
+ "description": "[false, true] from items array is valid",
+ "data": [false, true],
+ "valid": true
+ },
+ {
+ "description": "[true, false] from items array is valid",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "[false, false] from items array is valid",
+ "data": [false, false],
+ "valid": true
+ },
+ {
+ "description": "[true, true] from items array is valid",
+ "data": [true, true],
+ "valid": true
+ },
+ {
+ "description": "extra items are invalid even if unique",
+ "data": [false, true, null],
+ "valid": false
+ }
+ ]
}
]