From 20f025d740bf69b7d119fa04674e15f377acc6d5 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Tue, 29 Apr 2025 12:01:10 +0200 Subject: [PATCH 1/6] Add helper function --- jsonschema/_utils.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py index 54d28c04..94830efb 100644 --- a/jsonschema/_utils.py +++ b/jsonschema/_utils.py @@ -270,6 +270,10 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema): return [] evaluated_keys = [] + def is_valid(errs_it): + """Whether there are no errors in the given iterator.""" + return next(errs_it, None) is None + ref = schema.get("$ref") if ref is not None: resolved = validator._resolver.lookup(ref) @@ -326,13 +330,12 @@ def find_evaluated_property_keys_by_schema(validator, instance, schema): ) for keyword in ["allOf", "oneOf", "anyOf"]: - if keyword in schema: - for subschema in schema[keyword]: - errs = next(validator.descend(instance, subschema), None) - if errs is None: - evaluated_keys += find_evaluated_property_keys_by_schema( - validator, instance, subschema, - ) + for subschema in schema.get(keyword, []): + if not is_valid(validator.descend(instance, subschema)): + continue + evaluated_keys += find_evaluated_property_keys_by_schema( + validator, instance, subschema, + ) if "if" in schema: if validator.evolve(schema=schema["if"]).is_valid(instance): From 75218a4c4632ecafa722724fd338dc3598625764 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Tue, 29 Apr 2025 12:01:10 +0200 Subject: [PATCH 2/6] Add test for unevaluatedProperties --- jsonschema/tests/test_validators.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 28cc4027..309229ee 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -742,6 +742,14 @@ def test_unevaluated_properties_on_invalid_type(self): message = self.message_for(instance="foo", schema=schema) self.assertEqual(message, "'foo' is not of type 'object'") + def test_unevaluated_properties_with_additional_properties(self): + schema = { + "additionalProperties": {"type": "string"}, + "unevaluatedProperties": False, + } + validator = validators._LATEST_VERSION(schema) + validator.validate(instance={"foo": "foo"}) + def test_single_item(self): schema = {"prefixItems": [{}], "items": False} message = self.message_for( From fb57921bcc37ce969550452e1b30351c476e24e5 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Tue, 29 Apr 2025 12:01:10 +0200 Subject: [PATCH 3/6] Fix calculation of evaluated properties --- jsonschema/_utils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/jsonschema/_utils.py b/jsonschema/_utils.py index 94830efb..61defd30 100644 --- a/jsonschema/_utils.py +++ b/jsonschema/_utils.py @@ -302,18 +302,18 @@ def is_valid(errs_it): ), ) - for keyword in [ - "properties", "additionalProperties", "unevaluatedProperties", - ]: - if keyword in schema: - schema_value = schema[keyword] - if validator.is_type(schema_value, "boolean") and schema_value: - evaluated_keys += instance.keys() - - elif validator.is_type(schema_value, "object"): - for property in schema_value: - if property in instance: - evaluated_keys.append(property) + properties = schema.get("properties") + if validator.is_type(properties, "object"): + evaluated_keys += properties.keys() & instance.keys() + + for keyword in ["additionalProperties", "unevaluatedProperties"]: + if (subschema := schema.get(keyword)) is None: + continue + evaluated_keys += ( + key + for key, value in instance.items() + if is_valid(validator.descend(value, subschema)) + ) if "patternProperties" in schema: for property in instance: From ef71f1be9b59cc7d6e799acdc0598d45c4f1c144 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Tue, 29 Apr 2025 12:01:54 +0200 Subject: [PATCH 4/6] Squashed 'json/' changes from 83e866b4..ab3924a6 REVERT: 83e866b4 Merge pull request #763 from michaelmior/propertynames-const REVERT: c5a9703f Merge pull request #760 from OptimumCode/rfc3490-label-separator REVERT: b4c09b65 Add tests for propertyNames with const/enum REVERT: 4fa572d8 Move tests for rfc3490#3.1 into a separate test case REVERT: ce9f68ca Add link to rfc and quote REVERT: ad94cacc Add test cases for other valid label separators in IDN hostnames REVERT: 39002ae7 Merge pull request #762 from OptimumCode/rfc-html-link REVERT: c8780535 Correct section anchor for rfc URL template REVERT: 5f2ca7d6 Modify rfc url template to use html version REVERT: 9c5d99b6 Merge pull request #761 from OptimumCode/annotation-script-rfc-support REVERT: 9563ce7b Correct rfc URL template - incorrect path pattern was used REVERT: 961bfad0 Correct spec kind extraction from defined key. Continue on unkown URL kind REVERT: e524505b Merge pull request #759 from sirosen/hostname-format-reject-single-dot REVERT: 4a3efd18 Add negative tests for "." for hostname formats REVERT: 4ba013d5 Merge pull request #747 from santhosh-tekuri/duration REVERT: aa500e80 Merge pull request #749 from json-schema-org/gregsdennis/json-everything-update REVERT: eb8ce976 Merge pull request #757 from ajevans99/main REVERT: dcdae5c0 Merge pull request #758 from sirosen/hostname-format-check-empty-string REVERT: db21d21b Merge branch 'main' into hostname-format-check-empty-string REVERT: 3fd78f04 Merge pull request #1 from ajevans99/swift-json-schema REVERT: 3cada3a9 Update README.md REVERT: 82a07749 Merge pull request #753 from json-schema-org/ether/fix-draft-locations REVERT: a66d23d4 move draft-specific files to the dedicated dir for its draft REVERT: 8ef15501 Merge pull request #751 from big-andy-coates/format_tests_under_format REVERT: fe1b1392 All format test cases should be under the `format` directory. REVERT: b1ee90f6 json-everything moved to an org REVERT: c00a3f94 test: duration format must start with P REVERT: 9fc880bf Merge pull request #740 from notEthan/format-pattern-control-char REVERT: cbd48ea5 Simplify test of \a regex character to test directly against `pattern` schema REVERT: d6f1010a Merge pull request #746 from json-schema-org/annotations REVERT: 4aec22c1 Revert the changes to additionalProperties.json. REVERT: 2dc10671 Move the workflow step title. REVERT: d9ce71ac May as well also show quotes in the annotation. REVERT: 1b719a84 Pick the line after the description when attaching spec annotations. REVERT: 08105151 Markdown is apparently not (yet?) supported in annotations. REVERT: 81645773 Tidy up the specification annotator a bit. REVERT: 38628b79 Make the spec URLs structure a bit easier for internal use. REVERT: 4ebbeaf4 Merge branch 'Era-cell/main' REVERT: e4bd7554 dumbness2 corrected REVERT: d8ade402 inside run REVERT: 57c7c869 changed install location REVERT: 11f8e511 Added installing command in workflow REVERT: f2766616 template library, url loads changes REVERT: c2badb12 Merge pull request #734 from OptimumCode/idn-hostname-arabic-indic-mixed REVERT: dd9599a5 Merge branch 'main' of github.com:json-schema-org/JSON-Schema-Test-Suite REVERT: 5b393436 add pr dependencies action REVERT: 3a509007 Clear existin annotations on same PR REVERT: 23674123 Cases for rfc and iso written separately REVERT: 0b780b2c Corected yaml format REVERT: 2b1ffb74 Best practices followed with optimized code REVERT: e88a2da6 Works for all OS REVERT: 7b40efe4 Base path for neighbouring file? REVERT: 564e6957 Walking through all leaf files REVERT: 7b84fb44 Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-Suite REVERT: 891d0265 First workflow2 REVERT: 1c175195 regex correction REVERT: 96f7683a Final correction2 - file names beautufied REVERT: 5f050a07 Final correction1 REVERT: 77527b63 Stupidity corrected REVERT: eb8fd760 Branch name specified REVERT: 540a269b Log2 REVERT: f29d090a Wrong location sepcification REVERT: 582e12be logging logs check REVERT: df3bdecc path corrected REVERT: c6b937ca Reading all jsons and spec urls added REVERT: cbdd1755 change day2 REVERT: 54f3784a Merge pull request #731 from MeastroZI/main REVERT: 79dc92f1 TOKEN REVERT: ce52852d Python file location changed REVERT: 3558c2c6 Fake add to tests REVERT: eecc7b7a Merge branch 'main' of https://github.com/Era-cell/JSON-Schema-Test-Suite REVERT: 810d148a First workflow2 REVERT: 4eac02c7 First workflow REVERT: ff29264c Merge pull request #741 from harrel56/chore/tabs-to-spaces REVERT: 9f39cf73 use spaces instead of tabs REVERT: 2f3b5f7a Corrected replaced unevaluated with additoinalProperties REVERT: 40bcb8b3 Corrected replaced unevaluated with additoinalProperties REVERT: fa9224d7 Merge pull request #732 from MeastroZI/main2 REVERT: 83bedd5c Changing descriptions REVERT: 49f73429 fixing tests REVERT: e6d6a081 adding more test cases REVERT: 7e6c9be6 changing descriptions REVERT: 959aca92 shifting test REVERT: 605d7d78 Update propertyDependencies.json : test must be tests REVERT: deb82824 test for dependentSchema and propertyDependencies with unevaluatedProperties and additionalProperties REVERT: ea485124 Merge branch 'json-schema-org:main' into main REVERT: 64a3e7b3 Merge pull request #721 from json-schema-org/gregsdennis/dynamicref-skips-resources REVERT: b9f14e64 Fix $schema in new new test REVERT: 3d5048e8 Merge pull request #733 from Era-cell/main REVERT: 4ae14268 Add valid first character to avoid Bidi rule violation REVERT: 2480edba Update additionalProperties.json formatting it REVERT: 6aa79c0b Update additionalProperties.json formatting it REVERT: 3e0139a5 Update tests/draft-next/additionalProperties.json REVERT: 616240b0 Update tests/draft-next/additionalProperties.json REVERT: c5f3e4ea Update tests/draft2020-12/propertyNames.json REVERT: 964efb8e propertyNames doesn't affect additionalProperties, tests exist already for unevaluatedProps REVERT: f08b884c Cases go under additional and unevaluated Properties REVERT: 99864ff6 added tests for propertyNames with additionalProperties/unevaluatedProperties, also with specification property REVERT: 3b5782b6 Update ref.json : changing $Ids REVERT: 546b3561 test for $ref with $recursiveAnchor REVERT: 57617f25 Merge pull request #726 from Era-cell/main REVERT: 51fc69cd meta data and property names constraints added, additional Items: string REVERT: 9b169bed specification takes array of objects having section and quote REVERT: 1362a8cc Pattern for para corrected REVERT: 340116ec Schema of specification in much structured REVERT: 003ac021 Test-schema including sub-schema for scpecification REVERT: 50a20280 adding specification enhancement for additionalProperties REVERT: 604f5f99 Drop tests of `$id` and `$anchor` that just test values against meta-schema `pattern` for those properties REVERT: 9cd64ec9 come on man, save all the files REVERT: f494440e use unique $id in optional tests, too REVERT: 468453b0 use unique $id REVERT: 9ec6d17e fix copy/paste error REVERT: b284f423 add tests for $dynamicRef skipping over resources REVERT: bf0360f4 add $recursiveAnchor to 2019-09 meta-schemas REVERT: 0519d1f0 add $dynamicAnchor to meta-schemas REVERT: b41167c7 Merge pull request #714 from json-schema-org/more-not REVERT: 4221a55a Add tests for not: {} schemas for all values. REVERT: c499d1d2 Merge pull request #713 from spacether/patch-1 REVERT: 24a471bd Update README.md REVERT: 544f7c3d Merge pull request #712 from otto-ifak/main REVERT: 9dad3ebe Add tests for enum with array of bool REVERT: 589a0858 Merge pull request #706 from marksparkza/unevaluated-before-ref REVERT: 64d5cab9 Merge pull request #710 from spacether/patch-1 REVERT: 418cdbd6 Removes idea folder REVERT: e0a9e066 Updates all other tests to mention grapheme/graphemes REVERT: 217bf81b Merge pull request #701 from json-schema-org/ether/dynamicRef-boolean REVERT: 7a3d06d7 I remove a test that doesn't make sense. REVERT: e8bf453d Move tests with ids in non-schemas to optional REVERT: 69136952 Update minLength.json REVERT: d545be21 Fix duplidate identifiers in recently added tests REVERT: 4e9640c8 test when $dynamicRef references a boolean schema REVERT: 3dab98ca Merge pull request #705 from json-schema-org/gregsdennis/remove-contains-objects-tests REVERT: 1d3aa495 remove more maxContains REVERT: 4a2c61e8 Test unevaluatedItems|Properties before $ref REVERT: ec553d76 contains no longer applies to objects REVERT: 0433a2bf Merge pull request #704 from big-andy-coates/clarify-format-requirements REVERT: c685195f Merge pull request #703 from big-andy-coates/link-to-creek-validator-comprison-site REVERT: a46174b0 Add more detail around test runner requirements for `format` tests REVERT: bb1de8a9 The site linked to is a data-driven functional and performance benchmark of JVM based validator implementations. REVERT: d38ddd54 Merge pull request #696 from jdesrosiers/unevaluated-dynamicref REVERT: 5d0c05fa Fix copy/paste error REVERT: 95fe6ca2 Merge pull request #694 from json-schema-org/heterogeneous-additionalItems REVERT: 9c88a0be Merge pull request #697 from json-schema-org/gregsdennis/add-ref-into-known-nonapplicator REVERT: 49222046 Add unevaluted with dynamic ref tests to draft-next REVERT: 8ba1c90d Update unevaluted with dynamic ref to be more likely to catch errors REVERT: fea2cf19 add tests for 2019 and 2020 REVERT: 6695ca38 add optional tests for `$ref`ing into known non-applicator keywords REVERT: 2834c630 Add tests for unevaluated with dynamic reference REVERT: cda4281c Merge pull request #695 from json-schema-org/ether/clean-up-subSchemas REVERT: 7b9f45c2 move subSchemas-defs.json to subSchemas.json REVERT: e41ec0ec remove unused definition files REVERT: 349c5a82 Merge pull request #692 from json-schema-org/ether/fix-subSchemas-refs REVERT: 451baca4 Merge pull request #670 from marksparkza/invalid-output-test REVERT: b8da838a Add tests for heterogeneous arrays with additionalItems REVERT: 6d7a44b7 fix subschema locations and their $refs REVERT: a9a1e2e3 Merge pull request #690 from skryukov/add-ipv4-mask-test REVERT: ba52c48a Merge pull request #689 from skryukov/add-schema-keyword-to-required-tests REVERT: 69b53add Add a test case for ipv4 with netmask REVERT: d0c602a7 Add $schema keyword to required tests REVERT: 20f1f52c Merge pull request #688 from spacether/feat_updates_python_exp_impl REVERT: b087b3ca Updates implmentation REVERT: 4ecd01f3 Merge pull request #687 from swaeberle/check-single-label-idn-hostnames REVERT: 732e7275 test single label IDN hostnames REVERT: 202d5625 test: hostname format check fails on empty string REVERT: ea0b63c9 Remove invalid output tests git-subtree-dir: json git-subtree-split: ab3924a663d2f9e6de844f464d185a70d881b9ed --- .github/workflows/pr-dependencies.yml | 12 - .../show_specification_annotations.yml | 21 -- README.md | 16 +- bin/annotate-specification-links | 140 --------- bin/specification_urls.json | 34 -- output-tests/draft2019-09/content/type.json | 26 ++ output-tests/draft2020-12/content/type.json | 26 ++ .../draft-next/format-assertion-false.json | 1 - remotes/draft-next/format-assertion-true.json | 1 - .../draft-next/metaschema-no-validation.json | 1 - .../metaschema-optional-vocabulary.json | 1 - remotes/draft-next/subSchemas-defs.json | 11 + remotes/draft-next/subSchemas.json | 12 +- .../metaschema-no-validation.json | 1 - .../metaschema-optional-vocabulary.json | 1 - remotes/draft2019-09/subSchemas-defs.json | 11 + remotes/draft2019-09/subSchemas.json | 12 +- .../draft2020-12/format-assertion-false.json | 1 - .../draft2020-12/format-assertion-true.json | 1 - .../metaschema-no-validation.json | 1 - .../metaschema-optional-vocabulary.json | 1 - remotes/draft2020-12/subSchemas-defs.json | 11 + remotes/draft2020-12/subSchemas.json | 12 +- remotes/draft4/subSchemas.json | 10 - remotes/draft6/name.json | 15 - remotes/draft6/ref-and-definitions.json | 11 - remotes/draft6/subSchemas.json | 10 - .../draft7/locationIndependentIdentifier.json | 11 - remotes/draft7/name.json | 15 - remotes/draft7/subSchemas.json | 10 - ... locationIndependentIdentifierDraft4.json} | 0 ...locationIndependentIdentifierPre2019.json} | 0 remotes/{draft4 => }/name.json | 0 remotes/{draft7 => }/ref-and-definitions.json | 2 +- .../subSchemas.json => subSchemas-defs.json} | 4 +- remotes/subSchemas.json | 8 + test-schema.json | 63 ---- tests/draft-next/additionalProperties.json | 92 ------ tests/draft-next/anchor.json | 114 +++++++ tests/draft-next/contains.json | 104 ++++++- tests/draft-next/dependentSchemas.json | 1 - tests/draft-next/dynamicRef.json | 85 ----- tests/draft-next/enum.json | 96 ------ tests/draft-next/id.json | 294 ++++++++++++++++++ tests/draft-next/items.json | 20 -- tests/draft-next/maxContains.json | 50 +++ tests/draft-next/maxLength.json | 2 +- tests/draft-next/minLength.json | 2 +- tests/draft-next/oneOf.json | 2 +- tests/draft-next/optional/anchor.json | 60 ---- tests/draft-next/optional/dynamicRef.json | 56 ---- .../draft-next/optional/ecmascript-regex.json | 14 + .../draft-next/optional/format/duration.json | 5 - .../optional/format/ecmascript-regex.json | 16 - .../draft-next/optional/format/hostname.json | 10 - .../optional/format/idn-hostname.json | 84 +---- tests/draft-next/optional/format/ipv4.json | 5 - tests/draft-next/optional/id.json | 53 ---- .../optional/refOfUnknownKeyword.json | 23 -- tests/draft-next/ref.json | 8 - tests/draft-next/refRemote.json | 20 +- tests/draft-next/unevaluatedItems.json | 73 ----- tests/draft-next/unevaluatedProperties.json | 206 +++--------- .../{optional => }/unknownKeyword.json | 0 tests/draft2019-09/additionalItems.json | 20 -- tests/draft2019-09/additionalProperties.json | 57 ---- tests/draft2019-09/anchor.json | 115 +++++++ tests/draft2019-09/dependentSchemas.json | 1 - tests/draft2019-09/enum.json | 96 ------ tests/draft2019-09/id.json | 294 ++++++++++++++++++ tests/draft2019-09/maxLength.json | 2 +- tests/draft2019-09/minLength.json | 2 +- tests/draft2019-09/not.json | 154 +-------- tests/draft2019-09/oneOf.json | 2 +- tests/draft2019-09/optional/anchor.json | 60 ---- .../optional/format/duration.json | 5 - .../optional/format/hostname.json | 10 - .../optional/format/idn-hostname.json | 84 +---- tests/draft2019-09/optional/format/ipv4.json | 5 - tests/draft2019-09/optional/id.json | 53 ---- .../optional/refOfUnknownKeyword.json | 23 -- tests/draft2019-09/propertyNames.json | 53 ---- tests/draft2019-09/ref.json | 63 +--- tests/draft2019-09/refRemote.json | 20 +- tests/draft2019-09/unevaluatedItems.json | 76 ----- tests/draft2019-09/unevaluatedProperties.json | 129 -------- .../{optional => }/unknownKeyword.json | 0 tests/draft2020-12/additionalProperties.json | 67 +--- tests/draft2020-12/anchor.json | 115 +++++++ tests/draft2020-12/dependentSchemas.json | 1 - tests/draft2020-12/dynamicRef.json | 85 ----- tests/draft2020-12/enum.json | 96 ------ tests/draft2020-12/id.json | 294 ++++++++++++++++++ tests/draft2020-12/items.json | 20 -- tests/draft2020-12/maxLength.json | 2 +- tests/draft2020-12/minLength.json | 2 +- tests/draft2020-12/not.json | 154 +-------- tests/draft2020-12/oneOf.json | 2 +- tests/draft2020-12/optional/anchor.json | 60 ---- tests/draft2020-12/optional/dynamicRef.json | 56 ---- .../optional/ecmascript-regex.json | 14 + .../optional/format/duration.json | 5 - .../optional/format/ecmascript-regex.json | 16 - .../optional/format/hostname.json | 10 - .../optional/format/idn-hostname.json | 84 +---- tests/draft2020-12/optional/format/ipv4.json | 5 - tests/draft2020-12/optional/id.json | 53 ---- .../optional/refOfUnknownKeyword.json | 23 -- tests/draft2020-12/propertyNames.json | 83 ----- tests/draft2020-12/ref.json | 23 +- tests/draft2020-12/refRemote.json | 20 +- tests/draft2020-12/unevaluatedItems.json | 81 +---- tests/draft2020-12/unevaluatedProperties.json | 126 -------- .../{optional => }/unknownKeyword.json | 0 tests/draft3/additionalItems.json | 19 -- tests/draft3/maxLength.json | 2 +- tests/draft3/minLength.json | 2 +- .../{format => }/ecmascript-regex.json | 0 tests/draft3/optional/format/host-name.json | 5 - tests/draft3/refRemote.json | 4 +- tests/draft4/additionalItems.json | 19 -- tests/draft4/enum.json | 84 ----- tests/draft4/{optional => }/id.json | 0 tests/draft4/maxLength.json | 2 +- tests/draft4/minLength.json | 2 +- tests/draft4/not.json | 63 +--- tests/draft4/oneOf.json | 2 +- tests/draft4/optional/format/hostname.json | 10 - tests/draft4/optional/format/ipv4.json | 5 - tests/draft4/refRemote.json | 8 +- tests/draft6/additionalItems.json | 19 -- tests/draft6/enum.json | 84 ----- tests/draft6/{optional => }/id.json | 0 tests/draft6/maxLength.json | 2 +- tests/draft6/minLength.json | 2 +- tests/draft6/not.json | 152 +-------- tests/draft6/oneOf.json | 2 +- tests/draft6/optional/format/hostname.json | 10 - tests/draft6/optional/format/ipv4.json | 5 - tests/draft6/propertyNames.json | 47 --- tests/draft6/refRemote.json | 10 +- .../draft6/{optional => }/unknownKeyword.json | 0 tests/draft7/additionalItems.json | 19 -- tests/draft7/enum.json | 84 ----- tests/draft7/{optional => }/id.json | 0 tests/draft7/maxLength.json | 2 +- tests/draft7/minLength.json | 2 +- tests/draft7/not.json | 152 +-------- tests/draft7/oneOf.json | 2 +- tests/draft7/optional/format/hostname.json | 10 - .../draft7/optional/format/idn-hostname.json | 76 +---- tests/draft7/optional/format/ipv4.json | 5 - tests/draft7/propertyNames.json | 47 --- tests/draft7/refRemote.json | 10 +- .../draft7/{optional => }/unknownKeyword.json | 0 155 files changed, 1663 insertions(+), 4135 deletions(-) delete mode 100644 .github/workflows/pr-dependencies.yml delete mode 100644 .github/workflows/show_specification_annotations.yml delete mode 100755 bin/annotate-specification-links delete mode 100644 bin/specification_urls.json create mode 100644 remotes/draft-next/subSchemas-defs.json create mode 100644 remotes/draft2019-09/subSchemas-defs.json create mode 100644 remotes/draft2020-12/subSchemas-defs.json delete mode 100644 remotes/draft4/subSchemas.json delete mode 100644 remotes/draft6/name.json delete mode 100644 remotes/draft6/ref-and-definitions.json delete mode 100644 remotes/draft6/subSchemas.json delete mode 100644 remotes/draft7/locationIndependentIdentifier.json delete mode 100644 remotes/draft7/name.json delete mode 100644 remotes/draft7/subSchemas.json rename remotes/{draft4/locationIndependentIdentifier.json => locationIndependentIdentifierDraft4.json} (100%) rename remotes/{draft6/locationIndependentIdentifier.json => locationIndependentIdentifierPre2019.json} (100%) rename remotes/{draft4 => }/name.json (100%) rename remotes/{draft7 => }/ref-and-definitions.json (74%) rename remotes/{draft3/subSchemas.json => subSchemas-defs.json} (62%) create mode 100644 remotes/subSchemas.json create mode 100644 tests/draft-next/id.json delete mode 100644 tests/draft-next/optional/anchor.json delete mode 100644 tests/draft-next/optional/dynamicRef.json delete mode 100644 tests/draft-next/optional/format/ecmascript-regex.json delete mode 100644 tests/draft-next/optional/id.json rename tests/draft-next/{optional => }/unknownKeyword.json (100%) create mode 100644 tests/draft2019-09/id.json delete mode 100644 tests/draft2019-09/optional/anchor.json delete mode 100644 tests/draft2019-09/optional/id.json rename tests/draft2019-09/{optional => }/unknownKeyword.json (100%) create mode 100644 tests/draft2020-12/id.json delete mode 100644 tests/draft2020-12/optional/anchor.json delete mode 100644 tests/draft2020-12/optional/dynamicRef.json delete mode 100644 tests/draft2020-12/optional/format/ecmascript-regex.json delete mode 100644 tests/draft2020-12/optional/id.json rename tests/draft2020-12/{optional => }/unknownKeyword.json (100%) rename tests/draft3/optional/{format => }/ecmascript-regex.json (100%) rename tests/draft4/{optional => }/id.json (100%) rename tests/draft6/{optional => }/id.json (100%) rename tests/draft6/{optional => }/unknownKeyword.json (100%) rename tests/draft7/{optional => }/id.json (100%) rename tests/draft7/{optional => }/unknownKeyword.json (100%) diff --git a/.github/workflows/pr-dependencies.yml b/.github/workflows/pr-dependencies.yml deleted file mode 100644 index 34a231dc..00000000 --- a/.github/workflows/pr-dependencies.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Check PR Dependencies - -on: pull_request - -jobs: - check_dependencies: - runs-on: ubuntu-latest - name: Check Dependencies - steps: - - uses: gregsdennis/dependencies-action@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/show_specification_annotations.yml b/.github/workflows/show_specification_annotations.yml deleted file mode 100644 index f7d7b398..00000000 --- a/.github/workflows/show_specification_annotations.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Show Specification Annotations - -on: - pull_request: - paths: - - 'tests/**' - -jobs: - annotate: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Generate Annotations - run: pip install uritemplate && bin/annotate-specification-links diff --git a/README.md b/README.md index 0bcad8e5..cdd5dc8a 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ To test a specific version: * For 2019-09 and later published drafts, implementations that are able to detect the draft of each schema via `$schema` SHOULD be configured to do so * For draft-07 and earlier, draft-next, and implementations unable to detect via `$schema`, implementations MUST be configured to expect the draft matching the test directory name -* Load any remote references [described below](#additional-assumptions) and configure your implementation to retrieve them via their URIs +* Load any remote references [described below](additional-assumptions) and configure your implementation to retrieve them via their URIs * Walk the filesystem tree for that version's subdirectory and for each `.json` file found: * if the file is located in the root of the version directory: @@ -159,7 +159,7 @@ If your implementation supports multiple versions, run the above procedure for e ``` 2. Test cases found within [special subdirectories](#subdirectories-within-each-draft) may require additional configuration to run. - In particular, when running tests within the `optional/format` subdirectory, test runners should configure implementations to enable format validation, where the implementation supports it. + In particular, tests within the `optional/format` subdirectory may require implementations to change the way they treat the `"format"`keyword (particularly on older drafts which did not have a notion of vocabularies). ### Invariants & Guarantees @@ -254,14 +254,12 @@ This suite is being used by: ### Java -* [json-schema-validation-comparison](https://www.creekservice.org/json-schema-validation-comparison/functional) (Comparison site for JVM-based validator implementations) * [json-schema-validator](https://github.com/daveclayton/json-schema-validator) * [everit-org/json-schema](https://github.com/everit-org/json-schema) * [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator) * [Justify](https://github.com/leadpony/justify) * [Snow](https://github.com/ssilverman/snowy-json) * [jsonschemafriend](https://github.com/jimblackler/jsonschemafriend) -* [OpenAPI JSON Schema Generator](https://github.com/openapi-json-schema-tools/openapi-json-schema-generator) ### JavaScript @@ -281,10 +279,6 @@ This suite is being used by: * [ajv](https://github.com/epoberezkin/ajv) * [djv](https://github.com/korzio/djv) -### Kotlin - -* [json-schema-validation-comparison](https://www.creekservice.org/json-schema-validation-comparison/functional) (Comparison site for JVM-based validator implementations) - ### Node.js For node.js developers, the suite is also available as an [npm](https://www.npmjs.com/package/@json-schema-org/tests) package. @@ -293,7 +287,7 @@ Node-specific support is maintained in a [separate repository](https://github.co ### .NET -* [JsonSchema.Net](https://github.com/json-everything/json-everything) +* [JsonSchema.Net](https://github.com/gregsdennis/json-everything) * [Newtonsoft.Json.Schema](https://github.com/JamesNK/Newtonsoft.Json.Schema) ### Perl @@ -319,7 +313,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) -* [OpenAPI JSON Schema Generator](https://github.com/openapi-json-schema-tools/openapi-json-schema-generator) +* [python-experimental, OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python-experimental.md) ### Ruby @@ -333,13 +327,11 @@ Node-specific support is maintained in a [separate repository](https://github.co ### Scala -* [json-schema-validation-comparison](https://www.creekservice.org/json-schema-validation-comparison/functional) (Comparison site for JVM-based validator implementations) * [typed-json](https://github.com/frawa/typed-json) ### Swift * [JSONSchema](https://github.com/kylef/JSONSchema.swift) -* [swift-json-schema](https://github.com/ajevans99/swift-json-schema) If you use it as well, please fork and send a pull request adding yourself to the list :). diff --git a/bin/annotate-specification-links b/bin/annotate-specification-links deleted file mode 100755 index 963768b4..00000000 --- a/bin/annotate-specification-links +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python3 -""" -Annotate pull requests to the GitHub repository with links to specifications. -""" - -from __future__ import annotations - -from pathlib import Path -from typing import Any -import json -import re -import sys - -from uritemplate import URITemplate - - -BIN_DIR = Path(__file__).parent -TESTS = BIN_DIR.parent / "tests" -URLS = json.loads(BIN_DIR.joinpath("specification_urls.json").read_text()) - - -def urls(version: str) -> dict[str, URITemplate]: - """ - Retrieve the version-specific URLs for specifications. - """ - for_version = {**URLS["json-schema"][version], **URLS["external"]} - return {k: URITemplate(v) for k, v in for_version.items()} - - -def annotation( - path: Path, - message: str, - line: int = 1, - level: str = "notice", - **kwargs: Any, -) -> str: - """ - Format a GitHub annotation. - - See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions - for full syntax. - """ - - if kwargs: - additional = "," + ",".join(f"{k}={v}" for k, v in kwargs.items()) - else: - additional = "" - - relative = path.relative_to(TESTS.parent) - return f"::{level} file={relative},line={line}{additional}::{message}\n" - - -def line_number_of(path: Path, case: dict[str, Any]) -> int: - """ - Crudely find the line number of a test case. - """ - with path.open() as file: - description = case["description"] - return next( - (i + 1 for i, line in enumerate(file, 1) if description in line), - 1, - ) - -def extract_kind_and_spec(key: str) -> (str, str): - """ - Extracts specification number and kind from the defined key - """ - can_have_spec = ["rfc", "iso"] - if not any(key.startswith(el) for el in can_have_spec): - return key, "" - number = re.search(r"\d+", key) - spec = "" if number is None else number.group(0) - kind = key.removesuffix(spec) - return kind, spec - - -def main(): - # Clear annotations which may have been emitted by a previous run. - sys.stdout.write("::remove-matcher owner=me::\n") - - for version in TESTS.iterdir(): - if version.name in {"draft-next", "latest"}: - continue - - version_urls = urls(version.name) - - for path in version.rglob("*.json"): - try: - contents = json.loads(path.read_text()) - except json.JSONDecodeError as error: - error = annotation( - level="error", - path=path, - line=error.lineno, - col=error.pos + 1, - title=str(error), - message=f"cannot load {path}" - ) - sys.stdout.write(error) - continue - - for test_case in contents: - specifications = test_case.get("specification") - if specifications is not None: - for each in specifications: - quote = each.pop("quote", "") - (key, section), = each.items() - - (kind, spec) = extract_kind_and_spec(key) - - url_template = version_urls[kind] - if url_template is None: - error = annotation( - level="error", - path=path, - line=line_number_of(path, test_case), - title=f"unsupported template '{kind}'", - message=f"cannot find a URL template for '{kind}'" - ) - sys.stdout.write(error) - continue - - url = url_template.expand( - spec=spec, - section=section, - ) - - message = f"{url}\n\n{quote}" if quote else url - sys.stdout.write( - annotation( - path=path, - line=line_number_of(path, test_case), - title="Specification Link", - message=message, - ), - ) - - -if __name__ == "__main__": - main() diff --git a/bin/specification_urls.json b/bin/specification_urls.json deleted file mode 100644 index e1824999..00000000 --- a/bin/specification_urls.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "json-schema": { - "draft2020-12": { - "core": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-{section}", - "validation": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-{section}" - }, - "draft2019-09": { - "core": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#rfc.section.{section}", - "validation": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-validation-02#rfc.section.{section}" - }, - "draft7": { - "core": "https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.{section}", - "validation": "https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.{section}" - }, - "draft6": { - "core": "https://json-schema.org/draft-06/draft-wright-json-schema-01#rfc.section.{section}", - "validation": "https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.{section}" - }, - "draft4": { - "core": "https://json-schema.org/draft-04/draft-zyp-json-schema-04#rfc.section.{section}", - "validation": "https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.{section}" - }, - "draft3": { - "core": "https://json-schema.org/draft-03/draft-zyp-json-schema-03.pdf" - } - }, - - "external": { - "ecma262": "https://262.ecma-international.org/{section}", - "perl5": "https://perldoc.perl.org/perlre#{section}", - "rfc": "https://www.rfc-editor.org/rfc/rfc{spec}.html#section-{section}", - "iso": "https://www.iso.org/obp/ui" - } -} diff --git a/output-tests/draft2019-09/content/type.json b/output-tests/draft2019-09/content/type.json index 21118fd5..cff77a74 100644 --- a/output-tests/draft2019-09/content/type.json +++ b/output-tests/draft2019-09/content/type.json @@ -31,6 +31,32 @@ "required": ["errors"] } } + }, + { + "description": "correct type yields an output unit", + "data": "a string", + "output": { + "basic": { + "$id": "https://json-schema.org/tests/content/draft2019-09/type/0/tests/1/basic", + "$ref": "/draft/2019-09/output/schema", + "properties": { + "annotations": { + "contains": { + "properties": { + "valid": {"const": true}, + "keywordLocation": {"const": "/type"}, + "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/type/0#/type"}, + "instanceLocation": {"const": ""}, + "annotation": false, + "error": false + }, + "required": ["keywordLocation", "instanceLocation"] + } + } + }, + "required": ["annotations"] + } + } } ] } diff --git a/output-tests/draft2020-12/content/type.json b/output-tests/draft2020-12/content/type.json index 2949a605..710475b2 100644 --- a/output-tests/draft2020-12/content/type.json +++ b/output-tests/draft2020-12/content/type.json @@ -31,6 +31,32 @@ "required": ["errors"] } } + }, + { + "description": "correct type yields an output unit", + "data": "a string", + "output": { + "basic": { + "$id": "https://json-schema.org/tests/content/draft2020-12/type/0/tests/1/basic", + "$ref": "/draft/2020-12/output/schema", + "properties": { + "annotations": { + "contains": { + "properties": { + "valid": {"const": true}, + "keywordLocation": {"const": "/type"}, + "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/type/0#/type"}, + "instanceLocation": {"const": ""}, + "annotation": false, + "error": false + }, + "required": ["keywordLocation", "instanceLocation"] + } + } + }, + "required": ["annotations"] + } + } } ] } diff --git a/remotes/draft-next/format-assertion-false.json b/remotes/draft-next/format-assertion-false.json index 9cbd2a1d..91c86699 100644 --- a/remotes/draft-next/format-assertion-false.json +++ b/remotes/draft-next/format-assertion-false.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/next/vocab/core": true, "https://json-schema.org/draft/next/vocab/format-assertion": false }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/next/meta/core" }, { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } diff --git a/remotes/draft-next/format-assertion-true.json b/remotes/draft-next/format-assertion-true.json index b3ff69f3..a33d1435 100644 --- a/remotes/draft-next/format-assertion-true.json +++ b/remotes/draft-next/format-assertion-true.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/next/vocab/core": true, "https://json-schema.org/draft/next/vocab/format-assertion": true }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/next/meta/core" }, { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } diff --git a/remotes/draft-next/metaschema-no-validation.json b/remotes/draft-next/metaschema-no-validation.json index 90e32a67..c19c9e8a 100644 --- a/remotes/draft-next/metaschema-no-validation.json +++ b/remotes/draft-next/metaschema-no-validation.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/next/vocab/applicator": true, "https://json-schema.org/draft/next/vocab/core": true }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/next/meta/applicator" }, { "$ref": "https://json-schema.org/draft/next/meta/core" } diff --git a/remotes/draft-next/metaschema-optional-vocabulary.json b/remotes/draft-next/metaschema-optional-vocabulary.json index 1af0cad4..e78e531d 100644 --- a/remotes/draft-next/metaschema-optional-vocabulary.json +++ b/remotes/draft-next/metaschema-optional-vocabulary.json @@ -6,7 +6,6 @@ "https://json-schema.org/draft/next/vocab/core": true, "http://localhost:1234/draft/next/vocab/custom": false }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/next/meta/validation" }, { "$ref": "https://json-schema.org/draft/next/meta/core" } diff --git a/remotes/draft-next/subSchemas-defs.json b/remotes/draft-next/subSchemas-defs.json new file mode 100644 index 00000000..75b7583c --- /dev/null +++ b/remotes/draft-next/subSchemas-defs.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://json-schema.org/draft/next/schema", + "$defs": { + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/$defs/integer" + } + } +} diff --git a/remotes/draft-next/subSchemas.json b/remotes/draft-next/subSchemas.json index 75b7583c..575dd00c 100644 --- a/remotes/draft-next/subSchemas.json +++ b/remotes/draft-next/subSchemas.json @@ -1,11 +1,9 @@ { "$schema": "https://json-schema.org/draft/next/schema", - "$defs": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/$defs/integer" - } + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/integer" } } diff --git a/remotes/draft2019-09/metaschema-no-validation.json b/remotes/draft2019-09/metaschema-no-validation.json index 859006c2..494f0abf 100644 --- a/remotes/draft2019-09/metaschema-no-validation.json +++ b/remotes/draft2019-09/metaschema-no-validation.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/2019-09/vocab/applicator": true, "https://json-schema.org/draft/2019-09/vocab/core": true }, - "$recursiveAnchor": true, "allOf": [ { "$ref": "https://json-schema.org/draft/2019-09/meta/applicator" }, { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } diff --git a/remotes/draft2019-09/metaschema-optional-vocabulary.json b/remotes/draft2019-09/metaschema-optional-vocabulary.json index 3a7502a2..968597c4 100644 --- a/remotes/draft2019-09/metaschema-optional-vocabulary.json +++ b/remotes/draft2019-09/metaschema-optional-vocabulary.json @@ -6,7 +6,6 @@ "https://json-schema.org/draft/2019-09/vocab/core": true, "http://localhost:1234/draft/2019-09/vocab/custom": false }, - "$recursiveAnchor": true, "allOf": [ { "$ref": "https://json-schema.org/draft/2019-09/meta/validation" }, { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } diff --git a/remotes/draft2019-09/subSchemas-defs.json b/remotes/draft2019-09/subSchemas-defs.json new file mode 100644 index 00000000..fdfee68d --- /dev/null +++ b/remotes/draft2019-09/subSchemas-defs.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/$defs/integer" + } + } +} diff --git a/remotes/draft2019-09/subSchemas.json b/remotes/draft2019-09/subSchemas.json index fdfee68d..6dea2252 100644 --- a/remotes/draft2019-09/subSchemas.json +++ b/remotes/draft2019-09/subSchemas.json @@ -1,11 +1,9 @@ { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$defs": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/$defs/integer" - } + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/integer" } } diff --git a/remotes/draft2020-12/format-assertion-false.json b/remotes/draft2020-12/format-assertion-false.json index 43a711c9..d6dd645b 100644 --- a/remotes/draft2020-12/format-assertion-false.json +++ b/remotes/draft2020-12/format-assertion-false.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/2020-12/vocab/core": true, "https://json-schema.org/draft/2020-12/vocab/format-assertion": false }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/2020-12/meta/core" }, { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } diff --git a/remotes/draft2020-12/format-assertion-true.json b/remotes/draft2020-12/format-assertion-true.json index 39c6b0ab..bb16d586 100644 --- a/remotes/draft2020-12/format-assertion-true.json +++ b/remotes/draft2020-12/format-assertion-true.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/2020-12/vocab/core": true, "https://json-schema.org/draft/2020-12/vocab/format-assertion": true }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/2020-12/meta/core" }, { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } diff --git a/remotes/draft2020-12/metaschema-no-validation.json b/remotes/draft2020-12/metaschema-no-validation.json index 71be8b5d..85d74b21 100644 --- a/remotes/draft2020-12/metaschema-no-validation.json +++ b/remotes/draft2020-12/metaschema-no-validation.json @@ -5,7 +5,6 @@ "https://json-schema.org/draft/2020-12/vocab/applicator": true, "https://json-schema.org/draft/2020-12/vocab/core": true }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" }, { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } diff --git a/remotes/draft2020-12/metaschema-optional-vocabulary.json b/remotes/draft2020-12/metaschema-optional-vocabulary.json index a6963e54..f38ec281 100644 --- a/remotes/draft2020-12/metaschema-optional-vocabulary.json +++ b/remotes/draft2020-12/metaschema-optional-vocabulary.json @@ -6,7 +6,6 @@ "https://json-schema.org/draft/2020-12/vocab/core": true, "http://localhost:1234/draft/2020-12/vocab/custom": false }, - "$dynamicAnchor": "meta", "allOf": [ { "$ref": "https://json-schema.org/draft/2020-12/meta/validation" }, { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } diff --git a/remotes/draft2020-12/subSchemas-defs.json b/remotes/draft2020-12/subSchemas-defs.json new file mode 100644 index 00000000..1bb4846d --- /dev/null +++ b/remotes/draft2020-12/subSchemas-defs.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/$defs/integer" + } + } +} diff --git a/remotes/draft2020-12/subSchemas.json b/remotes/draft2020-12/subSchemas.json index 1bb4846d..5fca21d8 100644 --- a/remotes/draft2020-12/subSchemas.json +++ b/remotes/draft2020-12/subSchemas.json @@ -1,11 +1,9 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$defs": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/$defs/integer" - } + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/integer" } } diff --git a/remotes/draft4/subSchemas.json b/remotes/draft4/subSchemas.json deleted file mode 100644 index 6e9b3de3..00000000 --- a/remotes/draft4/subSchemas.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "definitions": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/definitions/integer" - } - } -} diff --git a/remotes/draft6/name.json b/remotes/draft6/name.json deleted file mode 100644 index fceacb80..00000000 --- a/remotes/draft6/name.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "definitions": { - "orNull": { - "anyOf": [ - { - "type": "null" - }, - { - "$ref": "#" - } - ] - } - }, - "type": "string" -} diff --git a/remotes/draft6/ref-and-definitions.json b/remotes/draft6/ref-and-definitions.json deleted file mode 100644 index b80deeb7..00000000 --- a/remotes/draft6/ref-and-definitions.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$id": "http://localhost:1234/draft6/ref-and-definitions.json", - "definitions": { - "inner": { - "properties": { - "bar": { "type": "string" } - } - } - }, - "allOf": [ { "$ref": "#/definitions/inner" } ] -} diff --git a/remotes/draft6/subSchemas.json b/remotes/draft6/subSchemas.json deleted file mode 100644 index 6e9b3de3..00000000 --- a/remotes/draft6/subSchemas.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "definitions": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/definitions/integer" - } - } -} diff --git a/remotes/draft7/locationIndependentIdentifier.json b/remotes/draft7/locationIndependentIdentifier.json deleted file mode 100644 index e72815cd..00000000 --- a/remotes/draft7/locationIndependentIdentifier.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "definitions": { - "refToInteger": { - "$ref": "#foo" - }, - "A": { - "$id": "#foo", - "type": "integer" - } - } -} diff --git a/remotes/draft7/name.json b/remotes/draft7/name.json deleted file mode 100644 index fceacb80..00000000 --- a/remotes/draft7/name.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "definitions": { - "orNull": { - "anyOf": [ - { - "type": "null" - }, - { - "$ref": "#" - } - ] - } - }, - "type": "string" -} diff --git a/remotes/draft7/subSchemas.json b/remotes/draft7/subSchemas.json deleted file mode 100644 index 6e9b3de3..00000000 --- a/remotes/draft7/subSchemas.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "definitions": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/definitions/integer" - } - } -} diff --git a/remotes/draft4/locationIndependentIdentifier.json b/remotes/locationIndependentIdentifierDraft4.json similarity index 100% rename from remotes/draft4/locationIndependentIdentifier.json rename to remotes/locationIndependentIdentifierDraft4.json diff --git a/remotes/draft6/locationIndependentIdentifier.json b/remotes/locationIndependentIdentifierPre2019.json similarity index 100% rename from remotes/draft6/locationIndependentIdentifier.json rename to remotes/locationIndependentIdentifierPre2019.json diff --git a/remotes/draft4/name.json b/remotes/name.json similarity index 100% rename from remotes/draft4/name.json rename to remotes/name.json diff --git a/remotes/draft7/ref-and-definitions.json b/remotes/ref-and-definitions.json similarity index 74% rename from remotes/draft7/ref-and-definitions.json rename to remotes/ref-and-definitions.json index d5929380..e0ee802a 100644 --- a/remotes/draft7/ref-and-definitions.json +++ b/remotes/ref-and-definitions.json @@ -1,5 +1,5 @@ { - "$id": "http://localhost:1234/draft7/ref-and-definitions.json", + "$id": "http://localhost:1234/ref-and-definitions.json", "definitions": { "inner": { "properties": { diff --git a/remotes/draft3/subSchemas.json b/remotes/subSchemas-defs.json similarity index 62% rename from remotes/draft3/subSchemas.json rename to remotes/subSchemas-defs.json index 6e9b3de3..50b7b6dc 100644 --- a/remotes/draft3/subSchemas.json +++ b/remotes/subSchemas-defs.json @@ -1,10 +1,10 @@ { - "definitions": { + "$defs": { "integer": { "type": "integer" }, "refToInteger": { - "$ref": "#/definitions/integer" + "$ref": "#/$defs/integer" } } } diff --git a/remotes/subSchemas.json b/remotes/subSchemas.json new file mode 100644 index 00000000..9f8030bc --- /dev/null +++ b/remotes/subSchemas.json @@ -0,0 +1,8 @@ +{ + "integer": { + "type": "integer" + }, + "refToInteger": { + "$ref": "#/integer" + } +} diff --git a/test-schema.json b/test-schema.json index 0087c5e3..83393162 100644 --- a/test-schema.json +++ b/test-schema.json @@ -27,69 +27,6 @@ "type": "array", "items": { "$ref": "#/$defs/test" }, "minItems": 1 - }, - "specification":{ - "description": "A reference to a specification document which defines the behavior tested by this test case. Typically this should be a JSON Schema specification document, though in cases where the JSON Schema specification points to another RFC it should contain *both* the portion of the JSON Schema specification which indicates what RFC (and section) to follow as *well* as information on where in that specification the behavior is specified.", - - "type": "array", - "minItems": 1, - "uniqueItems": true, - "items":{ - "properties": { - "core": { - "description": "A section in official JSON Schema core drafts", - "url": "https://json-schema.org/specification-links", - "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", - "type":"string" - }, - "validation": { - "description": "A section in official JSON Schema validation drafts", - "url": "https://json-schema.org/specification-links", - "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", - "type":"string" - }, - "ecma262": { - "description": "A section in official ECMA 262 specification for defining regular expressions", - "url": "https://262.ecma-international.org/", - "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", - "type":"string" - }, - "perl5": { - "description": "A section name in Perl documentation for defining regular expressions", - "url": "https://perldoc.perl.org/perlre", - "type":"string" - }, - "quote": { - "description": "Quote describing the test case", - "type":"string" - } - }, - "patternProperties": { - "^rfc\\d+$": { - "description": "A section in official RFC for the given rfc number", - "url": "https://www.rfc-editor.org/", - "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", - "type":"string" - }, - "^iso\\d+$": { - "description": "A section in official ISO for the given iso number", - "pattern": "^[0-9a-zA-Z]+(\\.[0-9a-zA-Z]+)*$", - "type": "string" - } - }, - "additionalProperties": { "type": "string" }, - "minProperties": 1, - "propertyNames": { - "oneOf": [ - { - "pattern": "^((iso)|(rfc))[0-9]+$" - }, - { - "enum": [ "core", "validation", "ecma262", "perl5", "quote" ] - } - ] - } - } } }, "additionalProperties": false diff --git a/tests/draft-next/additionalProperties.json b/tests/draft-next/additionalProperties.json index 51b0edad..7859fbbf 100644 --- a/tests/draft-next/additionalProperties.json +++ b/tests/draft-next/additionalProperties.json @@ -152,97 +152,5 @@ "valid": true } ] - }, - { - "description": "additionalProperties with propertyNames", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "propertyNames": { - "maxLength": 5 - }, - "additionalProperties": { - "type": "number" - } - }, - "tests": [ - { - "description": "Valid against both keywords", - "data": { "apple": 4 }, - "valid": true - }, - { - "description": "Valid against propertyNames, but not additionalProperties", - "data": { "fig": 2, "pear": "available" }, - "valid": false - } - ] - }, - { - "description": "propertyDependencies with additionalProperties", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "properties" : {"foo2" : {}}, - "propertyDependencies": { - "foo" : {}, - "foo2": { - "bar": { - "properties": { - "buz": {} - } - } - } - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "additionalProperties doesn't consider propertyDependencies properties" , - "data": {"foo": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see buz even when foo2 is present", - "data": {"foo2": "bar", "buz": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see buz", - "data": {"buz": ""}, - "valid": false - } - ] - }, - { - "description": "dependentSchemas with additionalProperties", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "properties": {"foo2": {}}, - "dependentSchemas": { - "foo": {}, - "foo2": { - "properties": { - "bar": {} - } - } - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "additionalProperties doesn't consider dependentSchemas", - "data": {"foo": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see bar", - "data": {"bar": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see bar even when foo2 is present", - "data": {"foo2": "", "bar": ""}, - "valid": false - } - ] } ] diff --git a/tests/draft-next/anchor.json b/tests/draft-next/anchor.json index 84d4851c..321d8446 100644 --- a/tests/draft-next/anchor.json +++ b/tests/draft-next/anchor.json @@ -81,6 +81,64 @@ } ] }, + { + "description": "$anchor inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an $anchor buried in the enum", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$defs": { + "anchor_in_enum": { + "enum": [ + { + "$anchor": "my_anchor", + "type": "null" + } + ] + }, + "real_identifier_in_schema": { + "$anchor": "my_anchor", + "type": "string" + }, + "zzz_anchor_in_const": { + "const": { + "$anchor": "my_anchor", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/$defs/anchor_in_enum" }, + { "$ref": "#my_anchor" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$anchor": "my_anchor", + "type": "null" + }, + "valid": true + }, + { + "description": "in implementations that strip $anchor, this may match either $def", + "data": { + "type": "null" + }, + "valid": false + }, + { + "description": "match $ref to $anchor", + "data": "a string to match #/$defs/anchor_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to $anchor", + "data": 1, + "valid": false + } + ] + }, { "description": "same $anchor with different base uri", "schema": { @@ -116,5 +174,61 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $anchor property", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$defs": { + "const_not_anchor": { + "const": { + "$anchor": "not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] + }, + { + "description": "invalid anchors", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$ref": "https://json-schema.org/draft/next/schema" + }, + "tests": [ + { + "description": "MUST start with a letter (and not #)", + "data": { "$anchor" : "#foo" }, + "valid": false + }, + { + "description": "JSON pointers are not valid", + "data": { "$anchor" : "/a/b" }, + "valid": false + }, + { + "description": "invalid with valid beginning", + "data": { "$anchor" : "foo#something" }, + "valid": false + } + ] } ] diff --git a/tests/draft-next/contains.json b/tests/draft-next/contains.json index 8539a531..c17f55ee 100644 --- a/tests/draft-next/contains.json +++ b/tests/draft-next/contains.json @@ -31,6 +31,31 @@ "data": [], "valid": false }, + { + "description": "object with property matching schema (5) is valid", + "data": { "a": 3, "b": 4, "c": 5 }, + "valid": true + }, + { + "description": "object with property matching schema (6) is valid", + "data": { "a": 3, "b": 4, "c": 6 }, + "valid": true + }, + { + "description": "object with two properties matching schema (5, 6) is valid", + "data": { "a": 3, "b": 4, "c": 5, "d": 6 }, + "valid": true + }, + { + "description": "object without properties matching schema is invalid", + "data": { "a": 2, "b": 3, "c": 4 }, + "valid": false + }, + { + "description": "empty object is invalid", + "data": {}, + "valid": false + }, { "description": "not array or object is valid", "data": 42, @@ -59,6 +84,21 @@ "description": "array without item 5 is invalid", "data": [1, 2, 3, 4], "valid": false + }, + { + "description": "object with property 5 is valid", + "data": { "a": 3, "b": 4, "c": 5 }, + "valid": true + }, + { + "description": "object with two properties 5 is valid", + "data": { "a": 3, "b": 4, "c": 5, "d": 5 }, + "valid": true + }, + { + "description": "object without property 5 is invalid", + "data": { "a": 1, "b": 2, "c": 3, "d": 4 }, + "valid": false } ] }, @@ -78,6 +118,16 @@ "description": "empty array is invalid", "data": [], "valid": false + }, + { + "description": "any non-empty object is valid", + "data": { "a": "foo" }, + "valid": true + }, + { + "description": "empty object is invalid", + "data": {}, + "valid": false } ] }, @@ -99,28 +149,18 @@ "valid": false }, { - "description": "non-arrays are valid - string", - "data": "contains does not apply to strings", - "valid": true + "description": "any non-empty object is invalid", + "data": ["foo"], + "valid": false }, { - "description": "non-arrays are valid - object", + "description": "empty object is invalid", "data": {}, - "valid": true - }, - { - "description": "non-arrays are valid - number", - "data": 42, - "valid": true - }, - { - "description": "non-arrays are valid - boolean", - "data": false, - "valid": true + "valid": false }, { - "description": "non-arrays are valid - null", - "data": null, + "description": "non-arrays/objects are valid", + "data": "contains does not apply to strings", "valid": true } ] @@ -153,6 +193,26 @@ "description": "matches neither items nor contains", "data": [1, 5], "valid": false + }, + { + "description": "matches additionalProperties, does not match contains", + "data": { "a": 2, "b": 4, "c": 8 }, + "valid": false + }, + { + "description": "does not match additionalProperties, matches contains", + "data": { "a": 3, "b": 6, "c": 9 }, + "valid": false + }, + { + "description": "matches both additionalProperties and contains", + "data": { "a": 6, "b": 12 }, + "valid": true + }, + { + "description": "matches neither additionalProperties nor contains", + "data": { "a": 1, "b": 5 }, + "valid": false } ] }, @@ -175,6 +235,16 @@ "description": "empty array is invalid", "data": [], "valid": false + }, + { + "description": "any non-empty object is valid", + "data": { "a": "foo" }, + "valid": true + }, + { + "description": "empty object is invalid", + "data": {}, + "valid": false } ] }, diff --git a/tests/draft-next/dependentSchemas.json b/tests/draft-next/dependentSchemas.json index 86079c34..8a847759 100644 --- a/tests/draft-next/dependentSchemas.json +++ b/tests/draft-next/dependentSchemas.json @@ -132,7 +132,6 @@ { "description": "dependent subschema incompatible with root", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "properties": { "foo": {} }, diff --git a/tests/draft-next/dynamicRef.json b/tests/draft-next/dynamicRef.json index 30821c5b..428c83b3 100644 --- a/tests/draft-next/dynamicRef.json +++ b/tests/draft-next/dynamicRef.json @@ -612,90 +612,5 @@ "valid": false } ] - }, - { - "description": "$dynamicRef points to a boolean schema", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$defs": { - "true": true, - "false": false - }, - "properties": { - "true": { - "$dynamicRef": "#/$defs/true" - }, - "false": { - "$dynamicRef": "#/$defs/false" - } - } - }, - "tests": [ - { - "description": "follow $dynamicRef to a true schema", - "data": { "true": 1 }, - "valid": true - }, - { - "description": "follow $dynamicRef to a false schema", - "data": { "false": 1 }, - "valid": false - } - ] - }, - { - "description": "$dynamicRef skips over intermediate resources - direct reference", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/main", - "type": "object", - "properties": { - "bar-item": { - "$ref": "item" - } - }, - "$defs": { - "bar": { - "$id": "bar", - "type": "array", - "items": { - "$ref": "item" - }, - "$defs": { - "item": { - "$id": "item", - "type": "object", - "properties": { - "content": { - "$dynamicRef": "#content" - } - }, - "$defs": { - "defaultContent": { - "$dynamicAnchor": "content", - "type": "integer" - } - } - }, - "content": { - "$dynamicAnchor": "content", - "type": "string" - } - } - } - } - }, - "tests": [ - { - "description": "integer property passes", - "data": { "bar-item": { "content": 42 } }, - "valid": true - }, - { - "description": "string property fails", - "data": { "bar-item": { "content": "value" } }, - "valid": false - } - ] } ] diff --git a/tests/draft-next/enum.json b/tests/draft-next/enum.json index e263f390..32e5af01 100644 --- a/tests/draft-next/enum.json +++ b/tests/draft-next/enum.json @@ -168,30 +168,6 @@ } ] }, - { - "description": "enum with [false] does not match [0]", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "enum": [[false]] - }, - "tests": [ - { - "description": "[false] is valid", - "data": [false], - "valid": true - }, - { - "description": "[0] is invalid", - "data": [0], - "valid": false - }, - { - "description": "[0.0] is invalid", - "data": [0.0], - "valid": false - } - ] - }, { "description": "enum with true does not match 1", "schema": { @@ -216,30 +192,6 @@ } ] }, - { - "description": "enum with [true] does not match [1]", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "enum": [[true]] - }, - "tests": [ - { - "description": "[true] is valid", - "data": [true], - "valid": true - }, - { - "description": "[1] is invalid", - "data": [1], - "valid": false - }, - { - "description": "[1.0] is invalid", - "data": [1.0], - "valid": false - } - ] - }, { "description": "enum with 0 does not match false", "schema": { @@ -264,30 +216,6 @@ } ] }, - { - "description": "enum with [0] does not match [false]", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "enum": [[0]] - }, - "tests": [ - { - "description": "[false] is invalid", - "data": [false], - "valid": false - }, - { - "description": "[0] is valid", - "data": [0], - "valid": true - }, - { - "description": "[0.0] is valid", - "data": [0.0], - "valid": true - } - ] - }, { "description": "enum with 1 does not match true", "schema": { @@ -312,30 +240,6 @@ } ] }, - { - "description": "enum with [1] does not match [true]", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "enum": [[1]] - }, - "tests": [ - { - "description": "[true] is invalid", - "data": [true], - "valid": false - }, - { - "description": "[1] is valid", - "data": [1], - "valid": true - }, - { - "description": "[1.0] is valid", - "data": [1.0], - "valid": true - } - ] - }, { "description": "nul characters in strings", "schema": { diff --git a/tests/draft-next/id.json b/tests/draft-next/id.json new file mode 100644 index 00000000..9b3a591f --- /dev/null +++ b/tests/draft-next/id.json @@ -0,0 +1,294 @@ +[ + { + "description": "Invalid use of fragments in location-independent $id", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$ref": "https://json-schema.org/draft/next/schema" + }, + "tests": [ + { + "description": "Identifier name", + "data": { + "$ref": "#foo", + "$defs": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name and no ref", + "data": { + "$defs": { + "A": { "$id": "#foo" } + } + }, + "valid": false + }, + { + "description": "Identifier path", + "data": { + "$ref": "#/a/b", + "$defs": { + "A": { + "$id": "#/a/b", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft-next/bar#foo", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/bar#foo", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier path with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft-next/bar#/a/b", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/bar#/a/b", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft-next/root", + "$ref": "http://localhost:1234/draft-next/nested.json#foo", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#foo", + "type": "integer" + } + } + } + } + }, + "valid": false + }, + { + "description": "Identifier path with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft-next/root", + "$ref": "http://localhost:1234/draft-next/nested.json#/a/b", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#/a/b", + "type": "integer" + } + } + } + } + }, + "valid": false + } + ] + }, + { + "description": "Valid use of empty fragments in location-independent $id", + "comment": "These are allowed but discouraged", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$ref": "https://json-schema.org/draft/next/schema" + }, + "tests": [ + { + "description": "Identifier name with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft-next/bar", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/bar#", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Identifier name with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft-next/root", + "$ref": "http://localhost:1234/draft-next/nested.json#/$defs/B", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#", + "type": "integer" + } + } + } + } + }, + "valid": true + } + ] + }, + { + "description": "Unnormalized $ids are allowed but discouraged", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$ref": "https://json-schema.org/draft/next/schema" + }, + "tests": [ + { + "description": "Unnormalized identifier", + "data": { + "$ref": "http://localhost:1234/draft-next/foo/baz", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/foo/bar/../baz", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier and no ref", + "data": { + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/foo/bar/../baz", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier with empty fragment", + "data": { + "$ref": "http://localhost:1234/draft-next/foo/baz", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/foo/bar/../baz#", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier with empty fragment and no ref", + "data": { + "$defs": { + "A": { + "$id": "http://localhost:1234/draft-next/foo/bar/../baz#", + "type": "integer" + } + } + }, + "valid": true + } + ] + }, + { + "description": "$id inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an $id buried in the enum", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$defs": { + "id_in_enum": { + "enum": [ + { + "$id": "https://localhost:1234/draft-next/id/my_identifier.json", + "type": "null" + } + ] + }, + "real_id_in_schema": { + "$id": "https://localhost:1234/draft-next/id/my_identifier.json", + "type": "string" + }, + "zzz_id_in_const": { + "const": { + "$id": "https://localhost:1234/draft-next/id/my_identifier.json", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/$defs/id_in_enum" }, + { "$ref": "https://localhost:1234/draft-next/id/my_identifier.json" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$id": "https://localhost:1234/draft-next/id/my_identifier.json", + "type": "null" + }, + "valid": true + }, + { + "description": "match $ref to $id", + "data": "a string to match #/$defs/id_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to $id", + "data": 1, + "valid": false + } + ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] + } +] diff --git a/tests/draft-next/items.json b/tests/draft-next/items.json index dfb79af2..459943be 100644 --- a/tests/draft-next/items.json +++ b/tests/draft-next/items.json @@ -265,26 +265,6 @@ } ] }, - { - "description": "items with heterogeneous array", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "prefixItems": [{}], - "items": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "items with null instance elements", "schema": { diff --git a/tests/draft-next/maxContains.json b/tests/draft-next/maxContains.json index 5af6e4c1..7c151575 100644 --- a/tests/draft-next/maxContains.json +++ b/tests/draft-next/maxContains.json @@ -15,6 +15,16 @@ "description": "two items still valid against lone maxContains", "data": [1, 2], "valid": true + }, + { + "description": "one property valid against lone maxContains", + "data": { "a": 1 }, + "valid": true + }, + { + "description": "two properties still valid against lone maxContains", + "data": { "a": 1, "b": 2 }, + "valid": true } ] }, @@ -50,6 +60,31 @@ "description": "some elements match, invalid maxContains", "data": [1, 2, 1], "valid": false + }, + { + "description": "empty object", + "data": {}, + "valid": false + }, + { + "description": "all properties match, valid maxContains", + "data": { "a": 1 }, + "valid": true + }, + { + "description": "all properties match, invalid maxContains", + "data": { "a": 1, "b": 1 }, + "valid": false + }, + { + "description": "some properties match, valid maxContains", + "data": { "a": 1, "b": 2 }, + "valid": true + }, + { + "description": "some properties match, invalid maxContains", + "data": { "a": 1, "b": 2, "c": 1 }, + "valid": false } ] }, @@ -96,6 +131,21 @@ "description": "array with minContains < maxContains < actual", "data": [1, 1, 1, 1], "valid": false + }, + { + "description": "object with actual < minContains < maxContains", + "data": {}, + "valid": false + }, + { + "description": "object with minContains < actual < maxContains", + "data": { "a": 1, "b": 1 }, + "valid": true + }, + { + "description": "object with minContains < maxContains < actual", + "data": { "a": 1, "b": 1, "c": 1, "d": 1 }, + "valid": false } ] } diff --git a/tests/draft-next/maxLength.json b/tests/draft-next/maxLength.json index c88f604e..e09e44ad 100644 --- a/tests/draft-next/maxLength.json +++ b/tests/draft-next/maxLength.json @@ -27,7 +27,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft-next/minLength.json b/tests/draft-next/minLength.json index 52c9c9a1..16022acb 100644 --- a/tests/draft-next/minLength.json +++ b/tests/draft-next/minLength.json @@ -27,7 +27,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft-next/oneOf.json b/tests/draft-next/oneOf.json index 840d1579..e8c07713 100644 --- a/tests/draft-next/oneOf.json +++ b/tests/draft-next/oneOf.json @@ -220,7 +220,7 @@ } ] }, - { + { "description": "oneOf with missing optional property", "schema": { "$schema": "https://json-schema.org/draft/next/schema", diff --git a/tests/draft-next/optional/anchor.json b/tests/draft-next/optional/anchor.json deleted file mode 100644 index 1de0b7a7..00000000 --- a/tests/draft-next/optional/anchor.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "description": "$anchor inside an enum is not a real identifier", - "comment": "the implementation must not be confused by an $anchor buried in the enum", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$defs": { - "anchor_in_enum": { - "enum": [ - { - "$anchor": "my_anchor", - "type": "null" - } - ] - }, - "real_identifier_in_schema": { - "$anchor": "my_anchor", - "type": "string" - }, - "zzz_anchor_in_const": { - "const": { - "$anchor": "my_anchor", - "type": "null" - } - } - }, - "anyOf": [ - { "$ref": "#/$defs/anchor_in_enum" }, - { "$ref": "#my_anchor" } - ] - }, - "tests": [ - { - "description": "exact match to enum, and type matches", - "data": { - "$anchor": "my_anchor", - "type": "null" - }, - "valid": true - }, - { - "description": "in implementations that strip $anchor, this may match either $def", - "data": { - "type": "null" - }, - "valid": false - }, - { - "description": "match $ref to $anchor", - "data": "a string to match #/$defs/anchor_in_enum", - "valid": true - }, - { - "description": "no match on enum or $ref to $anchor", - "data": 1, - "valid": false - } - ] - } -] diff --git a/tests/draft-next/optional/dynamicRef.json b/tests/draft-next/optional/dynamicRef.json deleted file mode 100644 index dcace154..00000000 --- a/tests/draft-next/optional/dynamicRef.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "description": "$dynamicRef skips over intermediate resources - pointer reference across resource boundary", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/optional/main", - "type": "object", - "properties": { - "bar-item": { - "$ref": "bar#/$defs/item" - } - }, - "$defs": { - "bar": { - "$id": "bar", - "type": "array", - "items": { - "$ref": "item" - }, - "$defs": { - "item": { - "$id": "item", - "type": "object", - "properties": { - "content": { - "$dynamicRef": "#content" - } - }, - "$defs": { - "defaultContent": { - "$dynamicAnchor": "content", - "type": "integer" - } - } - }, - "content": { - "$dynamicAnchor": "content", - "type": "string" - } - } - } - } - }, - "tests": [ - { - "description": "integer property passes", - "data": { "bar-item": { "content": 42 } }, - "valid": true - }, - { - "description": "string property fails", - "data": { "bar-item": { "content": "value" } }, - "valid": false - } - ] - }] \ No newline at end of file diff --git a/tests/draft-next/optional/ecmascript-regex.json b/tests/draft-next/optional/ecmascript-regex.json index a1a4f963..27211450 100644 --- a/tests/draft-next/optional/ecmascript-regex.json +++ b/tests/draft-next/optional/ecmascript-regex.json @@ -405,6 +405,20 @@ } ] }, + { + "description": "\\a is not an ECMA 262 control escape", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "$ref": "https://json-schema.org/draft/next/schema" + }, + "tests": [ + { + "description": "when used as a pattern", + "data": { "pattern": "\\a" }, + "valid": false + } + ] + }, { "description": "pattern with non-ASCII digits", "schema": { diff --git a/tests/draft-next/optional/format/duration.json b/tests/draft-next/optional/format/duration.json index c4aa66ba..d5adca20 100644 --- a/tests/draft-next/optional/format/duration.json +++ b/tests/draft-next/optional/format/duration.json @@ -46,11 +46,6 @@ "data": "PT1D", "valid": false }, - { - "description": "must start with P", - "data": "4DT12H30M5S", - "valid": false - }, { "description": "no elements present", "data": "P", diff --git a/tests/draft-next/optional/format/ecmascript-regex.json b/tests/draft-next/optional/format/ecmascript-regex.json deleted file mode 100644 index 1e19c272..00000000 --- a/tests/draft-next/optional/format/ecmascript-regex.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "description": "\\a is not an ECMA 262 control escape", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "format": "regex" - }, - "tests": [ - { - "description": "when used as a pattern", - "data": "\\a", - "valid": false - } - ] - } -] diff --git a/tests/draft-next/optional/format/hostname.json b/tests/draft-next/optional/format/hostname.json index bc3a60dc..bfb30636 100644 --- a/tests/draft-next/optional/format/hostname.json +++ b/tests/draft-next/optional/format/hostname.json @@ -120,16 +120,6 @@ "description": "single label ending with digit", "data": "hostnam3", "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - }, - { - "description": "single dot", - "data": ".", - "valid": false } ] } diff --git a/tests/draft-next/optional/format/idn-hostname.json b/tests/draft-next/optional/format/idn-hostname.json index 1061f424..ee2e792f 100644 --- a/tests/draft-next/optional/format/idn-hostname.json +++ b/tests/draft-next/optional/format/idn-hostname.json @@ -257,7 +257,7 @@ { "description": "Arabic-Indic digits mixed with Extended Arabic-Indic digits", "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8", - "data": "\u0628\u0660\u06f0", + "data": "\u0660\u06f0", "valid": false }, { @@ -301,88 +301,6 @@ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement", "data": "\u0628\u064a\u200c\u0628\u064a", "valid": true - }, - { - "description": "single label", - "data": "hostname", - "valid": true - }, - { - "description": "single label with hyphen", - "data": "host-name", - "valid": true - }, - { - "description": "single label with digits", - "data": "h0stn4me", - "valid": true - }, - { - "description": "single label starting with digit", - "data": "1host", - "valid": true - }, - { - "description": "single label ending with digit", - "data": "hostnam3", - "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - } - ] - }, - { - "description": "validation of separators in internationalized host names", - "specification": [ - {"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"} - ], - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "format": "idn-hostname" - }, - "tests": [ - { - "description": "single dot", - "data": ".", - "valid": false - }, - { - "description": "single ideographic full stop", - "data": "\u3002", - "valid": false - }, - { - "description": "single fullwidth full stop", - "data": "\uff0e", - "valid": false - }, - { - "description": "single halfwidth ideographic full stop", - "data": "\uff61", - "valid": false - }, - { - "description": "dot as label separator", - "data": "a.b", - "valid": true - }, - { - "description": "ideographic full stop as label separator", - "data": "a\u3002b", - "valid": true - }, - { - "description": "fullwidth full stop as label separator", - "data": "a\uff0eb", - "valid": true - }, - { - "description": "halfwidth ideographic full stop as label separator", - "data": "a\uff61b", - "valid": true } ] } diff --git a/tests/draft-next/optional/format/ipv4.json b/tests/draft-next/optional/format/ipv4.json index 2a4bc2b2..e3e94401 100644 --- a/tests/draft-next/optional/format/ipv4.json +++ b/tests/draft-next/optional/format/ipv4.json @@ -81,11 +81,6 @@ "description": "invalid non-ASCII '২' (a Bengali 2)", "data": "1২7.0.0.1", "valid": false - }, - { - "description": "netmask is not a part of ipv4 address", - "data": "192.168.1.0/24", - "valid": false } ] } diff --git a/tests/draft-next/optional/id.json b/tests/draft-next/optional/id.json deleted file mode 100644 index fc26f26c..00000000 --- a/tests/draft-next/optional/id.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "description": "$id inside an enum is not a real identifier", - "comment": "the implementation must not be confused by an $id buried in the enum", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$defs": { - "id_in_enum": { - "enum": [ - { - "$id": "https://localhost:1234/draft-next/id/my_identifier.json", - "type": "null" - } - ] - }, - "real_id_in_schema": { - "$id": "https://localhost:1234/draft-next/id/my_identifier.json", - "type": "string" - }, - "zzz_id_in_const": { - "const": { - "$id": "https://localhost:1234/draft-next/id/my_identifier.json", - "type": "null" - } - } - }, - "anyOf": [ - { "$ref": "#/$defs/id_in_enum" }, - { "$ref": "https://localhost:1234/draft-next/id/my_identifier.json" } - ] - }, - "tests": [ - { - "description": "exact match to enum, and type matches", - "data": { - "$id": "https://localhost:1234/draft-next/id/my_identifier.json", - "type": "null" - }, - "valid": true - }, - { - "description": "match $ref to $id", - "data": "a string to match #/$defs/id_in_enum", - "valid": true - }, - { - "description": "no match on enum or $ref to $id", - "data": 1, - "valid": false - } - ] - } -] diff --git a/tests/draft-next/optional/refOfUnknownKeyword.json b/tests/draft-next/optional/refOfUnknownKeyword.json index c832e09f..489701cd 100644 --- a/tests/draft-next/optional/refOfUnknownKeyword.json +++ b/tests/draft-next/optional/refOfUnknownKeyword.json @@ -42,28 +42,5 @@ "valid": false } ] - }, - { - "description": "reference internals of known non-applicator", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$id": "/base", - "examples": [ - { "type": "string" } - ], - "$ref": "#/examples/0" - }, - "tests": [ - { - "description": "match", - "data": "a string", - "valid": true - }, - { - "description": "mismatch", - "data": 42, - "valid": false - } - ] } ] diff --git a/tests/draft-next/ref.json b/tests/draft-next/ref.json index 8417ce29..1d5f2561 100644 --- a/tests/draft-next/ref.json +++ b/tests/draft-next/ref.json @@ -862,7 +862,6 @@ { "description": "URN ref with nested pointer ref", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", "$defs": { "foo": { @@ -888,7 +887,6 @@ { "description": "ref to if", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$ref": "http://example.com/ref/if", "if": { "$id": "http://example.com/ref/if", @@ -911,7 +909,6 @@ { "description": "ref to then", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$ref": "http://example.com/ref/then", "then": { "$id": "http://example.com/ref/then", @@ -934,7 +931,6 @@ { "description": "ref to else", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$ref": "http://example.com/ref/else", "else": { "$id": "http://example.com/ref/else", @@ -957,7 +953,6 @@ { "description": "ref with absolute-path-reference", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$id": "http://example.com/ref/absref.json", "$defs": { "a": { @@ -987,7 +982,6 @@ { "description": "$id with file URI still resolves pointers - *nix", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$id": "file:///folder/file.json", "$defs": { "foo": { @@ -1012,7 +1006,6 @@ { "description": "$id with file URI still resolves pointers - windows", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$id": "file:///c:/folder/file.json", "$defs": { "foo": { @@ -1037,7 +1030,6 @@ { "description": "empty tokens in $ref json-pointer", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$defs": { "": { "$defs": { diff --git a/tests/draft-next/refRemote.json b/tests/draft-next/refRemote.json index 647fb9f1..9befceb2 100644 --- a/tests/draft-next/refRemote.json +++ b/tests/draft-next/refRemote.json @@ -22,7 +22,7 @@ "description": "fragment within remote ref", "schema": { "$schema": "https://json-schema.org/draft/next/schema", - "$ref": "http://localhost:1234/draft-next/subSchemas.json#/$defs/integer" + "$ref": "http://localhost:1234/draft-next/subSchemas-defs.json#/$defs/integer" }, "tests": [ { @@ -60,7 +60,7 @@ "description": "ref within remote ref", "schema": { "$schema": "https://json-schema.org/draft/next/schema", - "$ref": "http://localhost:1234/draft-next/subSchemas.json#/$defs/refToInteger" + "$ref": "http://localhost:1234/draft-next/subSchemas-defs.json#/$defs/refToInteger" }, "tests": [ { @@ -265,10 +265,7 @@ }, { "description": "remote HTTP ref with different $id", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$ref": "http://localhost:1234/different-id-ref-string.json" - }, + "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"}, "tests": [ { "description": "number is invalid", @@ -284,10 +281,7 @@ }, { "description": "remote HTTP ref with different URN $id", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$ref": "http://localhost:1234/urn-ref-string.json" - }, + "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"}, "tests": [ { "description": "number is invalid", @@ -303,10 +297,7 @@ }, { "description": "remote HTTP ref with nested absolute ref", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$ref": "http://localhost:1234/nested-absolute-ref-to-string.json" - }, + "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"}, "tests": [ { "description": "number is invalid", @@ -323,7 +314,6 @@ { "description": "$ref to $ref finds detached $anchor", "schema": { - "$schema": "https://json-schema.org/draft/next/schema", "$ref": "http://localhost:1234/draft-next/detached-ref.json#/$defs/foo" }, "tests": [ diff --git a/tests/draft-next/unevaluatedItems.json b/tests/draft-next/unevaluatedItems.json index 08f6ef12..7379afb4 100644 --- a/tests/draft-next/unevaluatedItems.json +++ b/tests/draft-next/unevaluatedItems.json @@ -461,79 +461,6 @@ } ] }, - { - "description": "unevaluatedItems before $ref", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "unevaluatedItems": false, - "prefixItems": [ - { "type": "string" } - ], - "$ref": "#/$defs/bar", - "$defs": { - "bar": { - "prefixItems": [ - true, - { "type": "string" } - ] - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": ["foo", "bar"], - "valid": true - }, - { - "description": "with unevaluated items", - "data": ["foo", "bar", "baz"], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with $dynamicRef", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$id": "https://example.com/unevaluated-items-with-dynamic-ref/derived", - - "$ref": "./baseSchema", - - "$defs": { - "derived": { - "$dynamicAnchor": "addons", - "prefixItems": [ - true, - { "type": "string" } - ] - }, - "baseSchema": { - "$id": "./baseSchema", - - "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", - "unevaluatedItems": false, - "type": "array", - "prefixItems": [ - { "type": "string" } - ], - "$dynamicRef": "#addons" - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": ["foo", "bar"], - "valid": true - }, - { - "description": "with unevaluated items", - "data": ["foo", "bar", "baz"], - "valid": false - } - ] - }, { "description": "unevaluatedItems can't see inside cousins", "schema": { diff --git a/tests/draft-next/unevaluatedProperties.json b/tests/draft-next/unevaluatedProperties.json index 13fe6e03..69fe8a00 100644 --- a/tests/draft-next/unevaluatedProperties.json +++ b/tests/draft-next/unevaluatedProperties.json @@ -715,92 +715,6 @@ } ] }, - { - "description": "unevaluatedProperties before $ref", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "type": "object", - "unevaluatedProperties": false, - "properties": { - "foo": { "type": "string" } - }, - "$ref": "#/$defs/bar", - "$defs": { - "bar": { - "properties": { - "bar": { "type": "string" } - } - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with $dynamicRef", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "$id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived", - - "$ref": "./baseSchema", - - "$defs": { - "derived": { - "$dynamicAnchor": "addons", - "properties": { - "bar": { "type": "string" } - } - }, - "baseSchema": { - "$id": "./baseSchema", - - "$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", - "unevaluatedProperties": false, - "type": "object", - "properties": { - "foo": { "type": "string" } - }, - "$dynamicRef": "#addons" - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, { "description": "unevaluatedProperties can't see inside cousins", "schema": { @@ -1451,6 +1365,57 @@ } ] }, + { + "description": "unevaluatedProperties depends on adjacent contains", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "properties": { + "foo": { "type": "number" } + }, + "contains": { "type": "string" }, + "unevaluatedProperties": false + }, + "tests": [ + { + "description": "bar is evaluated by contains", + "data": { "foo": 1, "bar": "foo" }, + "valid": true + }, + { + "description": "contains fails, bar is not evaluated", + "data": { "foo": 1, "bar": 2 }, + "valid": false + }, + { + "description": "contains passes, bar is not evaluated", + "data": { "foo": 1, "bar": 2, "baz": "foo" }, + "valid": false + } + ] + }, + { + "description": "unevaluatedProperties depends on multiple nested contains", + "schema": { + "$schema": "https://json-schema.org/draft/next/schema", + "allOf": [ + { "contains": { "multipleOf": 2 } }, + { "contains": { "multipleOf": 3 } } + ], + "unevaluatedProperties": { "multipleOf": 5 } + }, + "tests": [ + { + "description": "5 not evaluated, passes unevaluatedItems", + "data": { "a": 2, "b": 3, "c": 4, "d": 5, "e": 6 }, + "valid": true + }, + { + "description": "7 not evaluated, fails unevaluatedItems", + "data": { "a": 2, "b": 3, "c": 4, "d": 7, "e": 8 }, + "valid": false + } + ] + }, { "description": "non-object instances are valid", "schema": { @@ -1603,74 +1568,5 @@ "valid": false } ] - }, - { - "description": "propertyDependencies with unevaluatedProperties" , - "schema" : { - "$schema": "https://json-schema.org/draft/next/schema", - "properties" : {"foo2" : {}}, - "propertyDependencies": { - "foo" : {}, - "foo2": { - "bar": { - "properties": { - "buz": {} - } - } - } - }, - "unevaluatedProperties": false - }, - - "tests": [ - { - "description": "unevaluatedProperties doesn't consider propertyDependencies" , - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "unevaluatedProperties sees buz when foo2 is present", - "data": {"foo2": "bar", "buz": ""}, - "valid": true - }, - { - "description": "unevaluatedProperties doesn't see buz when foo2 is absent", - "data": {"buz": ""}, - "valid": false - } - ] - }, - { - "description": "dependentSchemas with unevaluatedProperties", - "schema": { - "$schema": "https://json-schema.org/draft/next/schema", - "properties": {"foo2": {}}, - "dependentSchemas": { - "foo" : {}, - "foo2": { - "properties": { - "bar":{} - } - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "unevaluatedProperties doesn't consider dependentSchemas", - "data": {"foo": ""}, - "valid": false - }, - { - "description": "unevaluatedProperties doesn't see bar when foo2 is absent", - "data": {"bar": ""}, - "valid": false - }, - { - "description": "unevaluatedProperties sees bar when foo2 is present", - "data": {"foo2": "", "bar": ""}, - "valid": true - } - ] } ] diff --git a/tests/draft-next/optional/unknownKeyword.json b/tests/draft-next/unknownKeyword.json similarity index 100% rename from tests/draft-next/optional/unknownKeyword.json rename to tests/draft-next/unknownKeyword.json diff --git a/tests/draft2019-09/additionalItems.json b/tests/draft2019-09/additionalItems.json index 9a7ae4f8..aa44bcb7 100644 --- a/tests/draft2019-09/additionalItems.json +++ b/tests/draft2019-09/additionalItems.json @@ -182,26 +182,6 @@ } ] }, - { - "description": "additionalItems with heterogeneous array", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "items": [{}], - "additionalItems": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "additionalItems with null instance elements", "schema": { diff --git a/tests/draft2019-09/additionalProperties.json b/tests/draft2019-09/additionalProperties.json index 73f9b909..f9f03bb0 100644 --- a/tests/draft2019-09/additionalProperties.json +++ b/tests/draft2019-09/additionalProperties.json @@ -152,62 +152,5 @@ "valid": true } ] - }, - { - "description": "additionalProperties with propertyNames", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "propertyNames": { - "maxLength": 5 - }, - "additionalProperties": { - "type": "number" - } - }, - "tests": [ - { - "description": "Valid against both keywords", - "data": { "apple": 4 }, - "valid": true - }, - { - "description": "Valid against propertyNames, but not additionalProperties", - "data": { "fig": 2, "pear": "available" }, - "valid": false - } - ] - }, - { - "description": "dependentSchemas with additionalProperties", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "properties": {"foo2": {}}, - "dependentSchemas": { - "foo" : {}, - "foo2": { - "properties": { - "bar":{} - } - } - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "additionalProperties doesn't consider dependentSchemas", - "data": {"foo": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see bar", - "data": {"bar": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see bar even when foo2 is present", - "data": { "foo2": "", "bar": ""}, - "valid": false - } - ] } ] diff --git a/tests/draft2019-09/anchor.json b/tests/draft2019-09/anchor.json index bce05e80..5d8c86f1 100644 --- a/tests/draft2019-09/anchor.json +++ b/tests/draft2019-09/anchor.json @@ -81,6 +81,64 @@ } ] }, + { + "description": "$anchor inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an $anchor buried in the enum", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "anchor_in_enum": { + "enum": [ + { + "$anchor": "my_anchor", + "type": "null" + } + ] + }, + "real_identifier_in_schema": { + "$anchor": "my_anchor", + "type": "string" + }, + "zzz_anchor_in_const": { + "const": { + "$anchor": "my_anchor", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/$defs/anchor_in_enum" }, + { "$ref": "#my_anchor" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$anchor": "my_anchor", + "type": "null" + }, + "valid": true + }, + { + "description": "in implementations that strip $anchor, this may match either $def", + "data": { + "type": "null" + }, + "valid": false + }, + { + "description": "match $ref to $anchor", + "data": "a string to match #/$defs/anchor_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to $anchor", + "data": 1, + "valid": false + } + ] + }, { "description": "same $anchor with different base uri", "schema": { @@ -116,5 +174,62 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $anchor property", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "const_not_anchor": { + "const": { + "$anchor": "not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] + }, + { + "description": "invalid anchors", + "comment": "Section 8.2.3", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, + "tests": [ + { + "description": "MUST start with a letter (and not #)", + "data": { "$anchor" : "#foo" }, + "valid": false + }, + { + "description": "JSON pointers are not valid", + "data": { "$anchor" : "/a/b" }, + "valid": false + }, + { + "description": "invalid with valid beginning", + "data": { "$anchor" : "foo#something" }, + "valid": false + } + ] } ] diff --git a/tests/draft2019-09/dependentSchemas.json b/tests/draft2019-09/dependentSchemas.json index c5b8ea05..3577efdf 100644 --- a/tests/draft2019-09/dependentSchemas.json +++ b/tests/draft2019-09/dependentSchemas.json @@ -132,7 +132,6 @@ { "description": "dependent subschema incompatible with root", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "properties": { "foo": {} }, diff --git a/tests/draft2019-09/enum.json b/tests/draft2019-09/enum.json index 1315211e..f9a44a61 100644 --- a/tests/draft2019-09/enum.json +++ b/tests/draft2019-09/enum.json @@ -168,30 +168,6 @@ } ] }, - { - "description": "enum with [false] does not match [0]", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "enum": [[false]] - }, - "tests": [ - { - "description": "[false] is valid", - "data": [false], - "valid": true - }, - { - "description": "[0] is invalid", - "data": [0], - "valid": false - }, - { - "description": "[0.0] is invalid", - "data": [0.0], - "valid": false - } - ] - }, { "description": "enum with true does not match 1", "schema": { @@ -216,30 +192,6 @@ } ] }, - { - "description": "enum with [true] does not match [1]", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "enum": [[true]] - }, - "tests": [ - { - "description": "[true] is valid", - "data": [true], - "valid": true - }, - { - "description": "[1] is invalid", - "data": [1], - "valid": false - }, - { - "description": "[1.0] is invalid", - "data": [1.0], - "valid": false - } - ] - }, { "description": "enum with 0 does not match false", "schema": { @@ -264,30 +216,6 @@ } ] }, - { - "description": "enum with [0] does not match [false]", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "enum": [[0]] - }, - "tests": [ - { - "description": "[false] is invalid", - "data": [false], - "valid": false - }, - { - "description": "[0] is valid", - "data": [0], - "valid": true - }, - { - "description": "[0.0] is valid", - "data": [0.0], - "valid": true - } - ] - }, { "description": "enum with 1 does not match true", "schema": { @@ -312,30 +240,6 @@ } ] }, - { - "description": "enum with [1] does not match [true]", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "enum": [[1]] - }, - "tests": [ - { - "description": "[true] is invalid", - "data": [true], - "valid": false - }, - { - "description": "[1] is valid", - "data": [1], - "valid": true - }, - { - "description": "[1.0] is valid", - "data": [1.0], - "valid": true - } - ] - }, { "description": "nul characters in strings", "schema": { diff --git a/tests/draft2019-09/id.json b/tests/draft2019-09/id.json new file mode 100644 index 00000000..e2e403f0 --- /dev/null +++ b/tests/draft2019-09/id.json @@ -0,0 +1,294 @@ +[ + { + "description": "Invalid use of fragments in location-independent $id", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, + "tests": [ + { + "description": "Identifier name", + "data": { + "$ref": "#foo", + "$defs": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name and no ref", + "data": { + "$defs": { + "A": { "$id": "#foo" } + } + }, + "valid": false + }, + { + "description": "Identifier path", + "data": { + "$ref": "#/a/b", + "$defs": { + "A": { + "$id": "#/a/b", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft2019-09/bar#foo", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/bar#foo", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier path with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft2019-09/bar#/a/b", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/bar#/a/b", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft2019-09/root", + "$ref": "http://localhost:1234/draft2019-09/nested.json#foo", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#foo", + "type": "integer" + } + } + } + } + }, + "valid": false + }, + { + "description": "Identifier path with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft2019-09/root", + "$ref": "http://localhost:1234/draft2019-09/nested.json#/a/b", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#/a/b", + "type": "integer" + } + } + } + } + }, + "valid": false + } + ] + }, + { + "description": "Valid use of empty fragments in location-independent $id", + "comment": "These are allowed but discouraged", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, + "tests": [ + { + "description": "Identifier name with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft2019-09/bar", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/bar#", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Identifier name with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft2019-09/root", + "$ref": "http://localhost:1234/draft2019-09/nested.json#/$defs/B", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#", + "type": "integer" + } + } + } + } + }, + "valid": true + } + ] + }, + { + "description": "Unnormalized $ids are allowed but discouraged", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, + "tests": [ + { + "description": "Unnormalized identifier", + "data": { + "$ref": "http://localhost:1234/draft2019-09/foo/baz", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/foo/bar/../baz", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier and no ref", + "data": { + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/foo/bar/../baz", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier with empty fragment", + "data": { + "$ref": "http://localhost:1234/draft2019-09/foo/baz", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/foo/bar/../baz#", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier with empty fragment and no ref", + "data": { + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2019-09/foo/bar/../baz#", + "type": "integer" + } + } + }, + "valid": true + } + ] + }, + { + "description": "$id inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an $id buried in the enum", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "id_in_enum": { + "enum": [ + { + "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", + "type": "null" + } + ] + }, + "real_id_in_schema": { + "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", + "type": "string" + }, + "zzz_id_in_const": { + "const": { + "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/$defs/id_in_enum" }, + { "$ref": "https://localhost:1234/draft2019-09/id/my_identifier.json" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", + "type": "null" + }, + "valid": true + }, + { + "description": "match $ref to $id", + "data": "a string to match #/$defs/id_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to $id", + "data": 1, + "valid": false + } + ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] + } +] diff --git a/tests/draft2019-09/maxLength.json b/tests/draft2019-09/maxLength.json index a0cc7d9b..f242c3ef 100644 --- a/tests/draft2019-09/maxLength.json +++ b/tests/draft2019-09/maxLength.json @@ -27,7 +27,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft2019-09/minLength.json b/tests/draft2019-09/minLength.json index 12782660..19dec2ca 100644 --- a/tests/draft2019-09/minLength.json +++ b/tests/draft2019-09/minLength.json @@ -27,7 +27,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft2019-09/not.json b/tests/draft2019-09/not.json index d90728c7..62c9af9d 100644 --- a/tests/draft2019-09/not.json +++ b/tests/draft2019-09/not.json @@ -97,173 +97,25 @@ ] }, { - "description": "forbid everything with empty schema", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "not": {} - }, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "forbid everything with boolean schema true", + "description": "not with boolean schema true", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", "not": true }, "tests": [ { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", + "description": "any value is invalid", "data": "foo", "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false } ] }, { - "description": "allow everything with boolean schema false", + "description": "not with boolean schema false", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", "not": false }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "boolean true is valid", - "data": true, - "valid": true - }, - { - "description": "boolean false is valid", - "data": false, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "object is valid", - "data": {"foo": "bar"}, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "array is valid", - "data": ["foo"], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "double negation", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "not": { "not": {} } - }, "tests": [ { "description": "any value is valid", diff --git a/tests/draft2019-09/oneOf.json b/tests/draft2019-09/oneOf.json index c27d4865..9b7a2204 100644 --- a/tests/draft2019-09/oneOf.json +++ b/tests/draft2019-09/oneOf.json @@ -220,7 +220,7 @@ } ] }, - { + { "description": "oneOf with missing optional property", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", diff --git a/tests/draft2019-09/optional/anchor.json b/tests/draft2019-09/optional/anchor.json deleted file mode 100644 index 45951d0a..00000000 --- a/tests/draft2019-09/optional/anchor.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "description": "$anchor inside an enum is not a real identifier", - "comment": "the implementation must not be confused by an $anchor buried in the enum", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$defs": { - "anchor_in_enum": { - "enum": [ - { - "$anchor": "my_anchor", - "type": "null" - } - ] - }, - "real_identifier_in_schema": { - "$anchor": "my_anchor", - "type": "string" - }, - "zzz_anchor_in_const": { - "const": { - "$anchor": "my_anchor", - "type": "null" - } - } - }, - "anyOf": [ - { "$ref": "#/$defs/anchor_in_enum" }, - { "$ref": "#my_anchor" } - ] - }, - "tests": [ - { - "description": "exact match to enum, and type matches", - "data": { - "$anchor": "my_anchor", - "type": "null" - }, - "valid": true - }, - { - "description": "in implementations that strip $anchor, this may match either $def", - "data": { - "type": "null" - }, - "valid": false - }, - { - "description": "match $ref to $anchor", - "data": "a string to match #/$defs/anchor_in_enum", - "valid": true - }, - { - "description": "no match on enum or $ref to $anchor", - "data": 1, - "valid": false - } - ] - } -] diff --git a/tests/draft2019-09/optional/format/duration.json b/tests/draft2019-09/optional/format/duration.json index 2d515a64..00d5f47a 100644 --- a/tests/draft2019-09/optional/format/duration.json +++ b/tests/draft2019-09/optional/format/duration.json @@ -46,11 +46,6 @@ "data": "PT1D", "valid": false }, - { - "description": "must start with P", - "data": "4DT12H30M5S", - "valid": false - }, { "description": "no elements present", "data": "P", diff --git a/tests/draft2019-09/optional/format/hostname.json b/tests/draft2019-09/optional/format/hostname.json index 24bfdfc5..f3b7181c 100644 --- a/tests/draft2019-09/optional/format/hostname.json +++ b/tests/draft2019-09/optional/format/hostname.json @@ -120,16 +120,6 @@ "description": "single label ending with digit", "data": "hostnam3", "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - }, - { - "description": "single dot", - "data": ".", - "valid": false } ] } diff --git a/tests/draft2019-09/optional/format/idn-hostname.json b/tests/draft2019-09/optional/format/idn-hostname.json index 348c504c..72f17975 100644 --- a/tests/draft2019-09/optional/format/idn-hostname.json +++ b/tests/draft2019-09/optional/format/idn-hostname.json @@ -257,7 +257,7 @@ { "description": "Arabic-Indic digits mixed with Extended Arabic-Indic digits", "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8", - "data": "\u0628\u0660\u06f0", + "data": "\u0660\u06f0", "valid": false }, { @@ -301,88 +301,6 @@ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement", "data": "\u0628\u064a\u200c\u0628\u064a", "valid": true - }, - { - "description": "single label", - "data": "hostname", - "valid": true - }, - { - "description": "single label with hyphen", - "data": "host-name", - "valid": true - }, - { - "description": "single label with digits", - "data": "h0stn4me", - "valid": true - }, - { - "description": "single label starting with digit", - "data": "1host", - "valid": true - }, - { - "description": "single label ending with digit", - "data": "hostnam3", - "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - } - ] - }, - { - "description": "validation of separators in internationalized host names", - "specification": [ - {"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"} - ], - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "format": "idn-hostname" - }, - "tests": [ - { - "description": "single dot", - "data": ".", - "valid": false - }, - { - "description": "single ideographic full stop", - "data": "\u3002", - "valid": false - }, - { - "description": "single fullwidth full stop", - "data": "\uff0e", - "valid": false - }, - { - "description": "single halfwidth ideographic full stop", - "data": "\uff61", - "valid": false - }, - { - "description": "dot as label separator", - "data": "a.b", - "valid": true - }, - { - "description": "ideographic full stop as label separator", - "data": "a\u3002b", - "valid": true - }, - { - "description": "fullwidth full stop as label separator", - "data": "a\uff0eb", - "valid": true - }, - { - "description": "halfwidth ideographic full stop as label separator", - "data": "a\uff61b", - "valid": true } ] } diff --git a/tests/draft2019-09/optional/format/ipv4.json b/tests/draft2019-09/optional/format/ipv4.json index efe42471..ac1e14c6 100644 --- a/tests/draft2019-09/optional/format/ipv4.json +++ b/tests/draft2019-09/optional/format/ipv4.json @@ -81,11 +81,6 @@ "description": "invalid non-ASCII '২' (a Bengali 2)", "data": "1২7.0.0.1", "valid": false - }, - { - "description": "netmask is not a part of ipv4 address", - "data": "192.168.1.0/24", - "valid": false } ] } diff --git a/tests/draft2019-09/optional/id.json b/tests/draft2019-09/optional/id.json deleted file mode 100644 index 4daa8f51..00000000 --- a/tests/draft2019-09/optional/id.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "description": "$id inside an enum is not a real identifier", - "comment": "the implementation must not be confused by an $id buried in the enum", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$defs": { - "id_in_enum": { - "enum": [ - { - "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", - "type": "null" - } - ] - }, - "real_id_in_schema": { - "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", - "type": "string" - }, - "zzz_id_in_const": { - "const": { - "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", - "type": "null" - } - } - }, - "anyOf": [ - { "$ref": "#/$defs/id_in_enum" }, - { "$ref": "https://localhost:1234/draft2019-09/id/my_identifier.json" } - ] - }, - "tests": [ - { - "description": "exact match to enum, and type matches", - "data": { - "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", - "type": "null" - }, - "valid": true - }, - { - "description": "match $ref to $id", - "data": "a string to match #/$defs/id_in_enum", - "valid": true - }, - { - "description": "no match on enum or $ref to $id", - "data": 1, - "valid": false - } - ] - } -] diff --git a/tests/draft2019-09/optional/refOfUnknownKeyword.json b/tests/draft2019-09/optional/refOfUnknownKeyword.json index e9a75dd1..eee1c33e 100644 --- a/tests/draft2019-09/optional/refOfUnknownKeyword.json +++ b/tests/draft2019-09/optional/refOfUnknownKeyword.json @@ -42,28 +42,5 @@ "valid": false } ] - }, - { - "description": "reference internals of known non-applicator", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "/base", - "examples": [ - { "type": "string" } - ], - "$ref": "#/examples/0" - }, - "tests": [ - { - "description": "match", - "data": "a string", - "valid": true - }, - { - "description": "mismatch", - "data": 42, - "valid": false - } - ] } ] diff --git a/tests/draft2019-09/propertyNames.json b/tests/draft2019-09/propertyNames.json index 3b2bb23b..b7fecbf7 100644 --- a/tests/draft2019-09/propertyNames.json +++ b/tests/draft2019-09/propertyNames.json @@ -111,58 +111,5 @@ "valid": true } ] - }, - { - "description": "propertyNames with const", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "propertyNames": {"const": "foo"} - }, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"bar": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "propertyNames with enum", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "propertyNames": {"enum": ["foo", "bar"]} - }, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with property foo and bar is valid", - "data": {"foo": 1, "bar": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"baz": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] } ] diff --git a/tests/draft2019-09/ref.json b/tests/draft2019-09/ref.json index eff5305c..7d850414 100644 --- a/tests/draft2019-09/ref.json +++ b/tests/draft2019-09/ref.json @@ -791,6 +791,21 @@ } ] }, + { + "description": "URN base URI with f-component", + "schema": { + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$comment": "RFC 8141 §2.3.3, but we don't allow fragments", + "$ref": "https://json-schema.org/draft/2019-09/schema" + }, + "tests": [ + { + "description": "is invalid", + "data": {"$id": "urn:example:foo-bar-baz-qux#somepart"}, + "valid": false + } + ] + }, { "description": "URN base URI with URN and JSON pointer ref", "schema": { @@ -847,7 +862,6 @@ { "description": "URN ref with nested pointer ref", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", "$defs": { "foo": { @@ -873,7 +887,6 @@ { "description": "ref to if", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$ref": "http://example.com/ref/if", "if": { "$id": "http://example.com/ref/if", @@ -896,7 +909,6 @@ { "description": "ref to then", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$ref": "http://example.com/ref/then", "then": { "$id": "http://example.com/ref/then", @@ -919,7 +931,6 @@ { "description": "ref to else", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$ref": "http://example.com/ref/else", "else": { "$id": "http://example.com/ref/else", @@ -942,7 +953,6 @@ { "description": "ref with absolute-path-reference", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "http://example.com/ref/absref.json", "$defs": { "a": { @@ -972,7 +982,6 @@ { "description": "$id with file URI still resolves pointers - *nix", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "file:///folder/file.json", "$defs": { "foo": { @@ -997,7 +1006,6 @@ { "description": "$id with file URI still resolves pointers - windows", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$id": "file:///c:/folder/file.json", "$defs": { "foo": { @@ -1022,7 +1030,6 @@ { "description": "empty tokens in $ref json-pointer", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$defs": { "": { "$defs": { @@ -1048,43 +1055,5 @@ "valid": false } ] - }, - { - "description": "$ref with $recursiveAnchor", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://example.com/schemas/unevaluated-items-are-disallowed", - "$ref": "/schemas/unevaluated-items-are-allowed", - "$recursiveAnchor": true, - "unevaluatedItems": false, - "$defs": { - "/schemas/unevaluated-items-are-allowed": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "/schemas/unevaluated-items-are-allowed", - "$recursiveAnchor": true, - "type": "array", - "items": [ - { - "type": "string" - }, - { - "$ref": "#" - } - ] - } - } - }, - "tests": [ - { - "description": "extra items allowed for inner arrays", - "data" : ["foo",["bar" , [] , 8]], - "valid": true - }, - { - "description": "extra items disallowed for root", - "data" : ["foo",["bar" , [] , 8], 8], - "valid": false - } - ] - } + } ] diff --git a/tests/draft2019-09/refRemote.json b/tests/draft2019-09/refRemote.json index 072894cf..0bacbfc2 100644 --- a/tests/draft2019-09/refRemote.json +++ b/tests/draft2019-09/refRemote.json @@ -22,7 +22,7 @@ "description": "fragment within remote ref", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$ref": "http://localhost:1234/draft2019-09/subSchemas.json#/$defs/integer" + "$ref": "http://localhost:1234/draft2019-09/subSchemas-defs.json#/$defs/integer" }, "tests": [ { @@ -60,7 +60,7 @@ "description": "ref within remote ref", "schema": { "$schema": "https://json-schema.org/draft/2019-09/schema", - "$ref": "http://localhost:1234/draft2019-09/subSchemas.json#/$defs/refToInteger" + "$ref": "http://localhost:1234/draft2019-09/subSchemas-defs.json#/$defs/refToInteger" }, "tests": [ { @@ -265,10 +265,7 @@ }, { "description": "remote HTTP ref with different $id", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$ref": "http://localhost:1234/different-id-ref-string.json" - }, + "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"}, "tests": [ { "description": "number is invalid", @@ -284,10 +281,7 @@ }, { "description": "remote HTTP ref with different URN $id", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$ref": "http://localhost:1234/urn-ref-string.json" - }, + "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"}, "tests": [ { "description": "number is invalid", @@ -303,10 +297,7 @@ }, { "description": "remote HTTP ref with nested absolute ref", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$ref": "http://localhost:1234/nested-absolute-ref-to-string.json" - }, + "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"}, "tests": [ { "description": "number is invalid", @@ -323,7 +314,6 @@ { "description": "$ref to $ref finds detached $anchor", "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", "$ref": "http://localhost:1234/draft2019-09/detached-ref.json#/$defs/foo" }, "tests": [ diff --git a/tests/draft2019-09/unevaluatedItems.json b/tests/draft2019-09/unevaluatedItems.json index 8e2ee4b1..53565a0b 100644 --- a/tests/draft2019-09/unevaluatedItems.json +++ b/tests/draft2019-09/unevaluatedItems.json @@ -480,82 +480,6 @@ } ] }, - { - "description": "unevaluatedItems before $ref", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "unevaluatedItems": false, - "items": [ - { "type": "string" } - ], - "$ref": "#/$defs/bar", - "$defs": { - "bar": { - "items": [ - true, - { "type": "string" } - ] - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": ["foo", "bar"], - "valid": true - }, - { - "description": "with unevaluated items", - "data": ["foo", "bar", "baz"], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with $recursiveRef", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://example.com/unevaluated-items-with-recursive-ref/extended-tree", - - "$recursiveAnchor": true, - - "$ref": "./tree", - "items": [ - true, - true, - { "type": "string" } - ], - - "$defs": { - "tree": { - "$id": "./tree", - "$recursiveAnchor": true, - - "type": "array", - "items": [ - { "type": "number" }, - { - "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", - "unevaluatedItems": false, - "$recursiveRef": "#" - } - ] - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": [1, [2, [], "b"], "a"], - "valid": true - }, - { - "description": "with unevaluated items", - "data": [1, [2, [], "b", "too many"], "a"], - "valid": false - } - ] - }, { "description": "unevaluatedItems can't see inside cousins", "schema": { diff --git a/tests/draft2019-09/unevaluatedProperties.json b/tests/draft2019-09/unevaluatedProperties.json index e8765112..a6cce8bb 100644 --- a/tests/draft2019-09/unevaluatedProperties.json +++ b/tests/draft2019-09/unevaluatedProperties.json @@ -715,102 +715,6 @@ } ] }, - { - "description": "unevaluatedProperties before $ref", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "type": "object", - "unevaluatedProperties": false, - "properties": { - "foo": { "type": "string" } - }, - "$ref": "#/$defs/bar", - "$defs": { - "bar": { - "properties": { - "bar": { "type": "string" } - } - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with $recursiveRef", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "$id": "https://example.com/unevaluated-properties-with-recursive-ref/extended-tree", - - "$recursiveAnchor": true, - - "$ref": "./tree", - "properties": { - "name": { "type": "string" } - }, - - "$defs": { - "tree": { - "$id": "./tree", - "$recursiveAnchor": true, - - "type": "object", - "properties": { - "node": true, - "branches": { - "$comment": "unevaluatedProperties comes first so it's more likely to bugs errors with implementations that are sensitive to keyword ordering", - "unevaluatedProperties": false, - "$recursiveRef": "#" - } - }, - "required": ["node"] - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "name": "a", - "node": 1, - "branches": { - "name": "b", - "node": 2 - } - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "name": "a", - "node": 1, - "branches": { - "foo": "b", - "node": 2 - } - }, - "valid": false - } - ] - }, { "description": "unevaluatedProperties can't see inside cousins", "schema": { @@ -1567,38 +1471,5 @@ "valid": false } ] - }, - { - "description": "dependentSchemas with unevaluatedProperties", - "schema": { - "$schema": "https://json-schema.org/draft/2019-09/schema", - "properties": {"foo2": {}}, - "dependentSchemas": { - "foo" : {}, - "foo2": { - "properties": { - "bar":{} - } - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "unevaluatedProperties doesn't consider dependentSchemas", - "data": {"foo": ""}, - "valid": false - }, - { - "description": "unevaluatedProperties doesn't see bar when foo2 is absent", - "data": {"bar": ""}, - "valid": false - }, - { - "description": "unevaluatedProperties sees bar when foo2 is present", - "data": { "foo2": "", "bar": ""}, - "valid": true - } - ] } ] diff --git a/tests/draft2019-09/optional/unknownKeyword.json b/tests/draft2019-09/unknownKeyword.json similarity index 100% rename from tests/draft2019-09/optional/unknownKeyword.json rename to tests/draft2019-09/unknownKeyword.json diff --git a/tests/draft2020-12/additionalProperties.json b/tests/draft2020-12/additionalProperties.json index 9618575e..29e69c13 100644 --- a/tests/draft2020-12/additionalProperties.json +++ b/tests/draft2020-12/additionalProperties.json @@ -2,7 +2,6 @@ { "description": "additionalProperties being false does not allow other properties", - "specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema. Boolean \"false\" forbids everything." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}}, @@ -44,7 +43,6 @@ }, { "description": "non-ASCII pattern with additionalProperties", - "specification": [ { "core":"10.3.2.3"} ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "patternProperties": {"^á": {}}, @@ -65,7 +63,6 @@ }, { "description": "additionalProperties with schema", - "specification": [ { "core":"10.3.2.3", "quote": "The value of \"additionalProperties\" MUST be a valid JSON Schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}}, @@ -90,8 +87,8 @@ ] }, { - "description": "additionalProperties can exist by itself", - "specification": [ { "core":"10.3.2.3", "quote": "With no other applicator applying to object instances. This validates all the instance values irrespective of their property names" } ], + "description": + "additionalProperties can exist by itself", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": {"type": "boolean"} @@ -111,7 +108,6 @@ }, { "description": "additionalProperties are allowed by default", - "specification": [ { "core":"10.3.2.3", "quote": "Omitting this keyword has the same assertion behavior as an empty schema." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": {"foo": {}, "bar": {}} @@ -126,7 +122,6 @@ }, { "description": "additionalProperties does not look in applicators", - "specification":[ { "core": "10.2", "quote": "Subschemas of applicator keywords evaluate the instance completely independently such that the results of one such subschema MUST NOT impact the results of sibling subschemas." } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "allOf": [ @@ -144,7 +139,6 @@ }, { "description": "additionalProperties with null valued instance properties", - "specification": [ { "core":"10.3.2.3" } ], "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": { @@ -158,62 +152,5 @@ "valid": true } ] - }, - { - "description": "additionalProperties with propertyNames", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "propertyNames": { - "maxLength": 5 - }, - "additionalProperties": { - "type": "number" - } - }, - "tests": [ - { - "description": "Valid against both keywords", - "data": { "apple": 4 }, - "valid": true - }, - { - "description": "Valid against propertyNames, but not additionalProperties", - "data": { "fig": 2, "pear": "available" }, - "valid": false - } - ] - }, - { - "description": "dependentSchemas with additionalProperties", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "properties": {"foo2": {}}, - "dependentSchemas": { - "foo" : {}, - "foo2": { - "properties": { - "bar": {} - } - } - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "additionalProperties doesn't consider dependentSchemas", - "data": {"foo": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see bar", - "data": {"bar": ""}, - "valid": false - }, - { - "description": "additionalProperties can't see bar even when foo2 is present", - "data": {"foo2": "", "bar": ""}, - "valid": false - } - ] } ] diff --git a/tests/draft2020-12/anchor.json b/tests/draft2020-12/anchor.json index 99143fa1..423835da 100644 --- a/tests/draft2020-12/anchor.json +++ b/tests/draft2020-12/anchor.json @@ -81,6 +81,64 @@ } ] }, + { + "description": "$anchor inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an $anchor buried in the enum", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "anchor_in_enum": { + "enum": [ + { + "$anchor": "my_anchor", + "type": "null" + } + ] + }, + "real_identifier_in_schema": { + "$anchor": "my_anchor", + "type": "string" + }, + "zzz_anchor_in_const": { + "const": { + "$anchor": "my_anchor", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/$defs/anchor_in_enum" }, + { "$ref": "#my_anchor" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$anchor": "my_anchor", + "type": "null" + }, + "valid": true + }, + { + "description": "in implementations that strip $anchor, this may match either $def", + "data": { + "type": "null" + }, + "valid": false + }, + { + "description": "match $ref to $anchor", + "data": "a string to match #/$defs/anchor_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to $anchor", + "data": 1, + "valid": false + } + ] + }, { "description": "same $anchor with different base uri", "schema": { @@ -116,5 +174,62 @@ "valid": false } ] + }, + { + "description": "non-schema object containing an $anchor property", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "const_not_anchor": { + "const": { + "$anchor": "not_a_real_anchor" + } + } + }, + "if": { + "const": "skip not_a_real_anchor" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_anchor" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_anchor", + "valid": true + }, + { + "description": "const at const_not_anchor does not match", + "data": 1, + "valid": false + } + ] + }, + { + "description": "invalid anchors", + "comment": "Section 8.2.2", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "https://json-schema.org/draft/2020-12/schema" + }, + "tests": [ + { + "description": "MUST start with a letter (and not #)", + "data": { "$anchor" : "#foo" }, + "valid": false + }, + { + "description": "JSON pointers are not valid", + "data": { "$anchor" : "/a/b" }, + "valid": false + }, + { + "description": "invalid with valid beginning", + "data": { "$anchor" : "foo#something" }, + "valid": false + } + ] } ] diff --git a/tests/draft2020-12/dependentSchemas.json b/tests/draft2020-12/dependentSchemas.json index 1c5f0574..66ac0eb4 100644 --- a/tests/draft2020-12/dependentSchemas.json +++ b/tests/draft2020-12/dependentSchemas.json @@ -132,7 +132,6 @@ { "description": "dependent subschema incompatible with root", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "properties": { "foo": {} }, diff --git a/tests/draft2020-12/dynamicRef.json b/tests/draft2020-12/dynamicRef.json index ffa211ba..c1c56cb8 100644 --- a/tests/draft2020-12/dynamicRef.json +++ b/tests/draft2020-12/dynamicRef.json @@ -726,90 +726,5 @@ "valid": false } ] - }, - { - "description": "$dynamicRef points to a boolean schema", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$defs": { - "true": true, - "false": false - }, - "properties": { - "true": { - "$dynamicRef": "#/$defs/true" - }, - "false": { - "$dynamicRef": "#/$defs/false" - } - } - }, - "tests": [ - { - "description": "follow $dynamicRef to a true schema", - "data": { "true": 1 }, - "valid": true - }, - { - "description": "follow $dynamicRef to a false schema", - "data": { "false": 1 }, - "valid": false - } - ] - }, - { - "description": "$dynamicRef skips over intermediate resources - direct reference", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/main", - "type": "object", - "properties": { - "bar-item": { - "$ref": "item" - } - }, - "$defs": { - "bar": { - "$id": "bar", - "type": "array", - "items": { - "$ref": "item" - }, - "$defs": { - "item": { - "$id": "item", - "type": "object", - "properties": { - "content": { - "$dynamicRef": "#content" - } - }, - "$defs": { - "defaultContent": { - "$dynamicAnchor": "content", - "type": "integer" - } - } - }, - "content": { - "$dynamicAnchor": "content", - "type": "string" - } - } - } - } - }, - "tests": [ - { - "description": "integer property passes", - "data": { "bar-item": { "content": 42 } }, - "valid": true - }, - { - "description": "string property fails", - "data": { "bar-item": { "content": "value" } }, - "valid": false - } - ] } ] diff --git a/tests/draft2020-12/enum.json b/tests/draft2020-12/enum.json index c8f35eac..0d780b2a 100644 --- a/tests/draft2020-12/enum.json +++ b/tests/draft2020-12/enum.json @@ -168,30 +168,6 @@ } ] }, - { - "description": "enum with [false] does not match [0]", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "enum": [[false]] - }, - "tests": [ - { - "description": "[false] is valid", - "data": [false], - "valid": true - }, - { - "description": "[0] is invalid", - "data": [0], - "valid": false - }, - { - "description": "[0.0] is invalid", - "data": [0.0], - "valid": false - } - ] - }, { "description": "enum with true does not match 1", "schema": { @@ -216,30 +192,6 @@ } ] }, - { - "description": "enum with [true] does not match [1]", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "enum": [[true]] - }, - "tests": [ - { - "description": "[true] is valid", - "data": [true], - "valid": true - }, - { - "description": "[1] is invalid", - "data": [1], - "valid": false - }, - { - "description": "[1.0] is invalid", - "data": [1.0], - "valid": false - } - ] - }, { "description": "enum with 0 does not match false", "schema": { @@ -264,30 +216,6 @@ } ] }, - { - "description": "enum with [0] does not match [false]", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "enum": [[0]] - }, - "tests": [ - { - "description": "[false] is invalid", - "data": [false], - "valid": false - }, - { - "description": "[0] is valid", - "data": [0], - "valid": true - }, - { - "description": "[0.0] is valid", - "data": [0.0], - "valid": true - } - ] - }, { "description": "enum with 1 does not match true", "schema": { @@ -312,30 +240,6 @@ } ] }, - { - "description": "enum with [1] does not match [true]", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "enum": [[1]] - }, - "tests": [ - { - "description": "[true] is invalid", - "data": [true], - "valid": false - }, - { - "description": "[1] is valid", - "data": [1], - "valid": true - }, - { - "description": "[1.0] is valid", - "data": [1.0], - "valid": true - } - ] - }, { "description": "nul characters in strings", "schema": { diff --git a/tests/draft2020-12/id.json b/tests/draft2020-12/id.json new file mode 100644 index 00000000..0ae5fe68 --- /dev/null +++ b/tests/draft2020-12/id.json @@ -0,0 +1,294 @@ +[ + { + "description": "Invalid use of fragments in location-independent $id", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "https://json-schema.org/draft/2020-12/schema" + }, + "tests": [ + { + "description": "Identifier name", + "data": { + "$ref": "#foo", + "$defs": { + "A": { + "$id": "#foo", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name and no ref", + "data": { + "$defs": { + "A": { "$id": "#foo" } + } + }, + "valid": false + }, + { + "description": "Identifier path", + "data": { + "$ref": "#/a/b", + "$defs": { + "A": { + "$id": "#/a/b", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft2020-12/bar#foo", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/bar#foo", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier path with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft2020-12/bar#/a/b", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/bar#/a/b", + "type": "integer" + } + } + }, + "valid": false + }, + { + "description": "Identifier name with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft2020-12/root", + "$ref": "http://localhost:1234/draft2020-12/nested.json#foo", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#foo", + "type": "integer" + } + } + } + } + }, + "valid": false + }, + { + "description": "Identifier path with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft2020-12/root", + "$ref": "http://localhost:1234/draft2020-12/nested.json#/a/b", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#/a/b", + "type": "integer" + } + } + } + } + }, + "valid": false + } + ] + }, + { + "description": "Valid use of empty fragments in location-independent $id", + "comment": "These are allowed but discouraged", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "https://json-schema.org/draft/2020-12/schema" + }, + "tests": [ + { + "description": "Identifier name with absolute URI", + "data": { + "$ref": "http://localhost:1234/draft2020-12/bar", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/bar#", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Identifier name with base URI change in subschema", + "data": { + "$id": "http://localhost:1234/draft2020-12/root", + "$ref": "http://localhost:1234/draft2020-12/nested.json#/$defs/B", + "$defs": { + "A": { + "$id": "nested.json", + "$defs": { + "B": { + "$id": "#", + "type": "integer" + } + } + } + } + }, + "valid": true + } + ] + }, + { + "description": "Unnormalized $ids are allowed but discouraged", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "https://json-schema.org/draft/2020-12/schema" + }, + "tests": [ + { + "description": "Unnormalized identifier", + "data": { + "$ref": "http://localhost:1234/draft2020-12/foo/baz", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier and no ref", + "data": { + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier with empty fragment", + "data": { + "$ref": "http://localhost:1234/draft2020-12/foo/baz", + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz#", + "type": "integer" + } + } + }, + "valid": true + }, + { + "description": "Unnormalized identifier with empty fragment and no ref", + "data": { + "$defs": { + "A": { + "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz#", + "type": "integer" + } + } + }, + "valid": true + } + ] + }, + { + "description": "$id inside an enum is not a real identifier", + "comment": "the implementation must not be confused by an $id buried in the enum", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "id_in_enum": { + "enum": [ + { + "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", + "type": "null" + } + ] + }, + "real_id_in_schema": { + "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", + "type": "string" + }, + "zzz_id_in_const": { + "const": { + "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", + "type": "null" + } + } + }, + "anyOf": [ + { "$ref": "#/$defs/id_in_enum" }, + { "$ref": "https://localhost:1234/draft2020-12/id/my_identifier.json" } + ] + }, + "tests": [ + { + "description": "exact match to enum, and type matches", + "data": { + "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", + "type": "null" + }, + "valid": true + }, + { + "description": "match $ref to $id", + "data": "a string to match #/$defs/id_in_enum", + "valid": true + }, + { + "description": "no match on enum or $ref to $id", + "data": 1, + "valid": false + } + ] + }, + { + "description": "non-schema object containing an $id property", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$defs": { + "const_not_id": { + "const": { + "$id": "not_a_real_id" + } + } + }, + "if": { + "const": "skip not_a_real_id" + }, + "then": true, + "else" : { + "$ref": "#/$defs/const_not_id" + } + }, + "tests": [ + { + "description": "skip traversing definition for a valid result", + "data": "skip not_a_real_id", + "valid": true + }, + { + "description": "const at const_not_id does not match", + "data": 1, + "valid": false + } + ] + } +] diff --git a/tests/draft2020-12/items.json b/tests/draft2020-12/items.json index 6a3e1cf2..1ef18bdd 100644 --- a/tests/draft2020-12/items.json +++ b/tests/draft2020-12/items.json @@ -265,26 +265,6 @@ } ] }, - { - "description": "items with heterogeneous array", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "prefixItems": [{}], - "items": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "items with null instance elements", "schema": { diff --git a/tests/draft2020-12/maxLength.json b/tests/draft2020-12/maxLength.json index 7462726d..b6eb0340 100644 --- a/tests/draft2020-12/maxLength.json +++ b/tests/draft2020-12/maxLength.json @@ -27,7 +27,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft2020-12/minLength.json b/tests/draft2020-12/minLength.json index 5076c5a9..e0930b6f 100644 --- a/tests/draft2020-12/minLength.json +++ b/tests/draft2020-12/minLength.json @@ -27,7 +27,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft2020-12/not.json b/tests/draft2020-12/not.json index d0f2b6e8..57e45ba3 100644 --- a/tests/draft2020-12/not.json +++ b/tests/draft2020-12/not.json @@ -97,173 +97,25 @@ ] }, { - "description": "forbid everything with empty schema", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "not": {} - }, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "forbid everything with boolean schema true", + "description": "not with boolean schema true", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "not": true }, "tests": [ { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", + "description": "any value is invalid", "data": "foo", "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false } ] }, { - "description": "allow everything with boolean schema false", + "description": "not with boolean schema false", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", "not": false }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "boolean true is valid", - "data": true, - "valid": true - }, - { - "description": "boolean false is valid", - "data": false, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "object is valid", - "data": {"foo": "bar"}, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "array is valid", - "data": ["foo"], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "double negation", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "not": { "not": {} } - }, "tests": [ { "description": "any value is valid", diff --git a/tests/draft2020-12/oneOf.json b/tests/draft2020-12/oneOf.json index 7a7c7ffe..416c8e57 100644 --- a/tests/draft2020-12/oneOf.json +++ b/tests/draft2020-12/oneOf.json @@ -220,7 +220,7 @@ } ] }, - { + { "description": "oneOf with missing optional property", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", diff --git a/tests/draft2020-12/optional/anchor.json b/tests/draft2020-12/optional/anchor.json deleted file mode 100644 index 6d6713be..00000000 --- a/tests/draft2020-12/optional/anchor.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "description": "$anchor inside an enum is not a real identifier", - "comment": "the implementation must not be confused by an $anchor buried in the enum", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$defs": { - "anchor_in_enum": { - "enum": [ - { - "$anchor": "my_anchor", - "type": "null" - } - ] - }, - "real_identifier_in_schema": { - "$anchor": "my_anchor", - "type": "string" - }, - "zzz_anchor_in_const": { - "const": { - "$anchor": "my_anchor", - "type": "null" - } - } - }, - "anyOf": [ - { "$ref": "#/$defs/anchor_in_enum" }, - { "$ref": "#my_anchor" } - ] - }, - "tests": [ - { - "description": "exact match to enum, and type matches", - "data": { - "$anchor": "my_anchor", - "type": "null" - }, - "valid": true - }, - { - "description": "in implementations that strip $anchor, this may match either $def", - "data": { - "type": "null" - }, - "valid": false - }, - { - "description": "match $ref to $anchor", - "data": "a string to match #/$defs/anchor_in_enum", - "valid": true - }, - { - "description": "no match on enum or $ref to $anchor", - "data": 1, - "valid": false - } - ] - } -] diff --git a/tests/draft2020-12/optional/dynamicRef.json b/tests/draft2020-12/optional/dynamicRef.json deleted file mode 100644 index 7e63f209..00000000 --- a/tests/draft2020-12/optional/dynamicRef.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "description": "$dynamicRef skips over intermediate resources - pointer reference across resource boundary", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/optional/main", - "type": "object", - "properties": { - "bar-item": { - "$ref": "bar#/$defs/item" - } - }, - "$defs": { - "bar": { - "$id": "bar", - "type": "array", - "items": { - "$ref": "item" - }, - "$defs": { - "item": { - "$id": "item", - "type": "object", - "properties": { - "content": { - "$dynamicRef": "#content" - } - }, - "$defs": { - "defaultContent": { - "$dynamicAnchor": "content", - "type": "integer" - } - } - }, - "content": { - "$dynamicAnchor": "content", - "type": "string" - } - } - } - } - }, - "tests": [ - { - "description": "integer property passes", - "data": { "bar-item": { "content": 42 } }, - "valid": true - }, - { - "description": "string property fails", - "data": { "bar-item": { "content": "value" } }, - "valid": false - } - ] - }] \ No newline at end of file diff --git a/tests/draft2020-12/optional/ecmascript-regex.json b/tests/draft2020-12/optional/ecmascript-regex.json index a4d62e0c..23b962e4 100644 --- a/tests/draft2020-12/optional/ecmascript-regex.json +++ b/tests/draft2020-12/optional/ecmascript-regex.json @@ -405,6 +405,20 @@ } ] }, + { + "description": "\\a is not an ECMA 262 control escape", + "schema": { + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "https://json-schema.org/draft/2020-12/schema" + }, + "tests": [ + { + "description": "when used as a pattern", + "data": { "pattern": "\\a" }, + "valid": false + } + ] + }, { "description": "pattern with non-ASCII digits", "schema": { diff --git a/tests/draft2020-12/optional/format/duration.json b/tests/draft2020-12/optional/format/duration.json index a09fec5e..a3af56ef 100644 --- a/tests/draft2020-12/optional/format/duration.json +++ b/tests/draft2020-12/optional/format/duration.json @@ -46,11 +46,6 @@ "data": "PT1D", "valid": false }, - { - "description": "must start with P", - "data": "4DT12H30M5S", - "valid": false - }, { "description": "no elements present", "data": "P", diff --git a/tests/draft2020-12/optional/format/ecmascript-regex.json b/tests/draft2020-12/optional/format/ecmascript-regex.json deleted file mode 100644 index b0648084..00000000 --- a/tests/draft2020-12/optional/format/ecmascript-regex.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "description": "\\a is not an ECMA 262 control escape", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "format": "regex" - }, - "tests": [ - { - "description": "when used as a pattern", - "data": "\\a", - "valid": false - } - ] - } -] \ No newline at end of file diff --git a/tests/draft2020-12/optional/format/hostname.json b/tests/draft2020-12/optional/format/hostname.json index 57827c4d..41418dd4 100644 --- a/tests/draft2020-12/optional/format/hostname.json +++ b/tests/draft2020-12/optional/format/hostname.json @@ -120,16 +120,6 @@ "description": "single label ending with digit", "data": "hostnam3", "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - }, - { - "description": "single dot", - "data": ".", - "valid": false } ] } diff --git a/tests/draft2020-12/optional/format/idn-hostname.json b/tests/draft2020-12/optional/format/idn-hostname.json index f42ae969..5549c055 100644 --- a/tests/draft2020-12/optional/format/idn-hostname.json +++ b/tests/draft2020-12/optional/format/idn-hostname.json @@ -257,7 +257,7 @@ { "description": "Arabic-Indic digits mixed with Extended Arabic-Indic digits", "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8", - "data": "\u0628\u0660\u06f0", + "data": "\u0660\u06f0", "valid": false }, { @@ -301,88 +301,6 @@ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement", "data": "\u0628\u064a\u200c\u0628\u064a", "valid": true - }, - { - "description": "single label", - "data": "hostname", - "valid": true - }, - { - "description": "single label with hyphen", - "data": "host-name", - "valid": true - }, - { - "description": "single label with digits", - "data": "h0stn4me", - "valid": true - }, - { - "description": "single label starting with digit", - "data": "1host", - "valid": true - }, - { - "description": "single label ending with digit", - "data": "hostnam3", - "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - } - ] - }, - { - "description": "validation of separators in internationalized host names", - "specification": [ - {"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"} - ], - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "format": "idn-hostname" - }, - "tests": [ - { - "description": "single dot", - "data": ".", - "valid": false - }, - { - "description": "single ideographic full stop", - "data": "\u3002", - "valid": false - }, - { - "description": "single fullwidth full stop", - "data": "\uff0e", - "valid": false - }, - { - "description": "single halfwidth ideographic full stop", - "data": "\uff61", - "valid": false - }, - { - "description": "dot as label separator", - "data": "a.b", - "valid": true - }, - { - "description": "ideographic full stop as label separator", - "data": "a\u3002b", - "valid": true - }, - { - "description": "fullwidth full stop as label separator", - "data": "a\uff0eb", - "valid": true - }, - { - "description": "halfwidth ideographic full stop as label separator", - "data": "a\uff61b", - "valid": true } ] } diff --git a/tests/draft2020-12/optional/format/ipv4.json b/tests/draft2020-12/optional/format/ipv4.json index 86d27bdb..c72b6fc2 100644 --- a/tests/draft2020-12/optional/format/ipv4.json +++ b/tests/draft2020-12/optional/format/ipv4.json @@ -81,11 +81,6 @@ "description": "invalid non-ASCII '২' (a Bengali 2)", "data": "1২7.0.0.1", "valid": false - }, - { - "description": "netmask is not a part of ipv4 address", - "data": "192.168.1.0/24", - "valid": false } ] } diff --git a/tests/draft2020-12/optional/id.json b/tests/draft2020-12/optional/id.json deleted file mode 100644 index 0b7df4e8..00000000 --- a/tests/draft2020-12/optional/id.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "description": "$id inside an enum is not a real identifier", - "comment": "the implementation must not be confused by an $id buried in the enum", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$defs": { - "id_in_enum": { - "enum": [ - { - "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", - "type": "null" - } - ] - }, - "real_id_in_schema": { - "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", - "type": "string" - }, - "zzz_id_in_const": { - "const": { - "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", - "type": "null" - } - } - }, - "anyOf": [ - { "$ref": "#/$defs/id_in_enum" }, - { "$ref": "https://localhost:1234/draft2020-12/id/my_identifier.json" } - ] - }, - "tests": [ - { - "description": "exact match to enum, and type matches", - "data": { - "$id": "https://localhost:1234/draft2020-12/id/my_identifier.json", - "type": "null" - }, - "valid": true - }, - { - "description": "match $ref to $id", - "data": "a string to match #/$defs/id_in_enum", - "valid": true - }, - { - "description": "no match on enum or $ref to $id", - "data": 1, - "valid": false - } - ] - } -] diff --git a/tests/draft2020-12/optional/refOfUnknownKeyword.json b/tests/draft2020-12/optional/refOfUnknownKeyword.json index c2b080a1..f91c1888 100644 --- a/tests/draft2020-12/optional/refOfUnknownKeyword.json +++ b/tests/draft2020-12/optional/refOfUnknownKeyword.json @@ -42,28 +42,5 @@ "valid": false } ] - }, - { - "description": "reference internals of known non-applicator", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "/base", - "examples": [ - { "type": "string" } - ], - "$ref": "#/examples/0" - }, - "tests": [ - { - "description": "match", - "data": "a string", - "valid": true - }, - { - "description": "mismatch", - "data": 42, - "valid": false - } - ] } ] diff --git a/tests/draft2020-12/propertyNames.json b/tests/draft2020-12/propertyNames.json index b4780088..7ecfb7ec 100644 --- a/tests/draft2020-12/propertyNames.json +++ b/tests/draft2020-12/propertyNames.json @@ -44,36 +44,6 @@ } ] }, - { - "description": "propertyNames validation with pattern", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "propertyNames": { "pattern": "^a+$" } - }, - "tests": [ - { - "description": "matching property names valid", - "data": { - "a": {}, - "aa": {}, - "aaa": {} - }, - "valid": true - }, - { - "description": "non-matching property name is invalid", - "data": { - "aaA": {} - }, - "valid": false - }, - { - "description": "object without properties is valid", - "data": {}, - "valid": true - } - ] - }, { "description": "propertyNames with boolean schema true", "schema": { @@ -111,58 +81,5 @@ "valid": true } ] - }, - { - "description": "propertyNames with const", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "propertyNames": {"const": "foo"} - }, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"bar": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "propertyNames with enum", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "propertyNames": {"enum": ["foo", "bar"]} - }, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with property foo and bar is valid", - "data": {"foo": 1, "bar": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"baz": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] } ] diff --git a/tests/draft2020-12/ref.json b/tests/draft2020-12/ref.json index a1d3efaf..5f6be8c2 100644 --- a/tests/draft2020-12/ref.json +++ b/tests/draft2020-12/ref.json @@ -791,6 +791,21 @@ } ] }, + { + "description": "URN base URI with f-component", + "schema": { + "$comment": "RFC 8141 §2.3.3, but we don't allow fragments", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$ref": "https://json-schema.org/draft/2020-12/schema" + }, + "tests": [ + { + "description": "is invalid", + "data": {"$id": "urn:example:foo-bar-baz-qux#somepart"}, + "valid": false + } + ] + }, { "description": "URN base URI with URN and JSON pointer ref", "schema": { @@ -847,7 +862,6 @@ { "description": "URN ref with nested pointer ref", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed", "$defs": { "foo": { @@ -873,7 +887,6 @@ { "description": "ref to if", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$ref": "http://example.com/ref/if", "if": { "$id": "http://example.com/ref/if", @@ -896,7 +909,6 @@ { "description": "ref to then", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$ref": "http://example.com/ref/then", "then": { "$id": "http://example.com/ref/then", @@ -919,7 +931,6 @@ { "description": "ref to else", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$ref": "http://example.com/ref/else", "else": { "$id": "http://example.com/ref/else", @@ -942,7 +953,6 @@ { "description": "ref with absolute-path-reference", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "http://example.com/ref/absref.json", "$defs": { "a": { @@ -972,7 +982,6 @@ { "description": "$id with file URI still resolves pointers - *nix", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "file:///folder/file.json", "$defs": { "foo": { @@ -997,7 +1006,6 @@ { "description": "$id with file URI still resolves pointers - windows", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "file:///c:/folder/file.json", "$defs": { "foo": { @@ -1022,7 +1030,6 @@ { "description": "empty tokens in $ref json-pointer", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "": { "$defs": { diff --git a/tests/draft2020-12/refRemote.json b/tests/draft2020-12/refRemote.json index 047ac74c..ea4177f0 100644 --- a/tests/draft2020-12/refRemote.json +++ b/tests/draft2020-12/refRemote.json @@ -22,7 +22,7 @@ "description": "fragment within remote ref", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$ref": "http://localhost:1234/draft2020-12/subSchemas.json#/$defs/integer" + "$ref": "http://localhost:1234/draft2020-12/subSchemas-defs.json#/$defs/integer" }, "tests": [ { @@ -60,7 +60,7 @@ "description": "ref within remote ref", "schema": { "$schema": "https://json-schema.org/draft/2020-12/schema", - "$ref": "http://localhost:1234/draft2020-12/subSchemas.json#/$defs/refToInteger" + "$ref": "http://localhost:1234/draft2020-12/subSchemas-defs.json#/$defs/refToInteger" }, "tests": [ { @@ -265,10 +265,7 @@ }, { "description": "remote HTTP ref with different $id", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$ref": "http://localhost:1234/different-id-ref-string.json" - }, + "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"}, "tests": [ { "description": "number is invalid", @@ -284,10 +281,7 @@ }, { "description": "remote HTTP ref with different URN $id", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$ref": "http://localhost:1234/urn-ref-string.json" - }, + "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"}, "tests": [ { "description": "number is invalid", @@ -303,10 +297,7 @@ }, { "description": "remote HTTP ref with nested absolute ref", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$ref": "http://localhost:1234/nested-absolute-ref-to-string.json" - }, + "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"}, "tests": [ { "description": "number is invalid", @@ -323,7 +314,6 @@ { "description": "$ref to $ref finds detached $anchor", "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", "$ref": "http://localhost:1234/draft2020-12/detached-ref.json#/$defs/foo" }, "tests": [ diff --git a/tests/draft2020-12/unevaluatedItems.json b/tests/draft2020-12/unevaluatedItems.json index f861cefa..2615c4c4 100644 --- a/tests/draft2020-12/unevaluatedItems.json +++ b/tests/draft2020-12/unevaluatedItems.json @@ -461,86 +461,6 @@ } ] }, - { - "description": "unevaluatedItems before $ref", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "unevaluatedItems": false, - "prefixItems": [ - { "type": "string" } - ], - "$ref": "#/$defs/bar", - "$defs": { - "bar": { - "prefixItems": [ - true, - { "type": "string" } - ] - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": ["foo", "bar"], - "valid": true - }, - { - "description": "with unevaluated items", - "data": ["foo", "bar", "baz"], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with $dynamicRef", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://example.com/unevaluated-items-with-dynamic-ref/derived", - - "$ref": "./baseSchema", - - "$defs": { - "derived": { - "$dynamicAnchor": "addons", - "prefixItems": [ - true, - { "type": "string" } - ] - }, - "baseSchema": { - "$id": "./baseSchema", - - "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", - "unevaluatedItems": false, - "type": "array", - "prefixItems": [ - { "type": "string" } - ], - "$dynamicRef": "#addons", - - "$defs": { - "defaultAddons": { - "$comment": "Needed to satisfy the bookending requirement", - "$dynamicAnchor": "addons" - } - } - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": ["foo", "bar"], - "valid": true - }, - { - "description": "with unevaluated items", - "data": ["foo", "bar", "baz"], - "valid": false - } - ] - }, { "description": "unevaluatedItems can't see inside cousins", "schema": { @@ -793,6 +713,7 @@ "data": [ "b" ], "valid": false } + ] } ] diff --git a/tests/draft2020-12/unevaluatedProperties.json b/tests/draft2020-12/unevaluatedProperties.json index ae29c9eb..f7fb420f 100644 --- a/tests/draft2020-12/unevaluatedProperties.json +++ b/tests/draft2020-12/unevaluatedProperties.json @@ -715,99 +715,6 @@ } ] }, - { - "description": "unevaluatedProperties before $ref", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "type": "object", - "unevaluatedProperties": false, - "properties": { - "foo": { "type": "string" } - }, - "$ref": "#/$defs/bar", - "$defs": { - "bar": { - "properties": { - "bar": { "type": "string" } - } - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with $dynamicRef", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived", - - "$ref": "./baseSchema", - - "$defs": { - "derived": { - "$dynamicAnchor": "addons", - "properties": { - "bar": { "type": "string" } - } - }, - "baseSchema": { - "$id": "./baseSchema", - - "$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", - "unevaluatedProperties": false, - "type": "object", - "properties": { - "foo": { "type": "string" } - }, - "$dynamicRef": "#addons", - - "$defs": { - "defaultAddons": { - "$comment": "Needed to satisfy the bookending requirement", - "$dynamicAnchor": "addons" - } - } - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, { "description": "unevaluatedProperties can't see inside cousins", "schema": { @@ -1564,38 +1471,5 @@ "valid": false } ] - }, - { - "description": "dependentSchemas with unevaluatedProperties", - "schema": { - "$schema": "https://json-schema.org/draft/2020-12/schema", - "properties": {"foo2": {}}, - "dependentSchemas": { - "foo" : {}, - "foo2": { - "properties": { - "bar":{} - } - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "unevaluatedProperties doesn't consider dependentSchemas", - "data": {"foo": ""}, - "valid": false - }, - { - "description": "unevaluatedProperties doesn't see bar when foo2 is absent", - "data": {"bar": ""}, - "valid": false - }, - { - "description": "unevaluatedProperties sees bar when foo2 is present", - "data": { "foo2": "", "bar": ""}, - "valid": true - } - ] } ] diff --git a/tests/draft2020-12/optional/unknownKeyword.json b/tests/draft2020-12/unknownKeyword.json similarity index 100% rename from tests/draft2020-12/optional/unknownKeyword.json rename to tests/draft2020-12/unknownKeyword.json diff --git a/tests/draft3/additionalItems.json b/tests/draft3/additionalItems.json index ab44a2eb..0cb66870 100644 --- a/tests/draft3/additionalItems.json +++ b/tests/draft3/additionalItems.json @@ -110,25 +110,6 @@ } ] }, - { - "description": "additionalItems with heterogeneous array", - "schema": { - "items": [{}], - "additionalItems": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "additionalItems with null instance elements", "schema": { diff --git a/tests/draft3/maxLength.json b/tests/draft3/maxLength.json index b0a9ea5b..4de42bca 100644 --- a/tests/draft3/maxLength.json +++ b/tests/draft3/maxLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft3/minLength.json b/tests/draft3/minLength.json index 6652c750..3f09158d 100644 --- a/tests/draft3/minLength.json +++ b/tests/draft3/minLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft3/optional/format/ecmascript-regex.json b/tests/draft3/optional/ecmascript-regex.json similarity index 100% rename from tests/draft3/optional/format/ecmascript-regex.json rename to tests/draft3/optional/ecmascript-regex.json diff --git a/tests/draft3/optional/format/host-name.json b/tests/draft3/optional/format/host-name.json index 9a75c3c2..d418f376 100644 --- a/tests/draft3/optional/format/host-name.json +++ b/tests/draft3/optional/format/host-name.json @@ -57,11 +57,6 @@ "description": "exceeds maximum label length", "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com", "valid": false - }, - { - "description": "empty string", - "data": "", - "valid": false } ] } diff --git a/tests/draft3/refRemote.json b/tests/draft3/refRemote.json index 81a6c511..de0cb43a 100644 --- a/tests/draft3/refRemote.json +++ b/tests/draft3/refRemote.json @@ -17,7 +17,7 @@ }, { "description": "fragment within remote ref", - "schema": {"$ref": "http://localhost:1234/draft3/subSchemas.json#/definitions/integer"}, + "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, "tests": [ { "description": "remote fragment valid", @@ -34,7 +34,7 @@ { "description": "ref within remote ref", "schema": { - "$ref": "http://localhost:1234/draft3/subSchemas.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/subSchemas.json#/refToInteger" }, "tests": [ { diff --git a/tests/draft4/additionalItems.json b/tests/draft4/additionalItems.json index c9e68154..deb44fd3 100644 --- a/tests/draft4/additionalItems.json +++ b/tests/draft4/additionalItems.json @@ -146,25 +146,6 @@ } ] }, - { - "description": "additionalItems with heterogeneous array", - "schema": { - "items": [{}], - "additionalItems": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "additionalItems with null instance elements", "schema": { diff --git a/tests/draft4/enum.json b/tests/draft4/enum.json index ce43acc0..f085097b 100644 --- a/tests/draft4/enum.json +++ b/tests/draft4/enum.json @@ -154,27 +154,6 @@ } ] }, - { - "description": "enum with [false] does not match [0]", - "schema": {"enum": [[false]]}, - "tests": [ - { - "description": "[false] is valid", - "data": [false], - "valid": true - }, - { - "description": "[0] is invalid", - "data": [0], - "valid": false - }, - { - "description": "[0.0] is invalid", - "data": [0.0], - "valid": false - } - ] - }, { "description": "enum with true does not match 1", "schema": {"enum": [true]}, @@ -196,27 +175,6 @@ } ] }, - { - "description": "enum with [true] does not match [1]", - "schema": {"enum": [[true]]}, - "tests": [ - { - "description": "[true] is valid", - "data": [true], - "valid": true - }, - { - "description": "[1] is invalid", - "data": [1], - "valid": false - }, - { - "description": "[1.0] is invalid", - "data": [1.0], - "valid": false - } - ] - }, { "description": "enum with 0 does not match false", "schema": {"enum": [0]}, @@ -238,27 +196,6 @@ } ] }, - { - "description": "enum with [0] does not match [false]", - "schema": {"enum": [[0]]}, - "tests": [ - { - "description": "[false] is invalid", - "data": [false], - "valid": false - }, - { - "description": "[0] is valid", - "data": [0], - "valid": true - }, - { - "description": "[0.0] is valid", - "data": [0.0], - "valid": true - } - ] - }, { "description": "enum with 1 does not match true", "schema": {"enum": [1]}, @@ -280,27 +217,6 @@ } ] }, - { - "description": "enum with [1] does not match [true]", - "schema": {"enum": [[1]]}, - "tests": [ - { - "description": "[true] is invalid", - "data": [true], - "valid": false - }, - { - "description": "[1] is valid", - "data": [1], - "valid": true - }, - { - "description": "[1.0] is valid", - "data": [1.0], - "valid": true - } - ] - }, { "description": "nul characters in strings", "schema": { "enum": [ "hello\u0000there" ] }, diff --git a/tests/draft4/optional/id.json b/tests/draft4/id.json similarity index 100% rename from tests/draft4/optional/id.json rename to tests/draft4/id.json diff --git a/tests/draft4/maxLength.json b/tests/draft4/maxLength.json index 33879594..811d35b2 100644 --- a/tests/draft4/maxLength.json +++ b/tests/draft4/maxLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft4/minLength.json b/tests/draft4/minLength.json index 6652c750..3f09158d 100644 --- a/tests/draft4/minLength.json +++ b/tests/draft4/minLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft4/not.json b/tests/draft4/not.json index 525219cf..cbb7f46b 100644 --- a/tests/draft4/not.json +++ b/tests/draft4/not.json @@ -91,67 +91,6 @@ "valid": true } ] - }, - { - "description": "forbid everything with empty schema", - "schema": { "not": {} }, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "double negation", - "schema": { "not": { "not": {} } }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] } + ] diff --git a/tests/draft4/oneOf.json b/tests/draft4/oneOf.json index 2487f0e3..fb63b089 100644 --- a/tests/draft4/oneOf.json +++ b/tests/draft4/oneOf.json @@ -159,7 +159,7 @@ } ] }, - { + { "description": "oneOf with missing optional property", "schema": { "oneOf": [ diff --git a/tests/draft4/optional/format/hostname.json b/tests/draft4/optional/format/hostname.json index 866a6178..a8ecd194 100644 --- a/tests/draft4/optional/format/hostname.json +++ b/tests/draft4/optional/format/hostname.json @@ -112,16 +112,6 @@ "description": "single label ending with digit", "data": "hostnam3", "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - }, - { - "description": "single dot", - "data": ".", - "valid": false } ] } diff --git a/tests/draft4/optional/format/ipv4.json b/tests/draft4/optional/format/ipv4.json index 9680fe62..4706581f 100644 --- a/tests/draft4/optional/format/ipv4.json +++ b/tests/draft4/optional/format/ipv4.json @@ -78,11 +78,6 @@ "description": "invalid non-ASCII '২' (a Bengali 2)", "data": "1২7.0.0.1", "valid": false - }, - { - "description": "netmask is not a part of ipv4 address", - "data": "192.168.1.0/24", - "valid": false } ] } diff --git a/tests/draft4/refRemote.json b/tests/draft4/refRemote.json index 65e45190..412c9ff8 100644 --- a/tests/draft4/refRemote.json +++ b/tests/draft4/refRemote.json @@ -17,7 +17,7 @@ }, { "description": "fragment within remote ref", - "schema": {"$ref": "http://localhost:1234/draft4/subSchemas.json#/definitions/integer"}, + "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, "tests": [ { "description": "remote fragment valid", @@ -34,7 +34,7 @@ { "description": "ref within remote ref", "schema": { - "$ref": "http://localhost:1234/draft4/subSchemas.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/subSchemas.json#/refToInteger" }, "tests": [ { @@ -139,7 +139,7 @@ "id": "http://localhost:1234/object", "type": "object", "properties": { - "name": {"$ref": "draft4/name.json#/definitions/orNull"} + "name": {"$ref": "name.json#/definitions/orNull"} } }, "tests": [ @@ -171,7 +171,7 @@ { "description": "Location-independent identifier in remote ref", "schema": { - "$ref": "http://localhost:1234/draft4/locationIndependentIdentifier.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/locationIndependentIdentifierDraft4.json#/definitions/refToInteger" }, "tests": [ { diff --git a/tests/draft6/additionalItems.json b/tests/draft6/additionalItems.json index 2c7d1558..cae72361 100644 --- a/tests/draft6/additionalItems.json +++ b/tests/draft6/additionalItems.json @@ -169,25 +169,6 @@ } ] }, - { - "description": "additionalItems with heterogeneous array", - "schema": { - "items": [{}], - "additionalItems": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "additionalItems with null instance elements", "schema": { diff --git a/tests/draft6/enum.json b/tests/draft6/enum.json index ce43acc0..f085097b 100644 --- a/tests/draft6/enum.json +++ b/tests/draft6/enum.json @@ -154,27 +154,6 @@ } ] }, - { - "description": "enum with [false] does not match [0]", - "schema": {"enum": [[false]]}, - "tests": [ - { - "description": "[false] is valid", - "data": [false], - "valid": true - }, - { - "description": "[0] is invalid", - "data": [0], - "valid": false - }, - { - "description": "[0.0] is invalid", - "data": [0.0], - "valid": false - } - ] - }, { "description": "enum with true does not match 1", "schema": {"enum": [true]}, @@ -196,27 +175,6 @@ } ] }, - { - "description": "enum with [true] does not match [1]", - "schema": {"enum": [[true]]}, - "tests": [ - { - "description": "[true] is valid", - "data": [true], - "valid": true - }, - { - "description": "[1] is invalid", - "data": [1], - "valid": false - }, - { - "description": "[1.0] is invalid", - "data": [1.0], - "valid": false - } - ] - }, { "description": "enum with 0 does not match false", "schema": {"enum": [0]}, @@ -238,27 +196,6 @@ } ] }, - { - "description": "enum with [0] does not match [false]", - "schema": {"enum": [[0]]}, - "tests": [ - { - "description": "[false] is invalid", - "data": [false], - "valid": false - }, - { - "description": "[0] is valid", - "data": [0], - "valid": true - }, - { - "description": "[0.0] is valid", - "data": [0.0], - "valid": true - } - ] - }, { "description": "enum with 1 does not match true", "schema": {"enum": [1]}, @@ -280,27 +217,6 @@ } ] }, - { - "description": "enum with [1] does not match [true]", - "schema": {"enum": [[1]]}, - "tests": [ - { - "description": "[true] is invalid", - "data": [true], - "valid": false - }, - { - "description": "[1] is valid", - "data": [1], - "valid": true - }, - { - "description": "[1.0] is valid", - "data": [1.0], - "valid": true - } - ] - }, { "description": "nul characters in strings", "schema": { "enum": [ "hello\u0000there" ] }, diff --git a/tests/draft6/optional/id.json b/tests/draft6/id.json similarity index 100% rename from tests/draft6/optional/id.json rename to tests/draft6/id.json diff --git a/tests/draft6/maxLength.json b/tests/draft6/maxLength.json index be60c540..748b4daa 100644 --- a/tests/draft6/maxLength.json +++ b/tests/draft6/maxLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft6/minLength.json b/tests/draft6/minLength.json index 23c68fe3..64db9480 100644 --- a/tests/draft6/minLength.json +++ b/tests/draft6/minLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft6/not.json b/tests/draft6/not.json index b46c4ed0..98de0eda 100644 --- a/tests/draft6/not.json +++ b/tests/draft6/not.json @@ -93,161 +93,19 @@ ] }, { - "description": "forbid everything with empty schema", - "schema": { "not": {} }, + "description": "not with boolean schema true", + "schema": {"not": true}, "tests": [ { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", + "description": "any value is invalid", "data": "foo", "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "forbid everything with boolean schema true", - "schema": { "not": true }, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "allow everything with boolean schema false", - "schema": { "not": false }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "boolean true is valid", - "data": true, - "valid": true - }, - { - "description": "boolean false is valid", - "data": false, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "object is valid", - "data": {"foo": "bar"}, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "array is valid", - "data": ["foo"], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true } ] }, { - "description": "double negation", - "schema": { "not": { "not": {} } }, + "description": "not with boolean schema false", + "schema": {"not": false}, "tests": [ { "description": "any value is valid", diff --git a/tests/draft6/oneOf.json b/tests/draft6/oneOf.json index c30a65c0..eeb7ae86 100644 --- a/tests/draft6/oneOf.json +++ b/tests/draft6/oneOf.json @@ -203,7 +203,7 @@ } ] }, - { + { "description": "oneOf with missing optional property", "schema": { "oneOf": [ diff --git a/tests/draft6/optional/format/hostname.json b/tests/draft6/optional/format/hostname.json index 866a6178..a8ecd194 100644 --- a/tests/draft6/optional/format/hostname.json +++ b/tests/draft6/optional/format/hostname.json @@ -112,16 +112,6 @@ "description": "single label ending with digit", "data": "hostnam3", "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - }, - { - "description": "single dot", - "data": ".", - "valid": false } ] } diff --git a/tests/draft6/optional/format/ipv4.json b/tests/draft6/optional/format/ipv4.json index 9680fe62..4706581f 100644 --- a/tests/draft6/optional/format/ipv4.json +++ b/tests/draft6/optional/format/ipv4.json @@ -78,11 +78,6 @@ "description": "invalid non-ASCII '২' (a Bengali 2)", "data": "1২7.0.0.1", "valid": false - }, - { - "description": "netmask is not a part of ipv4 address", - "data": "192.168.1.0/24", - "valid": false } ] } diff --git a/tests/draft6/propertyNames.json b/tests/draft6/propertyNames.json index 7c7b8000..f0788e64 100644 --- a/tests/draft6/propertyNames.json +++ b/tests/draft6/propertyNames.json @@ -103,52 +103,5 @@ "valid": true } ] - }, - { - "description": "propertyNames with const", - "schema": {"propertyNames": {"const": "foo"}}, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"bar": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "propertyNames with enum", - "schema": {"propertyNames": {"enum": ["foo", "bar"]}}, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with property foo and bar is valid", - "data": {"foo": 1, "bar": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"baz": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] } ] diff --git a/tests/draft6/refRemote.json b/tests/draft6/refRemote.json index 49ead6d1..5d60fae1 100644 --- a/tests/draft6/refRemote.json +++ b/tests/draft6/refRemote.json @@ -17,7 +17,7 @@ }, { "description": "fragment within remote ref", - "schema": {"$ref": "http://localhost:1234/draft6/subSchemas.json#/definitions/integer"}, + "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, "tests": [ { "description": "remote fragment valid", @@ -34,7 +34,7 @@ { "description": "ref within remote ref", "schema": { - "$ref": "http://localhost:1234/draft6/subSchemas.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/subSchemas.json#/refToInteger" }, "tests": [ { @@ -139,7 +139,7 @@ "$id": "http://localhost:1234/object", "type": "object", "properties": { - "name": {"$ref": "draft6/name.json#/definitions/orNull"} + "name": {"$ref": "name.json#/definitions/orNull"} } }, "tests": [ @@ -173,7 +173,7 @@ "schema": { "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", "allOf": [ - { "$ref": "draft6/ref-and-definitions.json" } + { "$ref": "ref-and-definitions.json" } ] }, "tests": [ @@ -196,7 +196,7 @@ { "description": "Location-independent identifier in remote ref", "schema": { - "$ref": "http://localhost:1234/draft6/locationIndependentIdentifier.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger" }, "tests": [ { diff --git a/tests/draft6/optional/unknownKeyword.json b/tests/draft6/unknownKeyword.json similarity index 100% rename from tests/draft6/optional/unknownKeyword.json rename to tests/draft6/unknownKeyword.json diff --git a/tests/draft7/additionalItems.json b/tests/draft7/additionalItems.json index 2c7d1558..cae72361 100644 --- a/tests/draft7/additionalItems.json +++ b/tests/draft7/additionalItems.json @@ -169,25 +169,6 @@ } ] }, - { - "description": "additionalItems with heterogeneous array", - "schema": { - "items": [{}], - "additionalItems": false - }, - "tests": [ - { - "description": "heterogeneous invalid instance", - "data": [ "foo", "bar", 37 ], - "valid": false - }, - { - "description": "valid instance", - "data": [ null ], - "valid": true - } - ] - }, { "description": "additionalItems with null instance elements", "schema": { diff --git a/tests/draft7/enum.json b/tests/draft7/enum.json index ce43acc0..f085097b 100644 --- a/tests/draft7/enum.json +++ b/tests/draft7/enum.json @@ -154,27 +154,6 @@ } ] }, - { - "description": "enum with [false] does not match [0]", - "schema": {"enum": [[false]]}, - "tests": [ - { - "description": "[false] is valid", - "data": [false], - "valid": true - }, - { - "description": "[0] is invalid", - "data": [0], - "valid": false - }, - { - "description": "[0.0] is invalid", - "data": [0.0], - "valid": false - } - ] - }, { "description": "enum with true does not match 1", "schema": {"enum": [true]}, @@ -196,27 +175,6 @@ } ] }, - { - "description": "enum with [true] does not match [1]", - "schema": {"enum": [[true]]}, - "tests": [ - { - "description": "[true] is valid", - "data": [true], - "valid": true - }, - { - "description": "[1] is invalid", - "data": [1], - "valid": false - }, - { - "description": "[1.0] is invalid", - "data": [1.0], - "valid": false - } - ] - }, { "description": "enum with 0 does not match false", "schema": {"enum": [0]}, @@ -238,27 +196,6 @@ } ] }, - { - "description": "enum with [0] does not match [false]", - "schema": {"enum": [[0]]}, - "tests": [ - { - "description": "[false] is invalid", - "data": [false], - "valid": false - }, - { - "description": "[0] is valid", - "data": [0], - "valid": true - }, - { - "description": "[0.0] is valid", - "data": [0.0], - "valid": true - } - ] - }, { "description": "enum with 1 does not match true", "schema": {"enum": [1]}, @@ -280,27 +217,6 @@ } ] }, - { - "description": "enum with [1] does not match [true]", - "schema": {"enum": [[1]]}, - "tests": [ - { - "description": "[true] is invalid", - "data": [true], - "valid": false - }, - { - "description": "[1] is valid", - "data": [1], - "valid": true - }, - { - "description": "[1.0] is valid", - "data": [1.0], - "valid": true - } - ] - }, { "description": "nul characters in strings", "schema": { "enum": [ "hello\u0000there" ] }, diff --git a/tests/draft7/optional/id.json b/tests/draft7/id.json similarity index 100% rename from tests/draft7/optional/id.json rename to tests/draft7/id.json diff --git a/tests/draft7/maxLength.json b/tests/draft7/maxLength.json index be60c540..748b4daa 100644 --- a/tests/draft7/maxLength.json +++ b/tests/draft7/maxLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "two graphemes is long enough", + "description": "two supplementary Unicode code points is long enough", "data": "\uD83D\uDCA9\uD83D\uDCA9", "valid": true } diff --git a/tests/draft7/minLength.json b/tests/draft7/minLength.json index 23c68fe3..64db9480 100644 --- a/tests/draft7/minLength.json +++ b/tests/draft7/minLength.json @@ -24,7 +24,7 @@ "valid": true }, { - "description": "one grapheme is not long enough", + "description": "one supplementary Unicode code point is not long enough", "data": "\uD83D\uDCA9", "valid": false } diff --git a/tests/draft7/not.json b/tests/draft7/not.json index b46c4ed0..98de0eda 100644 --- a/tests/draft7/not.json +++ b/tests/draft7/not.json @@ -93,161 +93,19 @@ ] }, { - "description": "forbid everything with empty schema", - "schema": { "not": {} }, + "description": "not with boolean schema true", + "schema": {"not": true}, "tests": [ { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", + "description": "any value is invalid", "data": "foo", "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "forbid everything with boolean schema true", - "schema": { "not": true }, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "allow everything with boolean schema false", - "schema": { "not": false }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "boolean true is valid", - "data": true, - "valid": true - }, - { - "description": "boolean false is valid", - "data": false, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "object is valid", - "data": {"foo": "bar"}, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "array is valid", - "data": ["foo"], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true } ] }, { - "description": "double negation", - "schema": { "not": { "not": {} } }, + "description": "not with boolean schema false", + "schema": {"not": false}, "tests": [ { "description": "any value is valid", diff --git a/tests/draft7/oneOf.json b/tests/draft7/oneOf.json index c30a65c0..eeb7ae86 100644 --- a/tests/draft7/oneOf.json +++ b/tests/draft7/oneOf.json @@ -203,7 +203,7 @@ } ] }, - { + { "description": "oneOf with missing optional property", "schema": { "oneOf": [ diff --git a/tests/draft7/optional/format/hostname.json b/tests/draft7/optional/format/hostname.json index 866a6178..a8ecd194 100644 --- a/tests/draft7/optional/format/hostname.json +++ b/tests/draft7/optional/format/hostname.json @@ -112,16 +112,6 @@ "description": "single label ending with digit", "data": "hostnam3", "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - }, - { - "description": "single dot", - "data": ".", - "valid": false } ] } diff --git a/tests/draft7/optional/format/idn-hostname.json b/tests/draft7/optional/format/idn-hostname.json index 5c8cdc77..6c8f86a3 100644 --- a/tests/draft7/optional/format/idn-hostname.json +++ b/tests/draft7/optional/format/idn-hostname.json @@ -254,7 +254,7 @@ { "description": "Arabic-Indic digits mixed with Extended Arabic-Indic digits", "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8", - "data": "\u0628\u0660\u06f0", + "data": "\u0660\u06f0", "valid": false }, { @@ -298,80 +298,6 @@ "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement", "data": "\u0628\u064a\u200c\u0628\u064a", "valid": true - }, - { - "description": "single label", - "data": "hostname", - "valid": true - }, - { - "description": "single label with hyphen", - "data": "host-name", - "valid": true - }, - { - "description": "single label with digits", - "data": "h0stn4me", - "valid": true - }, - { - "description": "single label ending with digit", - "data": "hostnam3", - "valid": true - }, - { - "description": "empty string", - "data": "", - "valid": false - } - ] - }, - { - "description": "validation of separators in internationalized host names", - "specification": [ - {"rfc3490": "3.1", "quote": "Whenever dots are used as label separators, the following characters MUST be recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61(halfwidth ideographic full stop)"} - ], - "schema": { "format": "idn-hostname" }, - "tests": [ - { - "description": "single dot", - "data": ".", - "valid": false - }, - { - "description": "single ideographic full stop", - "data": "\u3002", - "valid": false - }, - { - "description": "single fullwidth full stop", - "data": "\uff0e", - "valid": false - }, - { - "description": "single halfwidth ideographic full stop", - "data": "\uff61", - "valid": false - }, - { - "description": "dot as label separator", - "data": "a.b", - "valid": true - }, - { - "description": "ideographic full stop as label separator", - "data": "a\u3002b", - "valid": true - }, - { - "description": "fullwidth full stop as label separator", - "data": "a\uff0eb", - "valid": true - }, - { - "description": "halfwidth ideographic full stop as label separator", - "data": "a\uff61b", - "valid": true } ] } diff --git a/tests/draft7/optional/format/ipv4.json b/tests/draft7/optional/format/ipv4.json index 9680fe62..4706581f 100644 --- a/tests/draft7/optional/format/ipv4.json +++ b/tests/draft7/optional/format/ipv4.json @@ -78,11 +78,6 @@ "description": "invalid non-ASCII '২' (a Bengali 2)", "data": "1২7.0.0.1", "valid": false - }, - { - "description": "netmask is not a part of ipv4 address", - "data": "192.168.1.0/24", - "valid": false } ] } diff --git a/tests/draft7/propertyNames.json b/tests/draft7/propertyNames.json index 7c7b8000..f0788e64 100644 --- a/tests/draft7/propertyNames.json +++ b/tests/draft7/propertyNames.json @@ -103,52 +103,5 @@ "valid": true } ] - }, - { - "description": "propertyNames with const", - "schema": {"propertyNames": {"const": "foo"}}, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"bar": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "propertyNames with enum", - "schema": {"propertyNames": {"enum": ["foo", "bar"]}}, - "tests": [ - { - "description": "object with property foo is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with property foo and bar is valid", - "data": {"foo": 1, "bar": 1}, - "valid": true - }, - { - "description": "object with any other property is invalid", - "data": {"baz": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] } ] diff --git a/tests/draft7/refRemote.json b/tests/draft7/refRemote.json index 450787af..115e12e7 100644 --- a/tests/draft7/refRemote.json +++ b/tests/draft7/refRemote.json @@ -17,7 +17,7 @@ }, { "description": "fragment within remote ref", - "schema": {"$ref": "http://localhost:1234/draft7/subSchemas.json#/definitions/integer"}, + "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, "tests": [ { "description": "remote fragment valid", @@ -34,7 +34,7 @@ { "description": "ref within remote ref", "schema": { - "$ref": "http://localhost:1234/draft7/subSchemas.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/subSchemas.json#/refToInteger" }, "tests": [ { @@ -139,7 +139,7 @@ "$id": "http://localhost:1234/object", "type": "object", "properties": { - "name": {"$ref": "draft7/name.json#/definitions/orNull"} + "name": {"$ref": "name.json#/definitions/orNull"} } }, "tests": [ @@ -173,7 +173,7 @@ "schema": { "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json", "allOf": [ - { "$ref": "draft7/ref-and-definitions.json" } + { "$ref": "ref-and-definitions.json" } ] }, "tests": [ @@ -196,7 +196,7 @@ { "description": "Location-independent identifier in remote ref", "schema": { - "$ref": "http://localhost:1234/draft7/locationIndependentIdentifier.json#/definitions/refToInteger" + "$ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger" }, "tests": [ { diff --git a/tests/draft7/optional/unknownKeyword.json b/tests/draft7/unknownKeyword.json similarity index 100% rename from tests/draft7/optional/unknownKeyword.json rename to tests/draft7/unknownKeyword.json From e3bc2dcda731844a21b4b20633386f65efd9c3f3 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Tue, 29 Apr 2025 11:13:05 +0200 Subject: [PATCH 5/6] Adapt test case generation from suite --- jsonschema/tests/test_jsonschema_test_suite.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/jsonschema/tests/test_jsonschema_test_suite.py b/jsonschema/tests/test_jsonschema_test_suite.py index 41c98255..9ff067f3 100644 --- a/jsonschema/tests/test_jsonschema_test_suite.py +++ b/jsonschema/tests/test_jsonschema_test_suite.py @@ -136,7 +136,6 @@ def leap_second(test): DRAFT4.format_cases(), DRAFT4.optional_cases_of(name="bignum"), DRAFT4.optional_cases_of(name="float-overflow"), - DRAFT4.optional_cases_of(name="id"), DRAFT4.optional_cases_of(name="non-bmp-regex"), DRAFT4.optional_cases_of(name="zeroTerminatedFloats"), Validator=jsonschema.Draft4Validator, @@ -155,7 +154,6 @@ def leap_second(test): DRAFT6.format_cases(), DRAFT6.optional_cases_of(name="bignum"), DRAFT6.optional_cases_of(name="float-overflow"), - DRAFT6.optional_cases_of(name="id"), DRAFT6.optional_cases_of(name="non-bmp-regex"), Validator=jsonschema.Draft6Validator, format_checker=jsonschema.Draft6Validator.FORMAT_CHECKER, @@ -174,9 +172,7 @@ def leap_second(test): DRAFT7.optional_cases_of(name="bignum"), DRAFT7.optional_cases_of(name="cross-draft"), DRAFT7.optional_cases_of(name="float-overflow"), - DRAFT6.optional_cases_of(name="id"), DRAFT7.optional_cases_of(name="non-bmp-regex"), - DRAFT7.optional_cases_of(name="unknownKeyword"), Validator=jsonschema.Draft7Validator, format_checker=jsonschema.Draft7Validator.FORMAT_CHECKER, skip=lambda test: ( @@ -190,15 +186,12 @@ def leap_second(test): TestDraft201909 = DRAFT201909.to_unittest_testcase( DRAFT201909.cases(), - DRAFT201909.optional_cases_of(name="anchor"), DRAFT201909.optional_cases_of(name="bignum"), DRAFT201909.optional_cases_of(name="cross-draft"), DRAFT201909.optional_cases_of(name="float-overflow"), - DRAFT201909.optional_cases_of(name="id"), DRAFT201909.optional_cases_of(name="no-schema"), DRAFT201909.optional_cases_of(name="non-bmp-regex"), DRAFT201909.optional_cases_of(name="refOfUnknownKeyword"), - DRAFT201909.optional_cases_of(name="unknownKeyword"), Validator=jsonschema.Draft201909Validator, skip=skip( message="Vocabulary support is still in-progress.", @@ -227,15 +220,12 @@ def leap_second(test): TestDraft202012 = DRAFT202012.to_unittest_testcase( DRAFT202012.cases(), - DRAFT201909.optional_cases_of(name="anchor"), DRAFT202012.optional_cases_of(name="bignum"), DRAFT202012.optional_cases_of(name="cross-draft"), DRAFT202012.optional_cases_of(name="float-overflow"), - DRAFT202012.optional_cases_of(name="id"), DRAFT202012.optional_cases_of(name="no-schema"), DRAFT202012.optional_cases_of(name="non-bmp-regex"), DRAFT202012.optional_cases_of(name="refOfUnknownKeyword"), - DRAFT202012.optional_cases_of(name="unknownKeyword"), Validator=jsonschema.Draft202012Validator, skip=skip( message="Vocabulary support is still in-progress.", From 2b6d928692e6faf2a6b27c270b36c18cf4d9beca Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" Date: Tue, 29 Apr 2025 12:03:41 +0200 Subject: [PATCH 6/6] Revert "Add test for unevaluatedProperties" This reverts commit 75218a4c4632ecafa722724fd338dc3598625764. --- jsonschema/tests/test_validators.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/jsonschema/tests/test_validators.py b/jsonschema/tests/test_validators.py index 309229ee..28cc4027 100644 --- a/jsonschema/tests/test_validators.py +++ b/jsonschema/tests/test_validators.py @@ -742,14 +742,6 @@ def test_unevaluated_properties_on_invalid_type(self): message = self.message_for(instance="foo", schema=schema) self.assertEqual(message, "'foo' is not of type 'object'") - def test_unevaluated_properties_with_additional_properties(self): - schema = { - "additionalProperties": {"type": "string"}, - "unevaluatedProperties": False, - } - validator = validators._LATEST_VERSION(schema) - validator.validate(instance={"foo": "foo"}) - def test_single_item(self): schema = {"prefixItems": [{}], "items": False} message = self.message_for(