diff --git a/json/.github/CODEOWNERS b/json/.github/CODEOWNERS new file mode 100644 index 000000000..15f4a2dbc --- /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 1de5391dd..d9cc16543 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 19dc65e97..a859dcf23 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 000000000..75da9e29b --- /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 381275a59..98b88422f 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 4fca81ada..5f3d05abc 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 b91819452..1f0bdcfd1 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 c10ffcc05..34b2e8531 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 7d0571ed9..f72da1165 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 b86c18198..8c3ed35ba 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 fbd4b48a4..eedb19f34 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 784bc8461..454142bab 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 381275a59..98b88422f 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 215da98e8..a6add6bfe 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 6e98ee82d..58992fcf5 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 c10ffcc05..34b2e8531 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 b86c18198..8c3ed35ba 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 b084986b6..3bf8483b0 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 6384cb803..894f68399 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 381275a59..98b88422f 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 215da98e8..a6add6bfe 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 b91819452..1f0bdcfd1 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 c10ffcc05..34b2e8531 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 7d0571ed9..f72da1165 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 b86c18198..8c3ed35ba 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 fbd4b48a4..eedb19f34 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 6384cb803..894f68399 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 910f1d66d..24b1d8656 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 46206181d..0a33b3bbb 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 f5e18a138..586a55973 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 2ca9aaebd..71954fd5a 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 a830c67e7..5b6a833e4 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 784bc8461..454142bab 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 381275a59..98b88422f 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 7bf9f02ba..89801db6d 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 5f741dfca..051176319 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 688527bc6..9fcb6012e 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 784bc8461..454142bab 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 381275a59..98b88422f 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 c5471cc02..be87c9704 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 67f11840a..dc56e7cdc 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 c10ffcc05..34b2e8531 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 b86c18198..8c3ed35ba 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 784bc8461..454142bab 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 381275a59..98b88422f 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 215da98e8..b1c36a41c 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 67f11840a..dc56e7cdc 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 c10ffcc05..34b2e8531 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 b86c18198..8c3ed35ba 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 + } + ] } ]