summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2022-07-11 12:29:21 +0200
committerJulian Berman <Julian@GrayVines.com>2022-07-11 12:29:21 +0200
commitbb745353ec9e2cc8f6d5fa447c49fff1e5fdc05f (patch)
tree995531cf099e1af7f257742afb71c908302085f9 /json
parent36d098e2f51631fc97ac64488898de897e582d9c (diff)
parentc09578b4249e70cc9148d012055b1071f2ad19a9 (diff)
downloadjsonschema-bb745353ec9e2cc8f6d5fa447c49fff1e5fdc05f.tar.gz
Merge commit 'c09578b4249e70cc9148d012055b1071f2ad19a9'v4.7.0
* commit 'c09578b4249e70cc9148d012055b1071f2ad19a9': Squashed 'json/' changes from b7d13f4b..69acf529
Diffstat (limited to 'json')
-rw-r--r--json/.github/CODEOWNERS2
-rw-r--r--json/README.md1
-rwxr-xr-xjson/bin/jsonschema_suite135
-rw-r--r--json/package.json12
-rw-r--r--json/tests/draft-next/additionalProperties.json15
-rw-r--r--json/tests/draft-next/contains.json15
-rw-r--r--json/tests/draft-next/items.json15
-rw-r--r--json/tests/draft-next/patternProperties.json15
-rw-r--r--json/tests/draft-next/prefixItems.json17
-rw-r--r--json/tests/draft-next/properties.json15
-rw-r--r--json/tests/draft-next/unevaluatedItems.json15
-rw-r--r--json/tests/draft2019-09/additionalItems.json15
-rw-r--r--json/tests/draft2019-09/additionalProperties.json15
-rw-r--r--json/tests/draft2019-09/contains.json15
-rw-r--r--json/tests/draft2019-09/items.json32
-rw-r--r--json/tests/draft2019-09/patternProperties.json15
-rw-r--r--json/tests/draft2019-09/properties.json15
-rw-r--r--json/tests/draft2019-09/unevaluatedItems.json15
-rw-r--r--json/tests/draft2019-09/unevaluatedProperties.json15
-rw-r--r--json/tests/draft2020-12/additionalProperties.json15
-rw-r--r--json/tests/draft2020-12/contains.json15
-rw-r--r--json/tests/draft2020-12/items.json15
-rw-r--r--json/tests/draft2020-12/patternProperties.json15
-rw-r--r--json/tests/draft2020-12/prefixItems.json17
-rw-r--r--json/tests/draft2020-12/properties.json15
-rw-r--r--json/tests/draft2020-12/unevaluatedItems.json15
-rw-r--r--json/tests/draft2020-12/unevaluatedProperties.json15
-rw-r--r--json/tests/draft3/additionalItems.json15
-rw-r--r--json/tests/draft3/additionalProperties.json15
-rw-r--r--json/tests/draft3/items.json32
-rw-r--r--json/tests/draft3/patternProperties.json15
-rw-r--r--json/tests/draft3/properties.json15
-rw-r--r--json/tests/draft4/additionalItems.json15
-rw-r--r--json/tests/draft4/additionalProperties.json15
-rw-r--r--json/tests/draft4/items.json32
-rw-r--r--json/tests/draft4/patternProperties.json15
-rw-r--r--json/tests/draft4/properties.json15
-rw-r--r--json/tests/draft6/additionalItems.json15
-rw-r--r--json/tests/draft6/additionalProperties.json15
-rw-r--r--json/tests/draft6/contains.json15
-rw-r--r--json/tests/draft6/items.json32
-rw-r--r--json/tests/draft6/patternProperties.json15
-rw-r--r--json/tests/draft6/properties.json15
-rw-r--r--json/tests/draft7/additionalItems.json15
-rw-r--r--json/tests/draft7/additionalProperties.json15
-rw-r--r--json/tests/draft7/contains.json15
-rw-r--r--json/tests/draft7/items.json32
-rw-r--r--json/tests/draft7/patternProperties.json15
-rw-r--r--json/tests/draft7/properties.json15
49 files changed, 852 insertions, 62 deletions
diff --git a/json/.github/CODEOWNERS b/json/.github/CODEOWNERS
new file mode 100644
index 0000000..15f4a2d
--- /dev/null
+++ b/json/.github/CODEOWNERS
@@ -0,0 +1,2 @@
+# Ping the entire test suite team by default.
+* @json-schema-org/test-suite-team
diff --git a/json/README.md b/json/README.md
index 1de5391..d9cc165 100644
--- a/json/README.md
+++ b/json/README.md
@@ -286,6 +286,7 @@ Node-specific support is maintained in a [separate repository](https://github.co
* [fastjsonschema](https://github.com/seznam/python-fastjsonschema)
* [hypothesis-jsonschema](https://github.com/Zac-HD/hypothesis-jsonschema)
* [jschon](https://github.com/marksparkza/jschon)
+* [python-experimental, OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python-experimental.md)
### Ruby
diff --git a/json/bin/jsonschema_suite b/json/bin/jsonschema_suite
index 19dc65e..a859dcf 100755
--- a/json/bin/jsonschema_suite
+++ b/json/bin/jsonschema_suite
@@ -1,7 +1,7 @@
#! /usr/bin/env python3
+from pathlib import Path
import argparse
import errno
-import fnmatch
import json
import os
import random
@@ -28,42 +28,36 @@ else:
}
-ROOT_DIR = os.path.abspath(
- os.path.join(os.path.dirname(__file__), os.pardir).rstrip("__pycache__"),
-)
-SUITE_ROOT_DIR = os.path.join(ROOT_DIR, "tests")
-REMOTES_DIR = os.path.join(ROOT_DIR, "remotes")
-
+ROOT_DIR = Path(__file__).parent.parent
+SUITE_ROOT_DIR = ROOT_DIR / "tests"
+REMOTES_DIR = ROOT_DIR / "remotes"
-with open(os.path.join(ROOT_DIR, "test-schema.json")) as schema:
- TESTSUITE_SCHEMA = json.load(schema)
+TESTSUITE_SCHEMA = json.loads((ROOT_DIR / "test-schema.json").read_text())
def files(paths):
"""
- Each test file in the provided paths.
+ Each test file in the provided paths, as an array of test cases.
"""
for path in paths:
- with open(path) as test_file:
- yield json.load(test_file)
+ yield json.loads(path.read_text())
-def groups(paths):
+def cases(paths):
"""
- Each test group within each file in the provided paths.
+ Each test case within each file in the provided paths.
"""
for test_file in files(paths):
- for group in test_file:
- yield group
+ yield from test_file
-def cases(paths):
+def tests(paths):
"""
- Each individual test case within all groups within the provided paths.
+ Each individual test within all cases within the provided paths.
"""
- for test_group in groups(paths):
- for test in test_group["tests"]:
- test["schema"] = test_group["schema"]
+ for case in cases(paths):
+ for test in case["tests"]:
+ test["schema"] = case["schema"]
yield test
@@ -71,76 +65,96 @@ def collect(root_dir):
"""
All of the test file paths within the given root directory, recursively.
"""
- for root, _, files in os.walk(root_dir):
- for filename in fnmatch.filter(files, "*.json"):
- yield os.path.join(root, filename)
+ return root_dir.glob("**/*.json")
class SanityTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
- print("Looking for tests in %s" % SUITE_ROOT_DIR)
- print("Looking for remotes in %s" % REMOTES_DIR)
+ print(f"Looking for tests in {SUITE_ROOT_DIR}")
+ print(f"Looking for remotes in {REMOTES_DIR}")
+
cls.test_files = list(collect(SUITE_ROOT_DIR))
- cls.remote_files = list(collect(REMOTES_DIR))
- print("Found %s test files" % len(cls.test_files))
- print("Found %s remote files" % len(cls.remote_files))
assert cls.test_files, "Didn't find the test files!"
+ print(f"Found {len(cls.test_files)} test files")
+
+ cls.remote_files = list(collect(REMOTES_DIR))
assert cls.remote_files, "Didn't find the remote files!"
+ print(f"Found {len(cls.remote_files)} remote files")
def test_all_test_files_are_valid_json(self):
+ """
+ All test files contain valid JSON.
+ """
for path in self.test_files:
- with open(path) as test_file:
- try:
- json.load(test_file)
- except ValueError as error:
- self.fail("%s contains invalid JSON (%s)" % (path, error))
+ try:
+ json.loads(path.read_text())
+ except ValueError as error:
+ self.fail(f"{path} contains invalid JSON ({error})")
def test_all_remote_files_are_valid_json(self):
+ """
+ All remote files contain valid JSON.
+ """
for path in self.remote_files:
- with open(path) as remote_file:
- try:
- json.load(remote_file)
- except ValueError as error:
- self.fail("%s contains invalid JSON (%s)" % (path, error))
+ try:
+ json.loads(path.read_text())
+ except ValueError as error:
+ self.fail(f"{path} contains invalid JSON ({error})")
def test_all_descriptions_have_reasonable_length(self):
- for case in cases(self.test_files):
- description = case["description"]
+ """
+ All tests have reasonably long descriptions.
+ """
+ for count, test in enumerate(tests(self.test_files)):
+ description = test["description"]
self.assertLess(
len(description),
70,
- "%r is too long! (keep it to less than 70 chars)" % (
- description,
- ),
+ f"{description!r} is too long! (keep it to less than 70 chars)"
)
+ print(f"Found {count} tests.")
def test_all_descriptions_are_unique(self):
- for group in groups(self.test_files):
- descriptions = set(test["description"] for test in group["tests"])
+ """
+ All test cases have unique test descriptions in their tests.
+ """
+ for count, case in enumerate(cases(self.test_files)):
+ descriptions = set(test["description"] for test in case["tests"])
self.assertEqual(
len(descriptions),
- len(group["tests"]),
- "%r contains a duplicate description" % (group,)
+ len(case["tests"]),
+ f"{case!r} contains a duplicate description",
)
+ print(f"Found {count} test cases.")
@unittest.skipIf(jsonschema is None, "Validation library not present!")
def test_all_schemas_are_valid(self):
- for version in os.listdir(SUITE_ROOT_DIR):
- Validator = VALIDATORS.get(version)
+ """
+ All schemas are valid under their metaschemas.
+ """
+ for version in SUITE_ROOT_DIR.iterdir():
+ if not version.is_dir():
+ continue
+
+ Validator = VALIDATORS.get(version.name)
if Validator is not None:
- test_files = collect(os.path.join(SUITE_ROOT_DIR, version))
+ test_files = collect(version)
for case in cases(test_files):
try:
Validator.check_schema(case["schema"])
except jsonschema.SchemaError as error:
- self.fail("%s contains an invalid schema (%s)" %
- (case, error))
+ self.fail(
+ f"{case} contains an invalid schema ({error})",
+ )
else:
- warnings.warn("No schema validator for %s" % schema)
+ warnings.warn(f"No schema validator for {version.name}")
@unittest.skipIf(jsonschema is None, "Validation library not present!")
def test_suites_are_valid(self):
+ """
+ All test files are valid under test-schema.json.
+ """
Validator = jsonschema.validators.validator_for(TESTSUITE_SCHEMA)
validator = Validator(TESTSUITE_SCHEMA)
for tests in files(self.test_files):
@@ -153,7 +167,7 @@ class SanityTests(unittest.TestCase):
def main(arguments):
if arguments.command == "check":
suite = unittest.TestLoader().loadTestsFromTestCase(SanityTests)
- result = unittest.TextTestRunner(verbosity=2).run(suite)
+ result = unittest.TextTestRunner().run(suite)
sys.exit(not result.wasSuccessful())
elif arguments.command == "flatten":
selected_cases = [case for case in cases(collect(arguments.version))]
@@ -166,8 +180,7 @@ def main(arguments):
remotes = {}
for path in collect(REMOTES_DIR):
relative_path = os.path.relpath(path, REMOTES_DIR)
- with open(path) as schema_file:
- remotes[relative_path] = json.load(schema_file)
+ remotes[relative_path] = json.loads(path.read_text())
json.dump(remotes, sys.stdout, indent=4, sort_keys=True)
elif arguments.command == "dump_remotes":
if arguments.update:
@@ -175,11 +188,9 @@ def main(arguments):
try:
shutil.copytree(REMOTES_DIR, arguments.out_dir)
- except OSError as e:
- if e.errno == errno.EEXIST:
- print("%s already exists. Aborting." % arguments.out_dir)
- sys.exit(1)
- raise
+ except FileExistsError:
+ print(f"{arguments.out_dir} already exists. Aborting.")
+ sys.exit(1)
elif arguments.command == "serve":
try:
import flask
diff --git a/json/package.json b/json/package.json
new file mode 100644
index 0000000..75da9e2
--- /dev/null
+++ b/json/package.json
@@ -0,0 +1,12 @@
+{
+ "name": "json-schema-test-suite",
+ "version": "0.1.0",
+ "description": "A language agnostic test suite for the JSON Schema specifications",
+ "repository": "github:json-schema-org/JSON-Schema-Test-Suite",
+ "keywords": [
+ "json-schema",
+ "tests"
+ ],
+ "author": "http://json-schema.org",
+ "license": "MIT"
+}
diff --git a/json/tests/draft-next/additionalProperties.json b/json/tests/draft-next/additionalProperties.json
index 381275a..98b8842 100644
--- a/json/tests/draft-next/additionalProperties.json
+++ b/json/tests/draft-next/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/contains.json b/json/tests/draft-next/contains.json
index 4fca81a..5f3d05a 100644
--- a/json/tests/draft-next/contains.json
+++ b/json/tests/draft-next/contains.json
@@ -237,5 +237,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "contains should properly handle null data",
+ "schema": {
+ "contains": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/items.json b/json/tests/draft-next/items.json
index b918194..1f0bdcf 100644
--- a/json/tests/draft-next/items.json
+++ b/json/tests/draft-next/items.json
@@ -252,5 +252,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/patternProperties.json b/json/tests/draft-next/patternProperties.json
index c10ffcc..34b2e85 100644
--- a/json/tests/draft-next/patternProperties.json
+++ b/json/tests/draft-next/patternProperties.json
@@ -152,5 +152,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/prefixItems.json b/json/tests/draft-next/prefixItems.json
index 7d0571e..f72da11 100644
--- a/json/tests/draft-next/prefixItems.json
+++ b/json/tests/draft-next/prefixItems.json
@@ -77,5 +77,22 @@
"valid": true
}
]
+ },
+ {
+ "description": "prefixItems should properly handle null data",
+ "schema": {
+ "prefixItems": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/properties.json b/json/tests/draft-next/properties.json
index b86c181..8c3ed35 100644
--- a/json/tests/draft-next/properties.json
+++ b/json/tests/draft-next/properties.json
@@ -163,5 +163,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft-next/unevaluatedItems.json b/json/tests/draft-next/unevaluatedItems.json
index fbd4b48..eedb19f 100644
--- a/json/tests/draft-next/unevaluatedItems.json
+++ b/json/tests/draft-next/unevaluatedItems.json
@@ -625,5 +625,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "unevaluatedItems should properly handle null data",
+ "schema": {
+ "unevaluatedItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/additionalItems.json b/json/tests/draft2019-09/additionalItems.json
index 784bc84..454142b 100644
--- a/json/tests/draft2019-09/additionalItems.json
+++ b/json/tests/draft2019-09/additionalItems.json
@@ -145,5 +145,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalItems should properly handle null data",
+ "schema": {
+ "additionalItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/additionalProperties.json b/json/tests/draft2019-09/additionalProperties.json
index 381275a..98b8842 100644
--- a/json/tests/draft2019-09/additionalProperties.json
+++ b/json/tests/draft2019-09/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/contains.json b/json/tests/draft2019-09/contains.json
index 215da98..a6add6b 100644
--- a/json/tests/draft2019-09/contains.json
+++ b/json/tests/draft2019-09/contains.json
@@ -146,5 +146,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "contains should properly handle null data",
+ "schema": {
+ "contains": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/items.json b/json/tests/draft2019-09/items.json
index 6e98ee8..58992fc 100644
--- a/json/tests/draft2019-09/items.json
+++ b/json/tests/draft2019-09/items.json
@@ -246,5 +246,37 @@
"valid": false
}
]
+ },
+ {
+ "description": "single-form items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "array-form items should properly handle null data",
+ "schema": {
+ "items": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/patternProperties.json b/json/tests/draft2019-09/patternProperties.json
index c10ffcc..34b2e85 100644
--- a/json/tests/draft2019-09/patternProperties.json
+++ b/json/tests/draft2019-09/patternProperties.json
@@ -152,5 +152,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/properties.json b/json/tests/draft2019-09/properties.json
index b86c181..8c3ed35 100644
--- a/json/tests/draft2019-09/properties.json
+++ b/json/tests/draft2019-09/properties.json
@@ -163,5 +163,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/unevaluatedItems.json b/json/tests/draft2019-09/unevaluatedItems.json
index b084986..3bf8483 100644
--- a/json/tests/draft2019-09/unevaluatedItems.json
+++ b/json/tests/draft2019-09/unevaluatedItems.json
@@ -515,5 +515,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "unevaluatedItems should properly handle null data",
+ "schema": {
+ "unevaluatedItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/unevaluatedProperties.json b/json/tests/draft2019-09/unevaluatedProperties.json
index 6384cb8..894f683 100644
--- a/json/tests/draft2019-09/unevaluatedProperties.json
+++ b/json/tests/draft2019-09/unevaluatedProperties.json
@@ -1343,5 +1343,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "unevaluatedProperties should properly handle null data",
+ "schema": {
+ "unevaluatedProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/additionalProperties.json b/json/tests/draft2020-12/additionalProperties.json
index 381275a..98b8842 100644
--- a/json/tests/draft2020-12/additionalProperties.json
+++ b/json/tests/draft2020-12/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/contains.json b/json/tests/draft2020-12/contains.json
index 215da98..a6add6b 100644
--- a/json/tests/draft2020-12/contains.json
+++ b/json/tests/draft2020-12/contains.json
@@ -146,5 +146,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "contains should properly handle null data",
+ "schema": {
+ "contains": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/items.json b/json/tests/draft2020-12/items.json
index b918194..1f0bdcf 100644
--- a/json/tests/draft2020-12/items.json
+++ b/json/tests/draft2020-12/items.json
@@ -252,5 +252,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/patternProperties.json b/json/tests/draft2020-12/patternProperties.json
index c10ffcc..34b2e85 100644
--- a/json/tests/draft2020-12/patternProperties.json
+++ b/json/tests/draft2020-12/patternProperties.json
@@ -152,5 +152,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/prefixItems.json b/json/tests/draft2020-12/prefixItems.json
index 7d0571e..f72da11 100644
--- a/json/tests/draft2020-12/prefixItems.json
+++ b/json/tests/draft2020-12/prefixItems.json
@@ -77,5 +77,22 @@
"valid": true
}
]
+ },
+ {
+ "description": "prefixItems should properly handle null data",
+ "schema": {
+ "prefixItems": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/properties.json b/json/tests/draft2020-12/properties.json
index b86c181..8c3ed35 100644
--- a/json/tests/draft2020-12/properties.json
+++ b/json/tests/draft2020-12/properties.json
@@ -163,5 +163,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/unevaluatedItems.json b/json/tests/draft2020-12/unevaluatedItems.json
index fbd4b48..eedb19f 100644
--- a/json/tests/draft2020-12/unevaluatedItems.json
+++ b/json/tests/draft2020-12/unevaluatedItems.json
@@ -625,5 +625,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "unevaluatedItems should properly handle null data",
+ "schema": {
+ "unevaluatedItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft2020-12/unevaluatedProperties.json b/json/tests/draft2020-12/unevaluatedProperties.json
index 6384cb8..894f683 100644
--- a/json/tests/draft2020-12/unevaluatedProperties.json
+++ b/json/tests/draft2020-12/unevaluatedProperties.json
@@ -1343,5 +1343,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "unevaluatedProperties should properly handle null data",
+ "schema": {
+ "unevaluatedProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft3/additionalItems.json b/json/tests/draft3/additionalItems.json
index 910f1d6..24b1d86 100644
--- a/json/tests/draft3/additionalItems.json
+++ b/json/tests/draft3/additionalItems.json
@@ -109,5 +109,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "additionalItems should properly handle null data",
+ "schema": {
+ "additionalItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft3/additionalProperties.json b/json/tests/draft3/additionalProperties.json
index 4620618..0a33b3b 100644
--- a/json/tests/draft3/additionalProperties.json
+++ b/json/tests/draft3/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft3/items.json b/json/tests/draft3/items.json
index f5e18a1..586a559 100644
--- a/json/tests/draft3/items.json
+++ b/json/tests/draft3/items.json
@@ -42,5 +42,37 @@
"valid": false
}
]
+ },
+ {
+ "description": "single-form items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "array-form items should properly handle null data",
+ "schema": {
+ "items": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft3/patternProperties.json b/json/tests/draft3/patternProperties.json
index 2ca9aae..71954fd 100644
--- a/json/tests/draft3/patternProperties.json
+++ b/json/tests/draft3/patternProperties.json
@@ -111,5 +111,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft3/properties.json b/json/tests/draft3/properties.json
index a830c67..5b6a833 100644
--- a/json/tests/draft3/properties.json
+++ b/json/tests/draft3/properties.json
@@ -93,5 +93,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/additionalItems.json b/json/tests/draft4/additionalItems.json
index 784bc84..454142b 100644
--- a/json/tests/draft4/additionalItems.json
+++ b/json/tests/draft4/additionalItems.json
@@ -145,5 +145,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalItems should properly handle null data",
+ "schema": {
+ "additionalItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/additionalProperties.json b/json/tests/draft4/additionalProperties.json
index 381275a..98b8842 100644
--- a/json/tests/draft4/additionalProperties.json
+++ b/json/tests/draft4/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/items.json b/json/tests/draft4/items.json
index 7bf9f02..89801db 100644
--- a/json/tests/draft4/items.json
+++ b/json/tests/draft4/items.json
@@ -191,5 +191,37 @@
"valid": false
}
]
+ },
+ {
+ "description": "single-form items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "array-form items should properly handle null data",
+ "schema": {
+ "items": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/patternProperties.json b/json/tests/draft4/patternProperties.json
index 5f741df..0511763 100644
--- a/json/tests/draft4/patternProperties.json
+++ b/json/tests/draft4/patternProperties.json
@@ -116,5 +116,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft4/properties.json b/json/tests/draft4/properties.json
index 688527b..9fcb601 100644
--- a/json/tests/draft4/properties.json
+++ b/json/tests/draft4/properties.json
@@ -132,5 +132,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/additionalItems.json b/json/tests/draft6/additionalItems.json
index 784bc84..454142b 100644
--- a/json/tests/draft6/additionalItems.json
+++ b/json/tests/draft6/additionalItems.json
@@ -145,5 +145,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalItems should properly handle null data",
+ "schema": {
+ "additionalItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/additionalProperties.json b/json/tests/draft6/additionalProperties.json
index 381275a..98b8842 100644
--- a/json/tests/draft6/additionalProperties.json
+++ b/json/tests/draft6/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/contains.json b/json/tests/draft6/contains.json
index c5471cc..be87c97 100644
--- a/json/tests/draft6/contains.json
+++ b/json/tests/draft6/contains.json
@@ -125,5 +125,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "contains should properly handle null data",
+ "schema": {
+ "contains": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/items.json b/json/tests/draft6/items.json
index 67f1184..dc56e7c 100644
--- a/json/tests/draft6/items.json
+++ b/json/tests/draft6/items.json
@@ -246,5 +246,37 @@
"valid": false
}
]
+ },
+ {
+ "description": "single-form items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "array-form items should properly handle null data",
+ "schema": {
+ "items": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/patternProperties.json b/json/tests/draft6/patternProperties.json
index c10ffcc..34b2e85 100644
--- a/json/tests/draft6/patternProperties.json
+++ b/json/tests/draft6/patternProperties.json
@@ -152,5 +152,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft6/properties.json b/json/tests/draft6/properties.json
index b86c181..8c3ed35 100644
--- a/json/tests/draft6/properties.json
+++ b/json/tests/draft6/properties.json
@@ -163,5 +163,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/additionalItems.json b/json/tests/draft7/additionalItems.json
index 784bc84..454142b 100644
--- a/json/tests/draft7/additionalItems.json
+++ b/json/tests/draft7/additionalItems.json
@@ -145,5 +145,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalItems should properly handle null data",
+ "schema": {
+ "additionalItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/additionalProperties.json b/json/tests/draft7/additionalProperties.json
index 381275a..98b8842 100644
--- a/json/tests/draft7/additionalProperties.json
+++ b/json/tests/draft7/additionalProperties.json
@@ -129,5 +129,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "additionalProperties should properly handle null data",
+ "schema": {
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/contains.json b/json/tests/draft7/contains.json
index 215da98..b1c36a4 100644
--- a/json/tests/draft7/contains.json
+++ b/json/tests/draft7/contains.json
@@ -146,5 +146,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "contains should properly handle null data",
+ "schema": {
+ "contains": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/items.json b/json/tests/draft7/items.json
index 67f1184..dc56e7c 100644
--- a/json/tests/draft7/items.json
+++ b/json/tests/draft7/items.json
@@ -246,5 +246,37 @@
"valid": false
}
]
+ },
+ {
+ "description": "single-form items should properly handle null data",
+ "schema": {
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "array-form items should properly handle null data",
+ "schema": {
+ "items": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "null items allowed",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/patternProperties.json b/json/tests/draft7/patternProperties.json
index c10ffcc..34b2e85 100644
--- a/json/tests/draft7/patternProperties.json
+++ b/json/tests/draft7/patternProperties.json
@@ -152,5 +152,20 @@
"valid": true
}
]
+ },
+ {
+ "description": "patternProperties should properly handle null data",
+ "schema": {
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
}
]
diff --git a/json/tests/draft7/properties.json b/json/tests/draft7/properties.json
index b86c181..8c3ed35 100644
--- a/json/tests/draft7/properties.json
+++ b/json/tests/draft7/properties.json
@@ -163,5 +163,20 @@
"valid": false
}
]
+ },
+ {
+ "description": "properties should properly handle null data",
+ "schema": {
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "null properties allowed",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
}
]