├── .github ├── FUNDING.yml ├── SECURITY.md ├── dependabot.yml ├── release.yml └── workflows │ ├── ci.yml │ ├── documentation-links.yml │ └── zizmor.yml ├── .gitignore ├── .pre-commit-config.yaml ├── .pre-commit-hooks.yaml ├── .readthedocs.yaml ├── CHANGELOG.rst ├── CONTRIBUTING.rst ├── COPYING ├── README.rst ├── docs ├── Makefile ├── api │ ├── index.rst │ └── jsonschema │ │ ├── exceptions │ │ └── index.rst │ │ ├── protocols │ │ └── index.rst │ │ └── validators │ │ └── index.rst ├── conf.py ├── creating.rst ├── errors.rst ├── faq.rst ├── index.rst ├── make.bat ├── referencing.rst ├── requirements.in ├── requirements.txt ├── spelling-wordlist.txt └── validate.rst ├── json ├── .editorconfig ├── .github │ ├── CODEOWNERS │ └── workflows │ │ ├── annotation-tests.yml │ │ ├── ci.yml │ │ ├── pr-dependencies.yml │ │ └── show_specification_annotations.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── annotations │ ├── README.md │ ├── assertion.schema.json │ ├── test-case.schema.json │ ├── test-suite.schema.json │ ├── test.schema.json │ └── tests │ │ ├── applicators.json │ │ ├── content.json │ │ ├── core.json │ │ ├── format.json │ │ ├── meta-data.json │ │ ├── unevaluated.json │ │ └── unknown.json ├── bin │ ├── annotate-specification-links │ ├── annotation-tests.ts │ ├── jsonschema_suite │ └── specification_urls.json ├── output-test-schema.json ├── output-tests │ ├── README.md │ ├── draft-next │ │ ├── content │ │ │ ├── general.json │ │ │ ├── readOnly.json │ │ │ └── type.json │ │ └── output-schema.json │ ├── draft2019-09 │ │ ├── content │ │ │ ├── escape.json │ │ │ ├── general.json │ │ │ ├── readOnly.json │ │ │ └── type.json │ │ └── output-schema.json │ └── draft2020-12 │ │ ├── content │ │ ├── escape.json │ │ ├── general.json │ │ ├── readOnly.json │ │ └── type.json │ │ └── output-schema.json ├── package.json ├── remotes │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── different-id-ref-string.json │ ├── draft-next │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── detached-dynamicref.json │ │ ├── detached-ref.json │ │ ├── extendible-dynamic-ref.json │ │ ├── format-assertion-false.json │ │ ├── format-assertion-true.json │ │ ├── integer.json │ │ ├── locationIndependentIdentifier.json │ │ ├── metaschema-no-validation.json │ │ ├── metaschema-optional-vocabulary.json │ │ ├── name-defs.json │ │ ├── nested │ │ │ ├── foo-ref-string.json │ │ │ └── string.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── draft2019-09 │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── dependentRequired.json │ │ ├── detached-ref.json │ │ ├── extendible-dynamic-ref.json │ │ ├── ignore-prefixItems.json │ │ ├── integer.json │ │ ├── locationIndependentIdentifier.json │ │ ├── metaschema-no-validation.json │ │ ├── metaschema-optional-vocabulary.json │ │ ├── name-defs.json │ │ ├── nested │ │ │ ├── foo-ref-string.json │ │ │ └── string.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── draft2020-12 │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── detached-dynamicref.json │ │ ├── detached-ref.json │ │ ├── extendible-dynamic-ref.json │ │ ├── format-assertion-false.json │ │ ├── format-assertion-true.json │ │ ├── integer.json │ │ ├── locationIndependentIdentifier.json │ │ ├── metaschema-no-validation.json │ │ ├── metaschema-optional-vocabulary.json │ │ ├── name-defs.json │ │ ├── nested │ │ │ ├── foo-ref-string.json │ │ │ └── string.json │ │ ├── prefixItems.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── draft3 │ │ └── subSchemas.json │ ├── draft4 │ │ ├── locationIndependentIdentifier.json │ │ ├── name.json │ │ └── subSchemas.json │ ├── draft6 │ │ ├── detached-ref.json │ │ ├── locationIndependentIdentifier.json │ │ ├── name.json │ │ ├── ref-and-definitions.json │ │ └── subSchemas.json │ ├── draft7 │ │ ├── detached-ref.json │ │ ├── ignore-dependentRequired.json │ │ ├── locationIndependentIdentifier.json │ │ ├── name.json │ │ ├── ref-and-definitions.json │ │ └── subSchemas.json │ ├── extendible-dynamic-ref.json │ ├── integer.json │ ├── locationIndependentIdentifier.json │ ├── name-defs.json │ ├── nested-absolute-ref-to-string.json │ ├── nested │ │ ├── foo-ref-string.json │ │ └── string.json │ ├── ref-and-defs.json │ ├── tree.json │ └── urn-ref-string.json ├── test-schema.json ├── tests │ ├── draft-next │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anchor.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── content.json │ │ ├── default.json │ │ ├── defs.json │ │ ├── dependentRequired.json │ │ ├── dependentSchemas.json │ │ ├── dynamicRef.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxContains.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minContains.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── anchor.json │ │ │ ├── bignum.json │ │ │ ├── dependencies-compatibility.json │ │ │ ├── dynamicRef.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format-assertion.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── duration.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ ├── uri.json │ │ │ │ └── uuid.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ ├── refOfUnknownKeyword.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── prefixItems.json │ │ ├── properties.json │ │ ├── propertyDependencies.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ ├── unevaluatedItems.json │ │ ├── unevaluatedProperties.json │ │ ├── uniqueItems.json │ │ └── vocabulary.json │ ├── draft2019-09 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anchor.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── content.json │ │ ├── default.json │ │ ├── defs.json │ │ ├── dependentRequired.json │ │ ├── dependentSchemas.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxContains.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minContains.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── anchor.json │ │ │ ├── bignum.json │ │ │ ├── cross-draft.json │ │ │ ├── dependencies-compatibility.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── duration.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ ├── uri.json │ │ │ │ └── uuid.json │ │ │ ├── id.json │ │ │ ├── no-schema.json │ │ │ ├── non-bmp-regex.json │ │ │ ├── refOfUnknownKeyword.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── recursiveRef.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ ├── unevaluatedItems.json │ │ ├── unevaluatedProperties.json │ │ ├── uniqueItems.json │ │ └── vocabulary.json │ ├── draft2020-12 │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anchor.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── content.json │ │ ├── default.json │ │ ├── defs.json │ │ ├── dependentRequired.json │ │ ├── dependentSchemas.json │ │ ├── dynamicRef.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxContains.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minContains.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── anchor.json │ │ │ ├── bignum.json │ │ │ ├── cross-draft.json │ │ │ ├── dependencies-compatibility.json │ │ │ ├── dynamicRef.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format-assertion.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── duration.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ ├── uri.json │ │ │ │ └── uuid.json │ │ │ ├── id.json │ │ │ ├── no-schema.json │ │ │ ├── non-bmp-regex.json │ │ │ ├── refOfUnknownKeyword.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── prefixItems.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ ├── unevaluatedItems.json │ │ ├── unevaluatedProperties.json │ │ ├── uniqueItems.json │ │ └── vocabulary.json │ ├── draft3 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── default.json │ │ ├── dependencies.json │ │ ├── disallow.json │ │ ├── divisibleBy.json │ │ ├── enum.json │ │ ├── extends.json │ │ ├── format.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minimum.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── format │ │ │ │ ├── color.json │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── email.json │ │ │ │ ├── host-name.json │ │ │ │ ├── ip-address.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── regex.json │ │ │ │ ├── time.json │ │ │ │ └── uri.json │ │ │ ├── non-bmp-regex.json │ │ │ └── zeroTerminatedFloats.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ ├── draft4 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anyOf.json │ │ ├── default.json │ │ ├── definitions.json │ │ ├── dependencies.json │ │ ├── enum.json │ │ ├── format.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── unknown.json │ │ │ │ └── uri.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ └── zeroTerminatedFloats.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ ├── draft6 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── default.json │ │ ├── definitions.json │ │ ├── dependencies.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ └── uri.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ ├── draft7 │ │ ├── additionalItems.json │ │ ├── additionalProperties.json │ │ ├── allOf.json │ │ ├── anyOf.json │ │ ├── boolean_schema.json │ │ ├── const.json │ │ ├── contains.json │ │ ├── default.json │ │ ├── definitions.json │ │ ├── dependencies.json │ │ ├── enum.json │ │ ├── exclusiveMaximum.json │ │ ├── exclusiveMinimum.json │ │ ├── format.json │ │ ├── if-then-else.json │ │ ├── infinite-loop-detection.json │ │ ├── items.json │ │ ├── maxItems.json │ │ ├── maxLength.json │ │ ├── maxProperties.json │ │ ├── maximum.json │ │ ├── minItems.json │ │ ├── minLength.json │ │ ├── minProperties.json │ │ ├── minimum.json │ │ ├── multipleOf.json │ │ ├── not.json │ │ ├── oneOf.json │ │ ├── optional │ │ │ ├── bignum.json │ │ │ ├── content.json │ │ │ ├── cross-draft.json │ │ │ ├── ecmascript-regex.json │ │ │ ├── float-overflow.json │ │ │ ├── format │ │ │ │ ├── date-time.json │ │ │ │ ├── date.json │ │ │ │ ├── email.json │ │ │ │ ├── hostname.json │ │ │ │ ├── idn-email.json │ │ │ │ ├── idn-hostname.json │ │ │ │ ├── ipv4.json │ │ │ │ ├── ipv6.json │ │ │ │ ├── iri-reference.json │ │ │ │ ├── iri.json │ │ │ │ ├── json-pointer.json │ │ │ │ ├── regex.json │ │ │ │ ├── relative-json-pointer.json │ │ │ │ ├── time.json │ │ │ │ ├── unknown.json │ │ │ │ ├── uri-reference.json │ │ │ │ ├── uri-template.json │ │ │ │ └── uri.json │ │ │ ├── id.json │ │ │ ├── non-bmp-regex.json │ │ │ └── unknownKeyword.json │ │ ├── pattern.json │ │ ├── patternProperties.json │ │ ├── properties.json │ │ ├── propertyNames.json │ │ ├── ref.json │ │ ├── refRemote.json │ │ ├── required.json │ │ ├── type.json │ │ └── uniqueItems.json │ └── latest └── tox.ini ├── jsonschema ├── __init__.py ├── __main__.py ├── _format.py ├── _keywords.py ├── _legacy_keywords.py ├── _types.py ├── _typing.py ├── _utils.py ├── benchmarks │ ├── __init__.py │ ├── const_vs_enum.py │ ├── contains.py │ ├── issue232.py │ ├── issue232 │ │ └── issue.json │ ├── json_schema_test_suite.py │ ├── nested_schemas.py │ ├── subcomponents.py │ ├── unused_registry.py │ ├── useless_applicator_schemas.py │ ├── useless_keywords.py │ └── validator_creation.py ├── cli.py ├── exceptions.py ├── protocols.py ├── tests │ ├── __init__.py │ ├── _suite.py │ ├── fuzz_validate.py │ ├── test_cli.py │ ├── test_deprecations.py │ ├── test_exceptions.py │ ├── test_format.py │ ├── test_jsonschema_test_suite.py │ ├── test_types.py │ ├── test_utils.py │ └── test_validators.py └── validators.py ├── noxfile.py └── pyproject.toml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: "Julian" 4 | tidelift: "pypi/jsonschema" 5 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | In general, only the latest released `jsonschema` version is supported and will receive updates. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | To report a security vulnerability, please send an email to `Julian+Security@GrayVines.com` with subject line `SECURITY (jsonschema)`. 10 | I will do my best to respond within 48 hours to acknowledge the message and discuss further steps. 11 | If the vulnerability is accepted, an advisory will be sent out via GitHub's security advisory functionality. 12 | 13 | For non-sensitive discussion related to this policy itself, feel free to open an issue on the issue tracker. 14 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | 8 | - package-ecosystem: "pip" 9 | directory: "/docs" 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | authors: 4 | - dependabot 5 | - pre-commit-ci 6 | -------------------------------------------------------------------------------- /.github/workflows/documentation-links.yml: -------------------------------------------------------------------------------- 1 | name: Read the Docs Pull Request Preview 2 | on: 3 | pull_request_target: # zizmor: ignore[dangerous-triggers] 4 | types: 5 | - opened 6 | 7 | permissions: 8 | pull-requests: write 9 | 10 | jobs: 11 | documentation-links: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: readthedocs/actions/preview@b8bba1484329bda1a3abe986df7ebc80a8950333 15 | with: 16 | project-slug: "python-jsonschema" 17 | -------------------------------------------------------------------------------- /.github/workflows/zizmor.yml: -------------------------------------------------------------------------------- 1 | name: GitHub Actions Security Analysis with zizmor 🌈 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | pull_request: 7 | branches: ["**"] 8 | 9 | jobs: 10 | zizmor: 11 | name: Run zizmor 12 | runs-on: ubuntu-latest 13 | permissions: 14 | security-events: write 15 | 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v4 19 | with: 20 | persist-credentials: false 21 | 22 | - name: Install uv 23 | uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb 24 | 25 | - name: Run zizmor 🌈 26 | run: uvx zizmor --format=sarif .github > results.sarif 27 | 28 | env: 29 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | 31 | - name: Upload SARIF file 32 | uses: github/codeql-action/upload-sarif@v3 33 | with: 34 | sarif_file: results.sarif 35 | category: zizmor 36 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: json/ 2 | 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v5.0.0 6 | hooks: 7 | - id: check-ast 8 | - id: check-json 9 | - id: check-toml 10 | - id: check-vcs-permalinks 11 | - id: check-yaml 12 | - id: debug-statements 13 | exclude: "^jsonschema/tests/_suite.py$" 14 | - id: end-of-file-fixer 15 | - id: mixed-line-ending 16 | args: [--fix, lf] 17 | - id: trailing-whitespace 18 | - repo: https://github.com/astral-sh/ruff-pre-commit 19 | rev: "v0.11.11" 20 | hooks: 21 | - id: ruff 22 | args: [--fix, --exit-non-zero-on-fix] 23 | -------------------------------------------------------------------------------- /.pre-commit-hooks.yaml: -------------------------------------------------------------------------------- 1 | - id: jsonschema 2 | name: jsonschema 3 | description: json schema validation 4 | language: python 5 | pass_filenames: false 6 | entry: jsonschema 7 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | build: 4 | os: ubuntu-22.04 5 | apt_packages: 6 | - inkscape 7 | tools: 8 | python: "3.11" 9 | 10 | sphinx: 11 | builder: dirhtml 12 | configuration: docs/conf.py 13 | fail_on_warning: true 14 | 15 | formats: all 16 | 17 | python: 18 | install: 19 | - requirements: docs/requirements.txt 20 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Julian Berman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /docs/api/index.rst: -------------------------------------------------------------------------------- 1 | API Reference 2 | ============= 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | :titlesonly: 9 | 10 | /api/jsonschema/validators/index 11 | /api/jsonschema/exceptions/index 12 | /api/jsonschema/protocols/index 13 | 14 | :mod:`jsonschema` 15 | ----------------- 16 | 17 | .. automodule:: jsonschema 18 | :members: 19 | :imported-members: 20 | :exclude-members: FormatError, Validator, ValidationError 21 | 22 | .. autodata:: jsonschema._format._F 23 | 24 | .. autodata:: jsonschema._typing.id_of 25 | -------------------------------------------------------------------------------- /docs/api/jsonschema/exceptions/index.rst: -------------------------------------------------------------------------------- 1 | :py:mod:`jsonschema.exceptions` 2 | =============================== 3 | 4 | .. automodule:: jsonschema.exceptions 5 | :members: 6 | :undoc-members: 7 | -------------------------------------------------------------------------------- /docs/api/jsonschema/protocols/index.rst: -------------------------------------------------------------------------------- 1 | :py:mod:`jsonschema.protocols` 2 | ============================== 3 | 4 | .. automodule:: jsonschema.protocols 5 | :members: 6 | :undoc-members: 7 | -------------------------------------------------------------------------------- /docs/api/jsonschema/validators/index.rst: -------------------------------------------------------------------------------- 1 | :py:mod:`jsonschema.validators` 2 | =============================== 3 | 4 | .. automodule:: jsonschema.validators 5 | :members: 6 | :undoc-members: 7 | :private-members: _RefResolver 8 | -------------------------------------------------------------------------------- /docs/creating.rst: -------------------------------------------------------------------------------- 1 | .. currentmodule:: jsonschema.validators 2 | 3 | .. _creating-validators: 4 | 5 | ======================================= 6 | Creating or Extending Validator Classes 7 | ======================================= 8 | 9 | .. autofunction:: create 10 | :noindex: 11 | 12 | .. autofunction:: extend 13 | :noindex: 14 | 15 | .. autofunction:: validator_for 16 | :noindex: 17 | 18 | .. autofunction:: validates 19 | :noindex: 20 | 21 | 22 | Creating Validation Errors 23 | -------------------------- 24 | 25 | Any validating function that validates against a subschema should call 26 | ``descend``, rather than ``iter_errors``. If it recurses into the 27 | instance, or schema, it should pass one or both of the ``path`` or 28 | ``schema_path`` arguments to ``descend`` in order to properly maintain 29 | where in the instance or schema respectively the error occurred. 30 | 31 | The Validator Protocol 32 | ---------------------- 33 | 34 | ``jsonschema`` defines a `protocol `, `jsonschema.protocols.Validator` which can be used in type annotations to describe the type of a validator. 35 | 36 | For full details, see `validator-protocol`. 37 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. module:: jsonschema 2 | :noindex: 3 | 4 | .. include:: ../README.rst 5 | 6 | 7 | Contents 8 | -------- 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | validate 14 | errors 15 | referencing 16 | creating 17 | faq 18 | api/index 19 | 20 | 21 | Indices and tables 22 | ================== 23 | 24 | * `genindex` 25 | -------------------------------------------------------------------------------- /docs/requirements.in: -------------------------------------------------------------------------------- 1 | file:. 2 | furo 3 | lxml 4 | sphinx!=7.2.5 5 | sphinx-autoapi 6 | sphinx-autodoc-typehints 7 | sphinx-copybutton 8 | sphinx-json-schema-spec 9 | sphinxcontrib-spelling 10 | sphinxext-opengraph 11 | -------------------------------------------------------------------------------- /docs/spelling-wordlist.txt: -------------------------------------------------------------------------------- 1 | # this appears to be misinterpreting Napoleon types as prose, sigh... 2 | Validator 3 | TypeChecker 4 | UnknownType 5 | ValidationError 6 | 7 | # 0th, sigh... 8 | th 9 | amongst 10 | callables 11 | # non-codeblocked cls from autoapi 12 | cls 13 | deque 14 | deduplication 15 | dereferences 16 | deserialize 17 | deserialized 18 | deserializing 19 | filesystem 20 | hostname 21 | implementers 22 | indices 23 | # ipv4/6, sigh... 24 | ipv 25 | iterable 26 | iteratively 27 | Javascript 28 | jsonschema 29 | majorly 30 | metaschema 31 | online 32 | outputter 33 | pre 34 | programmatically 35 | pseudocode 36 | recurses 37 | regex 38 | repr 39 | runtime 40 | sensical 41 | subclassing 42 | submodule 43 | submodules 44 | subschema 45 | subschemas 46 | subscopes 47 | untrusted 48 | uri 49 | validator 50 | validators 51 | versioned 52 | schemas 53 | 54 | Zac 55 | HD 56 | 57 | Berman 58 | Libera 59 | GPL 60 | -------------------------------------------------------------------------------- /json/.editorconfig: -------------------------------------------------------------------------------- 1 | insert_final_newline = true 2 | -------------------------------------------------------------------------------- /json/.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Ping the entire test suite team by default. 2 | * @json-schema-org/test-suite-team 3 | -------------------------------------------------------------------------------- /json/.github/workflows/annotation-tests.yml: -------------------------------------------------------------------------------- 1 | name: Validate annotation tests 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - "annotations/**" 7 | 8 | jobs: 9 | annotate: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Set up Deno 16 | uses: denoland/setup-deno@v2 17 | with: 18 | deno-version: "2.x" 19 | 20 | - name: Validate annotation tests 21 | run: deno --node-modules-dir=auto --allow-read --no-prompt bin/annotation-tests.ts 22 | -------------------------------------------------------------------------------- /json/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Test Suite Sanity Checking 2 | 3 | on: 4 | push: 5 | pull_request: 6 | release: 7 | types: [published] 8 | schedule: 9 | # Daily at 6:42, arbitrarily as a time that's possibly non-busy 10 | - cron: '42 6 * * *' 11 | 12 | jobs: 13 | ci: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Set up Python 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: '3.x' 22 | - name: Install tox 23 | run: python -m pip install tox 24 | - name: Run the sanity checks 25 | run: python -m tox 26 | -------------------------------------------------------------------------------- /json/.github/workflows/pr-dependencies.yml: -------------------------------------------------------------------------------- 1 | name: Check PR Dependencies 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | check_dependencies: 7 | runs-on: ubuntu-latest 8 | name: Check Dependencies 9 | steps: 10 | - uses: gregsdennis/dependencies-action@main 11 | env: 12 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /json/.github/workflows/show_specification_annotations.yml: -------------------------------------------------------------------------------- 1 | name: Show Specification Annotations 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - 'tests/**' 7 | 8 | jobs: 9 | annotate: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v4 14 | 15 | - name: Set up Python 16 | uses: actions/setup-python@v5 17 | with: 18 | python-version: '3.x' 19 | 20 | - name: Generate Annotations 21 | run: pip install uritemplate && bin/annotate-specification-links 22 | -------------------------------------------------------------------------------- /json/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Julian Berman 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /json/annotations/assertion.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | 4 | "type": "object", 5 | "properties": { 6 | "location": { 7 | "markdownDescription": "The instance location.", 8 | "type": "string", 9 | "format": "json-pointer" 10 | }, 11 | "keyword": { 12 | "markdownDescription": "The annotation keyword.", 13 | "type": "string" 14 | }, 15 | "expected": { 16 | "markdownDescription": "An object of schemaLocation/annotations pairs for `keyword` annotations expected on the instance at `location`.", 17 | "type": "object", 18 | "propertyNames": { 19 | "format": "uri" 20 | } 21 | } 22 | }, 23 | "required": ["location", "keyword", "expected"] 24 | } 25 | -------------------------------------------------------------------------------- /json/annotations/test-case.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | 4 | "type": "object", 5 | "properties": { 6 | "description": { 7 | "markdownDescription": "A short description of what behavior the Test Case is covering.", 8 | "type": "string" 9 | }, 10 | "compatibility": { 11 | "markdownDescription": "Set which dialects the Test Case is compatible with. Examples:\n- `\"7\"` -- draft-07 and above\n- `\"<=2019\"` -- 2019-09 and previous\n- `\"6,<=2019\"` -- Between draft-06 and 2019-09\n- `\"=2020\"` -- 2020-12 only", 12 | "type": "string", 13 | "pattern": "^(<=|=)?([123467]|2019|2020)(,(<=|=)?([123467]|2019|2020))*$" 14 | }, 15 | "schema": { 16 | "markdownDescription": "This schema shouldn't include `$schema` or `id`/`$id` unless necesary for the test because Test Cases should be designed to work with as many releases as possible.", 17 | "type": ["boolean", "object"] 18 | }, 19 | "externalSchemas": { 20 | "markdownDescription": "The keys are retrieval URIs and values are schemas.", 21 | "type": "object", 22 | "patternProperties": { 23 | "": { 24 | "type": ["boolean", "object"] 25 | } 26 | }, 27 | "propertyNames": { 28 | "format": "uri" 29 | } 30 | }, 31 | "tests": { 32 | "markdownDescription": "A collection of Tests to run to verify the Test Case.", 33 | "type": "array", 34 | "items": { "$ref": "./test.schema.json" } 35 | } 36 | }, 37 | "required": ["description", "schema", "tests"] 38 | } 39 | -------------------------------------------------------------------------------- /json/annotations/test-suite.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | 4 | "type": "object", 5 | "properties": { 6 | "description": { 7 | "type": "string" 8 | }, 9 | "suite": { 10 | "type": "array", 11 | "items": { "$ref": "./test-case.schema.json" } 12 | } 13 | }, 14 | "required": ["description", "suite"] 15 | } 16 | -------------------------------------------------------------------------------- /json/annotations/test.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | 4 | "type": "object", 5 | "properties": { 6 | "instance": { 7 | "markdownDescription": "The JSON instance to be annotated." 8 | }, 9 | "assertions": { 10 | "markdownDescription": "A collection of assertions that must be true for the test to pass.", 11 | "type": "array", 12 | "items": { "$ref": "./assertion.schema.json" } 13 | } 14 | }, 15 | "required": ["instance", "assertions"] 16 | } 17 | -------------------------------------------------------------------------------- /json/annotations/tests/core.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../test-suite.schema.json", 3 | "description": "The core vocabulary", 4 | "suite": [ 5 | { 6 | "description": "`$ref` and `$defs`", 7 | "compatibility": "2019", 8 | "schema": { 9 | "$ref": "#/$defs/foo", 10 | "$defs": { 11 | "foo": { "title": "Foo" } 12 | } 13 | }, 14 | "tests": [ 15 | { 16 | "instance": "foo", 17 | "assertions": [ 18 | { 19 | "location": "", 20 | "keyword": "title", 21 | "expected": { 22 | "#/$defs/foo": "Foo" 23 | } 24 | } 25 | ] 26 | } 27 | ] 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /json/annotations/tests/format.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../test-suite.schema.json", 3 | "description": "The format vocabulary", 4 | "suite": [ 5 | { 6 | "description": "`format` is an annotation", 7 | "schema": { 8 | "format": "email" 9 | }, 10 | "tests": [ 11 | { 12 | "instance": "foo@bar.com", 13 | "assertions": [ 14 | { 15 | "location": "", 16 | "keyword": "format", 17 | "expected": { 18 | "#": "email" 19 | } 20 | } 21 | ] 22 | } 23 | ] 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /json/annotations/tests/unknown.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../test-suite.schema.json", 3 | "description": "Unknown keywords", 4 | "suite": [ 5 | { 6 | "description": "`unknownKeyword` is an annotation", 7 | "schema": { 8 | "$schema": "https://json-schema.org/draft/2020-12/schema", 9 | "x-unknownKeyword": "Foo" 10 | }, 11 | "tests": [ 12 | { 13 | "instance": 42, 14 | "assertions": [ 15 | { 16 | "location": "", 17 | "keyword": "x-unknownKeyword", 18 | "expected": { 19 | "#": "Foo" 20 | } 21 | } 22 | ] 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /json/bin/annotation-tests.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env deno 2 | import { validate } from "npm:@hyperjump/json-schema/draft-07"; 3 | import { BASIC } from "npm:@hyperjump/json-schema/experimental"; 4 | 5 | const validateTestSuite = await validate("./annotations/test-suite.schema.json"); 6 | 7 | console.log("Validating annotation tests ..."); 8 | 9 | let isValid = true; 10 | for await (const entry of Deno.readDir("./annotations/tests")) { 11 | if (entry.isFile) { 12 | const json = await Deno.readTextFile(`./annotations/tests/${entry.name}`); 13 | const suite = JSON.parse(json); 14 | 15 | const output = validateTestSuite(suite, BASIC); 16 | 17 | if (output.valid) { 18 | console.log(`\x1b[32m✔\x1b[0m ${entry.name}`); 19 | } else { 20 | isValid = false; 21 | console.log(`\x1b[31m✖\x1b[0m ${entry.name}`); 22 | console.log(output); 23 | } 24 | } 25 | } 26 | 27 | console.log("Done."); 28 | 29 | if (!isValid) { 30 | Deno.exit(1); 31 | } 32 | -------------------------------------------------------------------------------- /json/bin/specification_urls.json: -------------------------------------------------------------------------------- 1 | { 2 | "json-schema": { 3 | "draft2020-12": { 4 | "core": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-01#section-{section}", 5 | "validation": "https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-{section}" 6 | }, 7 | "draft2019-09": { 8 | "core": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#rfc.section.{section}", 9 | "validation": "https://json-schema.org/draft/2019-09/draft-handrews-json-schema-validation-02#rfc.section.{section}" 10 | }, 11 | "draft7": { 12 | "core": "https://json-schema.org/draft-07/draft-handrews-json-schema-01#rfc.section.{section}", 13 | "validation": "https://json-schema.org/draft-07/draft-handrews-json-schema-validation-01#rfc.section.{section}" 14 | }, 15 | "draft6": { 16 | "core": "https://json-schema.org/draft-06/draft-wright-json-schema-01#rfc.section.{section}", 17 | "validation": "https://json-schema.org/draft-06/draft-wright-json-schema-validation-01#rfc.section.{section}" 18 | }, 19 | "draft4": { 20 | "core": "https://json-schema.org/draft-04/draft-zyp-json-schema-04#rfc.section.{section}", 21 | "validation": "https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.{section}" 22 | }, 23 | "draft3": { 24 | "core": "https://json-schema.org/draft-03/draft-zyp-json-schema-03.pdf" 25 | } 26 | }, 27 | 28 | "external": { 29 | "ecma262": "https://262.ecma-international.org/{section}", 30 | "perl5": "https://perldoc.perl.org/perlre#{section}", 31 | "rfc": "https://www.rfc-editor.org/rfc/rfc{spec}.html#section-{section}", 32 | "iso": "https://www.iso.org/obp/ui" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /json/output-tests/draft-next/content/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "incorrect type", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$id": "https://json-schema.org/tests/content/draft-next/type/0", 7 | "type": "string" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "incorrect type must be reported, but a message is not required", 12 | "data": 1, 13 | "output": { 14 | "list": { 15 | "$id": "https://json-schema.org/tests/content/draft-next/type/0/tests/0/basic", 16 | "$ref": "/draft/next/output/schema", 17 | "properties": { 18 | "details": { 19 | "contains": { 20 | "properties": { 21 | "evaluationPath": {"const": ""}, 22 | "schemaLocation": {"const": "https://json-schema.org/tests/content/draft-next/type/0#"}, 23 | "instanceLocation": {"const": ""}, 24 | "annotations": false, 25 | "errors": { 26 | "required": ["type"] 27 | } 28 | }, 29 | "required": ["evaluationPath", "schemaLocation", "instanceLocation"] 30 | } 31 | } 32 | }, 33 | "required": ["details"] 34 | } 35 | } 36 | } 37 | ] 38 | } 39 | ] 40 | -------------------------------------------------------------------------------- /json/output-tests/draft2019-09/content/escape.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "tilde and forward slash in json-pointer", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2019-09/escape/0", 7 | "properties": { 8 | "~a/b": {"type": "number"} 9 | } 10 | }, 11 | "tests": [ 12 | { 13 | "description": "incorrect type must be reported, but a message is not required", 14 | "data": {"~a/b": "foobar"}, 15 | "output": { 16 | "basic": { 17 | "$id": "https://json-schema.org/tests/content/draft2019-09/escape/0/tests/0/basic", 18 | "$ref": "/draft/2019-09/output/schema", 19 | "properties": { 20 | "errors": { 21 | "contains": { 22 | "properties": { 23 | "keywordLocation": {"const": "/properties/~0a~1b/type"}, 24 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/escape/0#/properties/~0a~1b/type"}, 25 | "instanceLocation": {"const": "/~0a~1b"}, 26 | "annotation": false 27 | }, 28 | "required": ["keywordLocation", "instanceLocation"] 29 | } 30 | } 31 | }, 32 | "required": ["errors"] 33 | } 34 | } 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /json/output-tests/draft2019-09/content/general.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "failed validation produces no annotations", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2019-09/general/0", 7 | "type": "string", 8 | "readOnly": true 9 | }, 10 | "tests": [ 11 | { 12 | "description": "readOnly annotation is dropped", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2019-09/general/0/tests/0/basic", 17 | "$ref": "/draft/2019-09/output/schema", 18 | "properties": { 19 | "errors": { 20 | "items": { 21 | "properties": { 22 | "annotation": false 23 | } 24 | } 25 | }, 26 | "annotations": false 27 | }, 28 | "required": ["errors"] 29 | } 30 | } 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /json/output-tests/draft2019-09/content/readOnly.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "readOnly generates its value as an annotation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2019-09/readOnly/0", 7 | "readOnly": true 8 | }, 9 | "tests": [ 10 | { 11 | "description": "readOnly is true", 12 | "data": 1, 13 | "output": { 14 | "basic": { 15 | "$id": "https://json-schema.org/tests/content/draft2019-09/readOnly/0/tests/0/basic", 16 | "$ref": "/draft/2019-09/output/schema", 17 | "properties": { 18 | "annotations": { 19 | "contains": { 20 | "type": "object", 21 | "properties": { 22 | "keywordLocation": {"const": "/readOnly"}, 23 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/readOnly/0#/readOnly"}, 24 | "instanceLocation": {"const": ""}, 25 | "annotation": {"const": true} 26 | }, 27 | "required": ["keywordLocation", "instanceLocation", "annotation"] 28 | } 29 | }, 30 | "errors": false 31 | }, 32 | "required": ["annotations"] 33 | } 34 | } 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /json/output-tests/draft2019-09/content/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validating type", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2019-09/type/0", 7 | "type": "string", 8 | "anyOf": [ true ] 9 | }, 10 | "tests": [ 11 | { 12 | "description": "incorrect type must be reported, but a message is not required", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2019-09/type/0/tests/0/basic", 17 | "$ref": "/draft/2019-09/output/schema", 18 | "properties": { 19 | "errors": { 20 | "contains": { 21 | "properties": { 22 | "keywordLocation": {"const": "/type"}, 23 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2019-09/type/0#/type"}, 24 | "instanceLocation": {"const": ""}, 25 | "annotation": false 26 | }, 27 | "required": ["keywordLocation", "instanceLocation"] 28 | } 29 | } 30 | }, 31 | "required": ["errors"] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /json/output-tests/draft2020-12/content/escape.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "tilde and forward slash in json-pointer", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/escape/0", 7 | "properties": { 8 | "~a/b": {"type": "number"} 9 | } 10 | }, 11 | "tests": [ 12 | { 13 | "description": "incorrect type must be reported, but a message is not required", 14 | "data": {"~a/b": "foobar"}, 15 | "output": { 16 | "basic": { 17 | "$id": "https://json-schema.org/tests/content/draft2020-12/escape/0/tests/0/basic", 18 | "$ref": "/draft/2020-12/output/schema", 19 | "properties": { 20 | "errors": { 21 | "contains": { 22 | "properties": { 23 | "keywordLocation": {"const": "/properties/~0a~1b/type"}, 24 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/escape/0#/properties/~0a~1b/type"}, 25 | "instanceLocation": {"const": "/~0a~1b"}, 26 | "annotation": false 27 | }, 28 | "required": ["keywordLocation", "instanceLocation"] 29 | } 30 | } 31 | }, 32 | "required": ["errors"] 33 | } 34 | } 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /json/output-tests/draft2020-12/content/general.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "failed validation produces no annotations", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/general/0", 7 | "type": "string", 8 | "readOnly": true 9 | }, 10 | "tests": [ 11 | { 12 | "description": "readOnly annotation is dropped", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2020-12/general/0/tests/0/basic", 17 | "$ref": "/draft/2020-12/output/schema", 18 | "properties": { 19 | "errors": { 20 | "items": { 21 | "properties": { 22 | "annotation": false 23 | } 24 | } 25 | }, 26 | "annotations": false 27 | }, 28 | "required": ["errors"] 29 | } 30 | } 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /json/output-tests/draft2020-12/content/readOnly.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "readOnly generates its value as an annotation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/readOnly/0", 7 | "readOnly": true 8 | }, 9 | "tests": [ 10 | { 11 | "description": "readOnly is true", 12 | "data": 1, 13 | "output": { 14 | "basic": { 15 | "$id": "https://json-schema.org/tests/content/draft2020-12/readOnly/0/tests/0/basic", 16 | "$ref": "/draft/2020-12/output/schema", 17 | "properties": { 18 | "annotations": { 19 | "contains": { 20 | "properties": { 21 | "keywordLocation": {"const": "/readOnly"}, 22 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/readOnly/0#/readOnly"}, 23 | "instanceLocation": {"const": ""}, 24 | "annotation": {"const": true} 25 | }, 26 | "required": ["keywordLocation", "instanceLocation", "annotation"] 27 | } 28 | }, 29 | "errors": false 30 | }, 31 | "required": ["annotations"] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /json/output-tests/draft2020-12/content/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validating type", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$id": "https://json-schema.org/tests/content/draft2020-12/type/0", 7 | "type": "string", 8 | "anyOf": [ true ] 9 | }, 10 | "tests": [ 11 | { 12 | "description": "incorrect type must be reported, but a message is not required", 13 | "data": 1, 14 | "output": { 15 | "basic": { 16 | "$id": "https://json-schema.org/tests/content/draft2020-12/type/0/tests/0/basic", 17 | "$ref": "/draft/2020-12/output/schema", 18 | "properties": { 19 | "errors": { 20 | "contains": { 21 | "properties": { 22 | "keywordLocation": {"const": "/type"}, 23 | "absoluteKeywordLocation": {"const": "https://json-schema.org/tests/content/draft2020-12/type/0#/type"}, 24 | "instanceLocation": {"const": ""}, 25 | "annotation": false 26 | }, 27 | "required": ["keywordLocation", "instanceLocation"] 28 | } 29 | } 30 | }, 31 | "required": ["errors"] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /json/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "json-schema-test-suite", 3 | "version": "0.1.0", 4 | "description": "A language agnostic test suite for the JSON Schema specifications", 5 | "repository": "github:json-schema-org/JSON-Schema-Test-Suite", 6 | "keywords": [ 7 | "json-schema", 8 | "tests" 9 | ], 10 | "author": "http://json-schema.org", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /json/remotes/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /json/remotes/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /json/remotes/different-id-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/real-id-ref-string.json", 3 | "$defs": {"bar": {"type": "string"}}, 4 | "$ref": "#/$defs/bar" 5 | } 6 | -------------------------------------------------------------------------------- /json/remotes/draft-next/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft-next/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft-next/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft-next/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft-next/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft-next/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "description": "extendible array", 4 | "$id": "http://localhost:1234/draft-next/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /json/remotes/draft-next/format-assertion-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/format-assertion-false.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/core": true, 6 | "https://json-schema.org/draft/next/vocab/format-assertion": false 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft-next/format-assertion-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/format-assertion-true.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/core": true, 6 | "https://json-schema.org/draft/next/vocab/format-assertion": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft-next/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft-next/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/draft-next/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/applicator": true, 6 | "https://json-schema.org/draft/next/vocab/core": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/applicator" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft-next/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/validation": true, 6 | "https://json-schema.org/draft/next/vocab/core": true, 7 | "http://localhost:1234/draft/next/vocab/custom": false 8 | }, 9 | "$dynamicAnchor": "meta", 10 | "allOf": [ 11 | { "$ref": "https://json-schema.org/draft/next/meta/validation" }, 12 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /json/remotes/draft-next/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /json/remotes/draft-next/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /json/remotes/draft-next/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft-next/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/draft-next/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft-next/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "description": "tree schema, extensible", 4 | "$id": "http://localhost:1234/draft-next/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/dependentRequired.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/dependentRequired.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "dependentRequired": { 5 | "foo": ["bar"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft2019-09/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$id": "http://localhost:1234/draft2019-09/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/ignore-prefixItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/ignore-prefixItems.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "prefixItems": [ 5 | {"type": "string"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/applicator": true, 6 | "https://json-schema.org/draft/2019-09/vocab/core": true 7 | }, 8 | "$recursiveAnchor": true, 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2019-09/meta/applicator" }, 11 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/validation": true, 6 | "https://json-schema.org/draft/2019-09/vocab/core": true, 7 | "http://localhost:1234/draft/2019-09/vocab/custom": false 8 | }, 9 | "$recursiveAnchor": true, 10 | "allOf": [ 11 | { "$ref": "https://json-schema.org/draft/2019-09/meta/validation" }, 12 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft2019-09/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$id": "http://localhost:1234/draft2019-09/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft2020-12/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft2020-12/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$id": "http://localhost:1234/draft2020-12/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/format-assertion-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/format-assertion-false.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/core": true, 6 | "https://json-schema.org/draft/2020-12/vocab/format-assertion": false 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/format-assertion-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/format-assertion-true.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/core": true, 6 | "https://json-schema.org/draft/2020-12/vocab/format-assertion": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 6 | "https://json-schema.org/draft/2020-12/vocab/core": true 7 | }, 8 | "$dynamicAnchor": "meta", 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 6 | "https://json-schema.org/draft/2020-12/vocab/core": true, 7 | "http://localhost:1234/draft/2020-12/vocab/custom": false 8 | }, 9 | "$dynamicAnchor": "meta", 10 | "allOf": [ 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/validation" }, 12 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/prefixItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/prefixItems.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "prefixItems": [ 5 | {"type": "string"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft2020-12/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$id": "http://localhost:1234/draft2020-12/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /json/remotes/draft3/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /json/remotes/draft4/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft4/name.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "orNull": { 4 | "anyOf": [ 5 | { 6 | "type": "null" 7 | }, 8 | { 9 | "$ref": "#" 10 | } 11 | ] 12 | } 13 | }, 14 | "type": "string" 15 | } 16 | -------------------------------------------------------------------------------- /json/remotes/draft4/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /json/remotes/draft6/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft6/detached-ref.json", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "definitions": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$id": "#detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft6/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft6/name.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "orNull": { 4 | "anyOf": [ 5 | { 6 | "type": "null" 7 | }, 8 | { 9 | "$ref": "#" 10 | } 11 | ] 12 | } 13 | }, 14 | "type": "string" 15 | } 16 | -------------------------------------------------------------------------------- /json/remotes/draft6/ref-and-definitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft6/ref-and-definitions.json", 3 | "definitions": { 4 | "inner": { 5 | "properties": { 6 | "bar": { "type": "string" } 7 | } 8 | } 9 | }, 10 | "allOf": [ { "$ref": "#/definitions/inner" } ] 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft6/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /json/remotes/draft7/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/detached-ref.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$id": "#detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /json/remotes/draft7/ignore-dependentRequired.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/integer.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "dependentRequired": { 5 | "foo": ["bar"] 6 | } 7 | } -------------------------------------------------------------------------------- /json/remotes/draft7/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft7/name.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "orNull": { 4 | "anyOf": [ 5 | { 6 | "type": "null" 7 | }, 8 | { 9 | "$ref": "#" 10 | } 11 | ] 12 | } 13 | }, 14 | "type": "string" 15 | } 16 | -------------------------------------------------------------------------------- /json/remotes/draft7/ref-and-definitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/ref-and-definitions.json", 3 | "definitions": { 4 | "inner": { 5 | "properties": { 6 | "bar": { "type": "string" } 7 | } 8 | } 9 | }, 10 | "allOf": [ { "$ref": "#/definitions/inner" } ] 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/draft7/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /json/remotes/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$id": "http://localhost:1234/extendible-dynamic-ref.json", 4 | "type": "object", 5 | "properties": { 6 | "elements": { 7 | "type": "array", 8 | "items": { 9 | "$dynamicRef": "#elements" 10 | } 11 | } 12 | }, 13 | "required": ["elements"], 14 | "additionalProperties": false, 15 | "$defs": { 16 | "elements": { 17 | "$dynamicAnchor": "elements" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /json/remotes/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /json/remotes/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$anchor": "foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "orNull": { 4 | "anyOf": [ 5 | { 6 | "type": "null" 7 | }, 8 | { 9 | "$ref": "#" 10 | } 11 | ] 12 | } 13 | }, 14 | "type": "string" 15 | } 16 | -------------------------------------------------------------------------------- /json/remotes/nested-absolute-ref-to-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "bar": { 4 | "$id": "http://localhost:1234/the-nested-id.json", 5 | "type": "string" 6 | } 7 | }, 8 | "$ref": "http://localhost:1234/the-nested-id.json" 9 | } 10 | -------------------------------------------------------------------------------- /json/remotes/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": {"$ref": "string.json"} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /json/remotes/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } 4 | -------------------------------------------------------------------------------- /json/remotes/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/ref-and-defs.json", 3 | "$defs": { 4 | "inner": { 5 | "properties": { 6 | "bar": { "type": "string" } 7 | } 8 | } 9 | }, 10 | "$ref": "#/$defs/inner" 11 | } 12 | -------------------------------------------------------------------------------- /json/remotes/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$id": "http://localhost:1234/tree.json", 4 | "$dynamicAnchor": "node", 5 | 6 | "type": "object", 7 | "properties": { 8 | "data": true, 9 | "children": { 10 | "type": "array", 11 | "items": { 12 | "$dynamicRef": "#node" 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /json/remotes/urn-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "urn:uuid:feebdaed-ffff-0000-ffff-0000deadbeef", 3 | "$defs": {"bar": {"type": "string"}}, 4 | "$ref": "#/$defs/bar" 5 | } 6 | -------------------------------------------------------------------------------- /json/tests/draft-next/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$ref": "https://json-schema.org/draft/next/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /json/tests/draft-next/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /json/tests/draft-next/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /json/tests/draft-next/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /json/tests/draft-next/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "maxItems": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": [1], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1, 2], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": [1, 2, 3], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "foobar", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maxItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/next/schema", 35 | "maxItems": 2.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "shorter is valid", 40 | "data": [1], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too long is invalid", 45 | "data": [1, 2, 3], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /json/tests/draft-next/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "maxLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": "f", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": "foo", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 100, 27 | "valid": true 28 | }, 29 | { 30 | "description": "two graphemes is long enough", 31 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "maxLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/next/schema", 40 | "maxLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "shorter is valid", 45 | "data": "f", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too long is invalid", 50 | "data": "foo", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /json/tests/draft-next/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "maximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the maximum is valid", 11 | "data": 2.6, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is valid", 16 | "data": 3.0, 17 | "valid": true 18 | }, 19 | { 20 | "description": "above the maximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maximum validation with unsigned integer", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/next/schema", 35 | "maximum": 300 36 | }, 37 | "tests": [ 38 | { 39 | "description": "below the maximum is invalid", 40 | "data": 299.97, 41 | "valid": true 42 | }, 43 | { 44 | "description": "boundary point integer is valid", 45 | "data": 300, 46 | "valid": true 47 | }, 48 | { 49 | "description": "boundary point float is valid", 50 | "data": 300.00, 51 | "valid": true 52 | }, 53 | { 54 | "description": "above the maximum is invalid", 55 | "data": 300.5, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft-next/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "minItems": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": [1, 2], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": [], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "minItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/next/schema", 35 | "minItems": 1.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "longer is valid", 40 | "data": [1, 2], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too short is invalid", 45 | "data": [], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /json/tests/draft-next/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": "f", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 1, 27 | "valid": true 28 | }, 29 | { 30 | "description": "one grapheme is not long enough", 31 | "data": "\uD83D\uDCA9", 32 | "valid": false 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "minLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/next/schema", 40 | "minLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "longer is valid", 45 | "data": "foo", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too short is invalid", 50 | "data": "f", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /json/tests/draft-next/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "minProperties": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": {"foo": 1, "bar": 2}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": {"foo": 1}, 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": {}, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "ignores strings", 31 | "data": "", 32 | "valid": true 33 | }, 34 | { 35 | "description": "ignores other non-objects", 36 | "data": 12, 37 | "valid": true 38 | } 39 | ] 40 | }, 41 | { 42 | "description": "minProperties validation with a decimal", 43 | "schema": { 44 | "$schema": "https://json-schema.org/draft/next/schema", 45 | "minProperties": 1.0 46 | }, 47 | "tests": [ 48 | { 49 | "description": "longer is valid", 50 | "data": {"foo": 1, "bar": 2}, 51 | "valid": true 52 | }, 53 | { 54 | "description": "too short is invalid", 55 | "data": {}, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft-next/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "type": "integer", 7 | "multipleOf": 0.5 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid if optional overflow handling is implemented", 12 | "data": 1e308, 13 | "valid": true 14 | } 15 | ] 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /json/tests/draft-next/optional/format-assertion.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with format-assertion: false", 4 | "schema": { 5 | "$id": "https://schema/using/format-assertion/false", 6 | "$schema": "http://localhost:1234/draft-next/format-assertion-false.json", 7 | "format": "ipv4" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "format-assertion: false: valid string", 12 | "data": "127.0.0.1", 13 | "valid": true 14 | }, 15 | { 16 | "description": "format-assertion: false: invalid string", 17 | "data": "not-an-ipv4", 18 | "valid": false 19 | } 20 | ] 21 | }, 22 | { 23 | "description": "schema that uses custom metaschema with format-assertion: true", 24 | "schema": { 25 | "$id": "https://schema/using/format-assertion/true", 26 | "$schema": "http://localhost:1234/draft-next/format-assertion-true.json", 27 | "format": "ipv4" 28 | }, 29 | "tests": [ 30 | { 31 | "description": "format-assertion: true: valid string", 32 | "data": "127.0.0.1", 33 | "valid": true 34 | }, 35 | { 36 | "description": "format-assertion: true: invalid string", 37 | "data": "not-an-ipv4", 38 | "valid": false 39 | } 40 | ] 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /json/tests/draft-next/optional/format/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "\\a is not an ECMA 262 control escape", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "when used as a pattern", 11 | "data": "\\a", 12 | "valid": false 13 | } 14 | ] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /json/tests/draft-next/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "all string formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "all string formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "all string formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "all string formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "all string formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "all string formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "a valid regular expression", 41 | "data": "([abc])+\\s+$", 42 | "valid": true 43 | }, 44 | { 45 | "description": "a regular expression with unclosed parens is invalid", 46 | "data": "^(abc]", 47 | "valid": false 48 | } 49 | ] 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$ref": "https://json-schema.org/draft/2019-09/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "maxItems": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": [1], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1, 2], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": [1, 2, 3], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "foobar", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maxItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2019-09/schema", 35 | "maxItems": 2.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "shorter is valid", 40 | "data": [1], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too long is invalid", 45 | "data": [1, 2, 3], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "maxLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": "f", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": "foo", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 100, 27 | "valid": true 28 | }, 29 | { 30 | "description": "two graphemes is long enough", 31 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "maxLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2019-09/schema", 40 | "maxLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "shorter is valid", 45 | "data": "f", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too long is invalid", 50 | "data": "foo", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "maximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the maximum is valid", 11 | "data": 2.6, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is valid", 16 | "data": 3.0, 17 | "valid": true 18 | }, 19 | { 20 | "description": "above the maximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maximum validation with unsigned integer", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2019-09/schema", 35 | "maximum": 300 36 | }, 37 | "tests": [ 38 | { 39 | "description": "below the maximum is invalid", 40 | "data": 299.97, 41 | "valid": true 42 | }, 43 | { 44 | "description": "boundary point integer is valid", 45 | "data": 300, 46 | "valid": true 47 | }, 48 | { 49 | "description": "boundary point float is valid", 50 | "data": 300.00, 51 | "valid": true 52 | }, 53 | { 54 | "description": "above the maximum is invalid", 55 | "data": 300.5, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "minItems": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": [1, 2], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": [], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "minItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2019-09/schema", 35 | "minItems": 1.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "longer is valid", 40 | "data": [1, 2], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too short is invalid", 45 | "data": [], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": "f", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 1, 27 | "valid": true 28 | }, 29 | { 30 | "description": "one grapheme is not long enough", 31 | "data": "\uD83D\uDCA9", 32 | "valid": false 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "minLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2019-09/schema", 40 | "minLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "longer is valid", 45 | "data": "foo", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too short is invalid", 50 | "data": "f", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "minProperties": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": {"foo": 1, "bar": 2}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": {"foo": 1}, 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": {}, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "ignores strings", 31 | "data": "", 32 | "valid": true 33 | }, 34 | { 35 | "description": "ignores other non-objects", 36 | "data": 12, 37 | "valid": true 38 | } 39 | ] 40 | }, 41 | { 42 | "description": "minProperties validation with a decimal", 43 | "schema": { 44 | "$schema": "https://json-schema.org/draft/2019-09/schema", 45 | "minProperties": 1.0 46 | }, 47 | "tests": [ 48 | { 49 | "description": "longer is valid", 50 | "data": {"foo": 1, "bar": 2}, 51 | "valid": true 52 | }, 53 | { 54 | "description": "too short is invalid", 55 | "data": {}, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to future drafts are processed as future drafts", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "type": "array", 7 | "$ref": "http://localhost:1234/draft2020-12/prefixItems.json" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "first item not a string is invalid", 12 | "comment": "if the implementation is not processing the $ref as a 2020-12 schema, this test will fail", 13 | "data": [1, 2, 3], 14 | "valid": false 15 | }, 16 | { 17 | "description": "first item is a string is valid", 18 | "data": ["a string", 1, 2, 3], 19 | "valid": true 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "refs to historic drafts are processed as historic drafts", 25 | "schema": { 26 | "type": "object", 27 | "allOf": [ 28 | { "properties": { "foo": true } }, 29 | { "$ref": "http://localhost:1234/draft7/ignore-dependentRequired.json" } 30 | ] 31 | }, 32 | "tests": [ 33 | { 34 | "description": "missing bar is valid", 35 | "comment": "if the implementation is not processing the $ref as a draft 7 schema, this test will fail", 36 | "data": {"foo": "any value"}, 37 | "valid": true 38 | } 39 | ] 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "type": "integer", "multipleOf": 0.5 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid if optional overflow handling is implemented", 11 | "data": 1e308, 12 | "valid": true 13 | } 14 | ] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "all string formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "all string formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "all string formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "all string formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "all string formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "all string formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "a valid regular expression", 41 | "data": "([abc])+\\s+$", 42 | "valid": true 43 | }, 44 | { 45 | "description": "a regular expression with unclosed parens is invalid", 46 | "data": "^(abc]", 47 | "valid": false 48 | } 49 | ] 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "format": "unknown" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "unknown formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "unknown formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "unknown formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "unknown formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "unknown formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "unknown formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "unknown formats ignore strings", 41 | "data": "string", 42 | "valid": true 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /json/tests/draft2019-09/optional/no-schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation without $schema", 4 | "comment": "minLength is the same across all drafts", 5 | "schema": { 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a 3-character string is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a 1-character string is not valid", 16 | "data": "a", 17 | "valid": false 18 | }, 19 | { 20 | "description": "a non-string is valid", 21 | "data": 5, 22 | "valid": true 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$ref": "https://json-schema.org/draft/2020-12/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "maxItems": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": [1], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1, 2], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": [1, 2, 3], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "foobar", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maxItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2020-12/schema", 35 | "maxItems": 2.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "shorter is valid", 40 | "data": [1], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too long is invalid", 45 | "data": [1, 2, 3], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "maxLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "shorter is valid", 11 | "data": "f", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too long is invalid", 21 | "data": "foo", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 100, 27 | "valid": true 28 | }, 29 | { 30 | "description": "two graphemes is long enough", 31 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "maxLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2020-12/schema", 40 | "maxLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "shorter is valid", 45 | "data": "f", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too long is invalid", 50 | "data": "foo", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "maximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the maximum is valid", 11 | "data": 2.6, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is valid", 16 | "data": 3.0, 17 | "valid": true 18 | }, 19 | { 20 | "description": "above the maximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "maximum validation with unsigned integer", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2020-12/schema", 35 | "maximum": 300 36 | }, 37 | "tests": [ 38 | { 39 | "description": "below the maximum is invalid", 40 | "data": 299.97, 41 | "valid": true 42 | }, 43 | { 44 | "description": "boundary point integer is valid", 45 | "data": 300, 46 | "valid": true 47 | }, 48 | { 49 | "description": "boundary point float is valid", 50 | "data": 300.00, 51 | "valid": true 52 | }, 53 | { 54 | "description": "above the maximum is invalid", 55 | "data": 300.5, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "minItems": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": [1, 2], 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": [1], 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": [], 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-arrays", 26 | "data": "", 27 | "valid": true 28 | } 29 | ] 30 | }, 31 | { 32 | "description": "minItems validation with a decimal", 33 | "schema": { 34 | "$schema": "https://json-schema.org/draft/2020-12/schema", 35 | "minItems": 1.0 36 | }, 37 | "tests": [ 38 | { 39 | "description": "longer is valid", 40 | "data": [1, 2], 41 | "valid": true 42 | }, 43 | { 44 | "description": "too short is invalid", 45 | "data": [], 46 | "valid": false 47 | } 48 | ] 49 | } 50 | ] 51 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": "fo", 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": "f", 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-strings", 26 | "data": 1, 27 | "valid": true 28 | }, 29 | { 30 | "description": "one grapheme is not long enough", 31 | "data": "\uD83D\uDCA9", 32 | "valid": false 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "minLength validation with a decimal", 38 | "schema": { 39 | "$schema": "https://json-schema.org/draft/2020-12/schema", 40 | "minLength": 2.0 41 | }, 42 | "tests": [ 43 | { 44 | "description": "longer is valid", 45 | "data": "foo", 46 | "valid": true 47 | }, 48 | { 49 | "description": "too short is invalid", 50 | "data": "f", 51 | "valid": false 52 | } 53 | ] 54 | } 55 | ] 56 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "minProperties": 1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "longer is valid", 11 | "data": {"foo": 1, "bar": 2}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "exact length is valid", 16 | "data": {"foo": 1}, 17 | "valid": true 18 | }, 19 | { 20 | "description": "too short is invalid", 21 | "data": {}, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "ignores strings", 31 | "data": "", 32 | "valid": true 33 | }, 34 | { 35 | "description": "ignores other non-objects", 36 | "data": 12, 37 | "valid": true 38 | } 39 | ] 40 | }, 41 | { 42 | "description": "minProperties validation with a decimal", 43 | "schema": { 44 | "$schema": "https://json-schema.org/draft/2020-12/schema", 45 | "minProperties": 1.0 46 | }, 47 | "tests": [ 48 | { 49 | "description": "longer is valid", 50 | "data": {"foo": 1, "bar": 2}, 51 | "valid": true 52 | }, 53 | { 54 | "description": "too short is invalid", 55 | "data": {}, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to historic drafts are processed as historic drafts", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "type": "array", 7 | "$ref": "http://localhost:1234/draft2019-09/ignore-prefixItems.json" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "first item not a string is valid", 12 | "comment": "if the implementation is not processing the $ref as a 2019-09 schema, this test will fail", 13 | "data": [1, 2, 3], 14 | "valid": true 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "type": "integer", 7 | "multipleOf": 0.5 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid if optional overflow handling is implemented", 12 | "data": 1e308, 13 | "valid": true 14 | } 15 | ] 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/format-assertion.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with format-assertion: false", 4 | "schema": { 5 | "$id": "https://schema/using/format-assertion/false", 6 | "$schema": "http://localhost:1234/draft2020-12/format-assertion-false.json", 7 | "format": "ipv4" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "format-assertion: false: valid string", 12 | "data": "127.0.0.1", 13 | "valid": true 14 | }, 15 | { 16 | "description": "format-assertion: false: invalid string", 17 | "data": "not-an-ipv4", 18 | "valid": false 19 | } 20 | ] 21 | }, 22 | { 23 | "description": "schema that uses custom metaschema with format-assertion: true", 24 | "schema": { 25 | "$id": "https://schema/using/format-assertion/true", 26 | "$schema": "http://localhost:1234/draft2020-12/format-assertion-true.json", 27 | "format": "ipv4" 28 | }, 29 | "tests": [ 30 | { 31 | "description": "format-assertion: true: valid string", 32 | "data": "127.0.0.1", 33 | "valid": true 34 | }, 35 | { 36 | "description": "format-assertion: true: invalid string", 37 | "data": "not-an-ipv4", 38 | "valid": false 39 | } 40 | ] 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/format/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "\\a is not an ECMA 262 control escape", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "when used as a pattern", 11 | "data": "\\a", 12 | "valid": false 13 | } 14 | ] 15 | } 16 | ] -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "format": "regex" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "all string formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "all string formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "all string formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "all string formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "all string formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "all string formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "a valid regular expression", 41 | "data": "([abc])+\\s+$", 42 | "valid": true 43 | }, 44 | { 45 | "description": "a regular expression with unclosed parens is invalid", 46 | "data": "^(abc]", 47 | "valid": false 48 | } 49 | ] 50 | } 51 | ] 52 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "format": "unknown" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "unknown formats ignore integers", 11 | "data": 12, 12 | "valid": true 13 | }, 14 | { 15 | "description": "unknown formats ignore floats", 16 | "data": 13.7, 17 | "valid": true 18 | }, 19 | { 20 | "description": "unknown formats ignore objects", 21 | "data": {}, 22 | "valid": true 23 | }, 24 | { 25 | "description": "unknown formats ignore arrays", 26 | "data": [], 27 | "valid": true 28 | }, 29 | { 30 | "description": "unknown formats ignore booleans", 31 | "data": false, 32 | "valid": true 33 | }, 34 | { 35 | "description": "unknown formats ignore nulls", 36 | "data": null, 37 | "valid": true 38 | }, 39 | { 40 | "description": "unknown formats ignore strings", 41 | "data": "string", 42 | "valid": true 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /json/tests/draft2020-12/optional/no-schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation without $schema", 4 | "comment": "minLength is the same across all drafts", 5 | "schema": { 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a 3-character string is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a 1-character string is not valid", 16 | "data": "a", 17 | "valid": false 18 | }, 19 | { 20 | "description": "a non-string is valid", 21 | "data": 5, 22 | "valid": true 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /json/tests/draft3/divisibleBy.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "by int", 4 | "schema": {"divisibleBy": 2}, 5 | "tests": [ 6 | { 7 | "description": "int by int", 8 | "data": 10, 9 | "valid": true 10 | }, 11 | { 12 | "description": "int by int fail", 13 | "data": 7, 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores non-numbers", 18 | "data": "foo", 19 | "valid": true 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "by number", 25 | "schema": {"divisibleBy": 1.5}, 26 | "tests": [ 27 | { 28 | "description": "zero is divisible by anything (except 0)", 29 | "data": 0, 30 | "valid": true 31 | }, 32 | { 33 | "description": "4.5 is divisible by 1.5", 34 | "data": 4.5, 35 | "valid": true 36 | }, 37 | { 38 | "description": "35 is not divisible by 1.5", 39 | "data": 35, 40 | "valid": false 41 | } 42 | ] 43 | }, 44 | { 45 | "description": "by small number", 46 | "schema": {"divisibleBy": 0.0001}, 47 | "tests": [ 48 | { 49 | "description": "0.0075 is divisible by 0.0001", 50 | "data": 0.0075, 51 | "valid": true 52 | }, 53 | { 54 | "description": "0.00751 is not divisible by 0.0001", 55 | "data": 0.00751, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /json/tests/draft3/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "properties": { 9 | "foo": { 10 | "$ref": "#/definitions/int" 11 | } 12 | }, 13 | "extends": { 14 | "additionalProperties": { 15 | "$ref": "#/definitions/int" 16 | } 17 | } 18 | }, 19 | "tests": [ 20 | { 21 | "description": "passing case", 22 | "data": { "foo": 1 }, 23 | "valid": true 24 | }, 25 | { 26 | "description": "failing case", 27 | "data": { "foo": "a string" }, 28 | "valid": false 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /json/tests/draft3/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /json/tests/draft3/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 10, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /json/tests/draft3/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /json/tests/draft3/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/color.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of CSS colors", 4 | "schema": { "format": "color" }, 5 | "tests": [ 6 | { 7 | "description": "a valid CSS color name", 8 | "data": "fuchsia", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a valid six-digit CSS color code", 13 | "data": "#CC8899", 14 | "valid": true 15 | }, 16 | { 17 | "description": "a valid three-digit CSS color code", 18 | "data": "#C89", 19 | "valid": true 20 | }, 21 | { 22 | "description": "an invalid CSS color code", 23 | "data": "#00332520", 24 | "valid": false 25 | }, 26 | { 27 | "description": "an invalid CSS color name", 28 | "data": "puce", 29 | "valid": false 30 | }, 31 | { 32 | "description": "a CSS color name containing invalid characters", 33 | "data": "light_grayish_red-violet", 34 | "valid": false 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/date-time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of date-time strings", 4 | "schema": { "format": "date-time" }, 5 | "tests": [ 6 | { 7 | "description": "a valid date-time string", 8 | "data": "1963-06-19T08:30:06.283185Z", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid date-time string", 13 | "data": "06/19/1963 08:30:06 PST", 14 | "valid": false 15 | }, 16 | { 17 | "description": "case-insensitive T and Z", 18 | "data": "1963-06-19t08:30:06.283185z", 19 | "valid": true 20 | }, 21 | { 22 | "description": "only RFC3339 not all of ISO 8601 are valid", 23 | "data": "2013-350T01:01:01", 24 | "valid": false 25 | }, 26 | { 27 | "description": "invalid non-padded month dates", 28 | "data": "1963-6-19T08:30:06.283185Z", 29 | "valid": false 30 | }, 31 | { 32 | "description": "invalid non-padded day dates", 33 | "data": "1963-06-1T08:30:06.283185Z", 34 | "valid": false 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "ECMA 262 regex dialect recognition", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "[^] is a valid regex", 8 | "data": "[^]", 9 | "valid": true 10 | }, 11 | { 12 | "description": "ECMA 262 has no support for lookbehind", 13 | "data": "(?<=foo)bar", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/ip-address.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IP addresses", 4 | "schema": { "format": "ip-address" }, 5 | "tests": [ 6 | { 7 | "description": "a valid IP address", 8 | "data": "192.168.0.1", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an IP address with too many components", 13 | "data": "127.0.0.0.1", 14 | "valid": false 15 | }, 16 | { 17 | "description": "an IP address with out-of-range values", 18 | "data": "256.256.256.256", 19 | "valid": false 20 | } 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "a valid regular expression", 8 | "data": "([abc])+\\s+$", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a regular expression with unclosed parens is invalid", 13 | "data": "^(abc]", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of time strings", 4 | "schema": { "format": "time" }, 5 | "tests": [ 6 | { 7 | "description": "a valid time string", 8 | "data": "08:30:06", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid time string", 13 | "data": "8:30 AM", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/format/uri.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of URIs", 4 | "schema": { "format": "uri" }, 5 | "tests": [ 6 | { 7 | "description": "a valid URI", 8 | "data": "http://foo.bar/?baz=qux#quux", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid protocol-relative URI Reference", 13 | "data": "//foo.bar/?baz=qux#quux", 14 | "valid": false 15 | }, 16 | { 17 | "description": "an invalid URI", 18 | "data": "\\\\WINDOWS\\fileshare", 19 | "valid": false 20 | }, 21 | { 22 | "description": "an invalid URI though valid URI reference", 23 | "data": "abc", 24 | "valid": false 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /json/tests/draft3/optional/zeroTerminatedFloats.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "some languages do not distinguish between different types of numeric value", 4 | "schema": { 5 | "type": "integer" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a float is not an integer even without fractional part", 10 | "data": 1.0, 11 | "valid": false 12 | } 13 | ] 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /json/tests/draft3/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /json/tests/draft3/required.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "required validation", 4 | "schema": { 5 | "properties": { 6 | "foo": {"required" : true}, 7 | "bar": {} 8 | } 9 | }, 10 | "tests": [ 11 | { 12 | "description": "present required property is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "non-present required property is invalid", 18 | "data": {"bar": 1}, 19 | "valid": false 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "required default validation", 25 | "schema": { 26 | "properties": { 27 | "foo": {} 28 | } 29 | }, 30 | "tests": [ 31 | { 32 | "description": "not required by default", 33 | "data": {}, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "required explicitly false validation", 40 | "schema": { 41 | "properties": { 42 | "foo": {"required": false} 43 | } 44 | }, 45 | "tests": [ 46 | { 47 | "description": "not required if required is false", 48 | "data": {}, 49 | "valid": true 50 | } 51 | ] 52 | } 53 | ] 54 | -------------------------------------------------------------------------------- /json/tests/draft4/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "http://json-schema.org/draft-04/schema#"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": { 9 | "definitions": { 10 | "foo": {"type": "integer"} 11 | } 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "invalid definition schema", 17 | "data": { 18 | "definitions": { 19 | "foo": {"type": 1} 20 | } 21 | }, 22 | "valid": false 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /json/tests/draft4/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/definitions/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/definitions/int" 19 | } 20 | } 21 | ] 22 | }, 23 | "tests": [ 24 | { 25 | "description": "passing case", 26 | "data": { "foo": 1 }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "failing case", 31 | "data": { "foo": "a string" }, 32 | "valid": false 33 | } 34 | ] 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /json/tests/draft4/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /json/tests/draft4/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /json/tests/draft4/maxProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxProperties validation", 4 | "schema": {"maxProperties": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": {"foo": 1}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1, "bar": 2}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": {"foo": 1, "bar": 2, "baz": 3}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [1, 2, 3], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "foobar", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "maxProperties = 0 means the object is empty", 40 | "schema": { "maxProperties": 0 }, 41 | "tests": [ 42 | { 43 | "description": "no properties is valid", 44 | "data": {}, 45 | "valid": true 46 | }, 47 | { 48 | "description": "one property is invalid", 49 | "data": { "foo": 1 }, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /json/tests/draft4/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /json/tests/draft4/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /json/tests/draft4/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /json/tests/draft4/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": {"type": "number", "multipleOf": 0.5}, 5 | "tests": [ 6 | { 7 | "description": "valid if optional overflow handling is implemented", 8 | "data": 1e308, 9 | "valid": true 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /json/tests/draft4/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { "format": "unknown" }, 5 | "tests": [ 6 | { 7 | "description": "unknown formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "unknown formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "unknown formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "unknown formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "unknown formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "unknown formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "unknown formats ignore strings", 38 | "data": "string", 39 | "valid": true 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /json/tests/draft4/optional/zeroTerminatedFloats.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "some languages do not distinguish between different types of numeric value", 4 | "schema": { 5 | "type": "integer" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a float is not an integer even without fractional part", 10 | "data": 1.0, 11 | "valid": false 12 | } 13 | ] 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /json/tests/draft4/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /json/tests/draft6/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "http://json-schema.org/draft-06/schema#"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": { 9 | "definitions": { 10 | "foo": {"type": "integer"} 11 | } 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "invalid definition schema", 17 | "data": { 18 | "definitions": { 19 | "foo": {"type": 1} 20 | } 21 | }, 22 | "valid": false 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /json/tests/draft6/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "exclusiveMaximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the exclusiveMaximum is valid", 10 | "data": 2.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 3.0, 16 | "valid": false 17 | }, 18 | { 19 | "description": "above the exclusiveMaximum is invalid", 20 | "data": 3.5, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /json/tests/draft6/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "exclusiveMinimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the exclusiveMinimum is valid", 10 | "data": 1.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 1.1, 16 | "valid": false 17 | }, 18 | { 19 | "description": "below the exclusiveMinimum is invalid", 20 | "data": 0.6, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /json/tests/draft6/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/definitions/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/definitions/int" 19 | } 20 | } 21 | ] 22 | }, 23 | "tests": [ 24 | { 25 | "description": "passing case", 26 | "data": { "foo": 1 }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "failing case", 31 | "data": { "foo": "a string" }, 32 | "valid": false 33 | } 34 | ] 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /json/tests/draft6/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maxItems validation with a decimal", 30 | "schema": {"maxItems": 2.0}, 31 | "tests": [ 32 | { 33 | "description": "shorter is valid", 34 | "data": [1], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too long is invalid", 39 | "data": [1, 2, 3], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /json/tests/draft6/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "maxLength validation with a decimal", 35 | "schema": {"maxLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "shorter is valid", 39 | "data": "f", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too long is invalid", 44 | "data": "foo", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /json/tests/draft6/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": {"maximum": 3.0}, 5 | "tests": [ 6 | { 7 | "description": "below the maximum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 3.0, 14 | "valid": true 15 | }, 16 | { 17 | "description": "above the maximum is invalid", 18 | "data": 3.5, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maximum validation with unsigned integer", 30 | "schema": {"maximum": 300}, 31 | "tests": [ 32 | { 33 | "description": "below the maximum is invalid", 34 | "data": 299.97, 35 | "valid": true 36 | }, 37 | { 38 | "description": "boundary point integer is valid", 39 | "data": 300, 40 | "valid": true 41 | }, 42 | { 43 | "description": "boundary point float is valid", 44 | "data": 300.00, 45 | "valid": true 46 | }, 47 | { 48 | "description": "above the maximum is invalid", 49 | "data": 300.5, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /json/tests/draft6/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "minItems validation with a decimal", 30 | "schema": {"minItems": 1.0}, 31 | "tests": [ 32 | { 33 | "description": "longer is valid", 34 | "data": [1, 2], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too short is invalid", 39 | "data": [], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /json/tests/draft6/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "minLength validation with a decimal", 35 | "schema": {"minLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "longer is valid", 39 | "data": "foo", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too short is invalid", 44 | "data": "f", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /json/tests/draft6/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "minProperties validation with a decimal", 40 | "schema": {"minProperties": 1.0}, 41 | "tests": [ 42 | { 43 | "description": "longer is valid", 44 | "data": {"foo": 1, "bar": 2}, 45 | "valid": true 46 | }, 47 | { 48 | "description": "too short is invalid", 49 | "data": {}, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /json/tests/draft6/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": {"type": "integer", "multipleOf": 0.5}, 5 | "tests": [ 6 | { 7 | "description": "valid if optional overflow handling is implemented", 8 | "data": 1e308, 9 | "valid": true 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /json/tests/draft6/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { "format": "unknown" }, 5 | "tests": [ 6 | { 7 | "description": "unknown formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "unknown formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "unknown formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "unknown formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "unknown formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "unknown formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "unknown formats ignore strings", 38 | "data": "string", 39 | "valid": true 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /json/tests/draft6/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /json/tests/draft7/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": { 9 | "definitions": { 10 | "foo": {"type": "integer"} 11 | } 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "invalid definition schema", 17 | "data": { 18 | "definitions": { 19 | "foo": {"type": 1} 20 | } 21 | }, 22 | "valid": false 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /json/tests/draft7/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "exclusiveMaximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the exclusiveMaximum is valid", 10 | "data": 2.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 3.0, 16 | "valid": false 17 | }, 18 | { 19 | "description": "above the exclusiveMaximum is invalid", 20 | "data": 3.5, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /json/tests/draft7/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "exclusiveMinimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the exclusiveMinimum is valid", 10 | "data": 1.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 1.1, 16 | "valid": false 17 | }, 18 | { 19 | "description": "below the exclusiveMinimum is invalid", 20 | "data": 0.6, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /json/tests/draft7/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "definitions": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/definitions/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/definitions/int" 19 | } 20 | } 21 | ] 22 | }, 23 | "tests": [ 24 | { 25 | "description": "passing case", 26 | "data": { "foo": 1 }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "failing case", 31 | "data": { "foo": "a string" }, 32 | "valid": false 33 | } 34 | ] 35 | } 36 | ] 37 | -------------------------------------------------------------------------------- /json/tests/draft7/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maxItems validation with a decimal", 30 | "schema": {"maxItems": 2.0}, 31 | "tests": [ 32 | { 33 | "description": "shorter is valid", 34 | "data": [1], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too long is invalid", 39 | "data": [1, 2, 3], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /json/tests/draft7/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "maxLength validation with a decimal", 35 | "schema": {"maxLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "shorter is valid", 39 | "data": "f", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too long is invalid", 44 | "data": "foo", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /json/tests/draft7/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": {"maximum": 3.0}, 5 | "tests": [ 6 | { 7 | "description": "below the maximum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 3.0, 14 | "valid": true 15 | }, 16 | { 17 | "description": "above the maximum is invalid", 18 | "data": 3.5, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "maximum validation with unsigned integer", 30 | "schema": {"maximum": 300}, 31 | "tests": [ 32 | { 33 | "description": "below the maximum is invalid", 34 | "data": 299.97, 35 | "valid": true 36 | }, 37 | { 38 | "description": "boundary point integer is valid", 39 | "data": 300, 40 | "valid": true 41 | }, 42 | { 43 | "description": "boundary point float is valid", 44 | "data": 300.00, 45 | "valid": true 46 | }, 47 | { 48 | "description": "above the maximum is invalid", 49 | "data": 300.5, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /json/tests/draft7/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | }, 28 | { 29 | "description": "minItems validation with a decimal", 30 | "schema": {"minItems": 1.0}, 31 | "tests": [ 32 | { 33 | "description": "longer is valid", 34 | "data": [1, 2], 35 | "valid": true 36 | }, 37 | { 38 | "description": "too short is invalid", 39 | "data": [], 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /json/tests/draft7/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | }, 33 | { 34 | "description": "minLength validation with a decimal", 35 | "schema": {"minLength": 2.0}, 36 | "tests": [ 37 | { 38 | "description": "longer is valid", 39 | "data": "foo", 40 | "valid": true 41 | }, 42 | { 43 | "description": "too short is invalid", 44 | "data": "f", 45 | "valid": false 46 | } 47 | ] 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /json/tests/draft7/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "minProperties validation with a decimal", 40 | "schema": {"minProperties": 1.0}, 41 | "tests": [ 42 | { 43 | "description": "longer is valid", 44 | "data": {"foo": 1, "bar": 2}, 45 | "valid": true 46 | }, 47 | { 48 | "description": "too short is invalid", 49 | "data": {}, 50 | "valid": false 51 | } 52 | ] 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /json/tests/draft7/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to future drafts are processed as future drafts", 4 | "schema": { 5 | "type": "object", 6 | "allOf": [ 7 | { "properties": { "foo": true } }, 8 | { "$ref": "http://localhost:1234/draft2019-09/dependentRequired.json" } 9 | ] 10 | }, 11 | "tests": [ 12 | { 13 | "description": "missing bar is invalid", 14 | "comment": "if the implementation is not processing the $ref as a 2019-09 schema, this test will fail", 15 | "data": {"foo": "any value"}, 16 | "valid": false 17 | }, 18 | { 19 | "description": "present bar is valid", 20 | "data": {"foo": "any value", "bar": "also any value"}, 21 | "valid": true 22 | } 23 | ] 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /json/tests/draft7/optional/float-overflow.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "all integers are multiples of 0.5, if overflow is handled", 4 | "schema": {"type": "integer", "multipleOf": 0.5}, 5 | "tests": [ 6 | { 7 | "description": "valid if optional overflow handling is implemented", 8 | "data": 1e308, 9 | "valid": true 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /json/tests/draft7/optional/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "all string formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "all string formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "all string formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "all string formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "all string formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "all string formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "a valid regular expression", 38 | "data": "([abc])+\\s+$", 39 | "valid": true 40 | }, 41 | { 42 | "description": "a regular expression with unclosed parens is invalid", 43 | "data": "^(abc]", 44 | "valid": false 45 | } 46 | ] 47 | } 48 | ] 49 | -------------------------------------------------------------------------------- /json/tests/draft7/optional/format/unknown.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unknown format", 4 | "schema": { "format": "unknown" }, 5 | "tests": [ 6 | { 7 | "description": "unknown formats ignore integers", 8 | "data": 12, 9 | "valid": true 10 | }, 11 | { 12 | "description": "unknown formats ignore floats", 13 | "data": 13.7, 14 | "valid": true 15 | }, 16 | { 17 | "description": "unknown formats ignore objects", 18 | "data": {}, 19 | "valid": true 20 | }, 21 | { 22 | "description": "unknown formats ignore arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "unknown formats ignore booleans", 28 | "data": false, 29 | "valid": true 30 | }, 31 | { 32 | "description": "unknown formats ignore nulls", 33 | "data": null, 34 | "valid": true 35 | }, 36 | { 37 | "description": "unknown formats ignore strings", 38 | "data": "string", 39 | "valid": true 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /json/tests/draft7/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores booleans", 18 | "data": true, 19 | "valid": true 20 | }, 21 | { 22 | "description": "ignores integers", 23 | "data": 123, 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores floats", 28 | "data": 1.0, 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores objects", 33 | "data": {}, 34 | "valid": true 35 | }, 36 | { 37 | "description": "ignores arrays", 38 | "data": [], 39 | "valid": true 40 | }, 41 | { 42 | "description": "ignores null", 43 | "data": null, 44 | "valid": true 45 | } 46 | ] 47 | }, 48 | { 49 | "description": "pattern is not anchored", 50 | "schema": {"pattern": "a+"}, 51 | "tests": [ 52 | { 53 | "description": "matches a substring", 54 | "data": "xxaayy", 55 | "valid": true 56 | } 57 | ] 58 | } 59 | ] 60 | -------------------------------------------------------------------------------- /json/tests/latest: -------------------------------------------------------------------------------- 1 | draft2020-12 -------------------------------------------------------------------------------- /json/tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | minversion = 1.6 3 | envlist = sanity 4 | skipsdist = True 5 | 6 | [testenv:sanity] 7 | # used just for validating the structure of the test case files themselves 8 | deps = jsonschema==4.19.0 9 | commands = {envpython} bin/jsonschema_suite check 10 | -------------------------------------------------------------------------------- /jsonschema/__main__.py: -------------------------------------------------------------------------------- 1 | """ 2 | The jsonschema CLI is now deprecated in favor of check-jsonschema. 3 | """ 4 | from jsonschema.cli import main 5 | 6 | main() 7 | -------------------------------------------------------------------------------- /jsonschema/_typing.py: -------------------------------------------------------------------------------- 1 | """ 2 | Some (initially private) typing helpers for jsonschema's types. 3 | """ 4 | from collections.abc import Iterable 5 | from typing import Any, Callable, Protocol, Union 6 | 7 | import referencing.jsonschema 8 | 9 | from jsonschema.protocols import Validator 10 | 11 | 12 | class SchemaKeywordValidator(Protocol): 13 | def __call__( 14 | self, 15 | validator: Validator, 16 | value: Any, 17 | instance: Any, 18 | schema: referencing.jsonschema.Schema, 19 | ) -> None: 20 | ... 21 | 22 | 23 | id_of = Callable[[referencing.jsonschema.Schema], Union[str, None]] 24 | 25 | 26 | ApplicableValidators = Callable[ 27 | [referencing.jsonschema.Schema], 28 | Iterable[tuple[str, Any]], 29 | ] 30 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Benchmarks for validation. 3 | 4 | This package is *not* public API. 5 | """ 6 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/const_vs_enum.py: -------------------------------------------------------------------------------- 1 | """ 2 | A benchmark for comparing equivalent validation of `const` and `enum`. 3 | """ 4 | 5 | from pyperf import Runner 6 | 7 | from jsonschema import Draft202012Validator 8 | 9 | value = [37] * 100 10 | const_schema = {"const": list(value)} 11 | enum_schema = {"enum": [list(value)]} 12 | 13 | valid = list(value) 14 | invalid = [*valid, 73] 15 | 16 | const = Draft202012Validator(const_schema) 17 | enum = Draft202012Validator(enum_schema) 18 | 19 | assert const.is_valid(valid) 20 | assert enum.is_valid(valid) 21 | assert not const.is_valid(invalid) 22 | assert not enum.is_valid(invalid) 23 | 24 | 25 | if __name__ == "__main__": 26 | runner = Runner() 27 | runner.bench_func("const valid", lambda: const.is_valid(valid)) 28 | runner.bench_func("const invalid", lambda: const.is_valid(invalid)) 29 | runner.bench_func("enum valid", lambda: enum.is_valid(valid)) 30 | runner.bench_func("enum invalid", lambda: enum.is_valid(invalid)) 31 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/contains.py: -------------------------------------------------------------------------------- 1 | """ 2 | A benchmark for validation of the `contains` keyword. 3 | """ 4 | 5 | from pyperf import Runner 6 | 7 | from jsonschema import Draft202012Validator 8 | 9 | schema = { 10 | "type": "array", 11 | "contains": {"const": 37}, 12 | } 13 | validator = Draft202012Validator(schema) 14 | 15 | size = 1000 16 | beginning = [37] + [0] * (size - 1) 17 | middle = [0] * (size // 2) + [37] + [0] * (size // 2) 18 | end = [0] * (size - 1) + [37] 19 | invalid = [0] * size 20 | 21 | 22 | if __name__ == "__main__": 23 | runner = Runner() 24 | runner.bench_func("baseline", lambda: validator.is_valid([])) 25 | runner.bench_func("beginning", lambda: validator.is_valid(beginning)) 26 | runner.bench_func("middle", lambda: validator.is_valid(middle)) 27 | runner.bench_func("end", lambda: validator.is_valid(end)) 28 | runner.bench_func("invalid", lambda: validator.is_valid(invalid)) 29 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/issue232.py: -------------------------------------------------------------------------------- 1 | """ 2 | A performance benchmark using the example from issue #232. 3 | 4 | See https://github.com/python-jsonschema/jsonschema/pull/232. 5 | """ 6 | from pathlib import Path 7 | 8 | from pyperf import Runner 9 | from referencing import Registry 10 | 11 | from jsonschema.tests._suite import Version 12 | import jsonschema 13 | 14 | issue232 = Version( 15 | path=Path(__file__).parent / "issue232", 16 | remotes=Registry(), 17 | name="issue232", 18 | ) 19 | 20 | 21 | if __name__ == "__main__": 22 | issue232.benchmark( 23 | runner=Runner(), 24 | Validator=jsonschema.Draft4Validator, 25 | ) 26 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/json_schema_test_suite.py: -------------------------------------------------------------------------------- 1 | """ 2 | A performance benchmark using the official test suite. 3 | 4 | This benchmarks jsonschema using every valid example in the 5 | JSON-Schema-Test-Suite. It will take some time to complete. 6 | """ 7 | from pyperf import Runner 8 | 9 | from jsonschema.tests._suite import Suite 10 | 11 | if __name__ == "__main__": 12 | Suite().benchmark(runner=Runner()) 13 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/subcomponents.py: -------------------------------------------------------------------------------- 1 | """ 2 | A benchmark which tries to compare the possible slow subparts of validation. 3 | """ 4 | from referencing import Registry 5 | from referencing.jsonschema import DRAFT202012 6 | from rpds import HashTrieMap, HashTrieSet 7 | 8 | from jsonschema import Draft202012Validator 9 | 10 | schema = { 11 | "type": "array", 12 | "minLength": 1, 13 | "maxLength": 1, 14 | "items": {"type": "integer"}, 15 | } 16 | 17 | hmap = HashTrieMap() 18 | hset = HashTrieSet() 19 | 20 | registry = Registry() 21 | 22 | v = Draft202012Validator(schema) 23 | 24 | 25 | def registry_data_structures(): 26 | return hmap.insert("foo", "bar"), hset.insert("foo") 27 | 28 | 29 | def registry_add(): 30 | resource = DRAFT202012.create_resource(schema) 31 | return registry.with_resource(uri="urn:example", resource=resource) 32 | 33 | 34 | if __name__ == "__main__": 35 | from pyperf import Runner 36 | runner = Runner() 37 | 38 | runner.bench_func("HashMap/HashSet insertion", registry_data_structures) 39 | runner.bench_func("Registry insertion", registry_add) 40 | runner.bench_func("Success", lambda: v.is_valid([1])) 41 | runner.bench_func("Failure", lambda: v.is_valid(["foo"])) 42 | runner.bench_func("Metaschema validation", lambda: v.check_schema(schema)) 43 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/unused_registry.py: -------------------------------------------------------------------------------- 1 | """ 2 | An unused schema registry should not cause slower validation. 3 | 4 | "Unused" here means one where no reference resolution is occurring anyhow. 5 | 6 | See https://github.com/python-jsonschema/jsonschema/issues/1088. 7 | """ 8 | from pyperf import Runner 9 | from referencing import Registry 10 | from referencing.jsonschema import DRAFT201909 11 | 12 | from jsonschema import Draft201909Validator 13 | 14 | registry = Registry().with_resource( 15 | "urn:example:foo", 16 | DRAFT201909.create_resource({}), 17 | ) 18 | 19 | schema = {"$ref": "https://json-schema.org/draft/2019-09/schema"} 20 | instance = {"maxLength": 4} 21 | 22 | no_registry = Draft201909Validator(schema) 23 | with_useless_registry = Draft201909Validator(schema, registry=registry) 24 | 25 | if __name__ == "__main__": 26 | runner = Runner() 27 | 28 | runner.bench_func( 29 | "no registry", 30 | lambda: no_registry.is_valid(instance), 31 | ) 32 | runner.bench_func( 33 | "useless registry", 34 | lambda: with_useless_registry.is_valid(instance), 35 | ) 36 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/useless_keywords.py: -------------------------------------------------------------------------------- 1 | """ 2 | A benchmark for validation of schemas containing lots of useless keywords. 3 | 4 | Checks we filter them out once, ahead of time. 5 | """ 6 | 7 | from pyperf import Runner 8 | 9 | from jsonschema import Draft202012Validator 10 | 11 | NUM_USELESS = 100000 12 | schema = dict( 13 | [ 14 | ("not", {"const": 42}), 15 | *((str(i), i) for i in range(NUM_USELESS)), 16 | ("type", "integer"), 17 | *((str(i), i) for i in range(NUM_USELESS, NUM_USELESS)), 18 | ("minimum", 37), 19 | ], 20 | ) 21 | validator = Draft202012Validator(schema) 22 | 23 | valid = 3737 24 | invalid = 12 25 | 26 | 27 | if __name__ == "__main__": 28 | runner = Runner() 29 | runner.bench_func("beginning of schema", lambda: validator.is_valid(42)) 30 | runner.bench_func("middle of schema", lambda: validator.is_valid("foo")) 31 | runner.bench_func("end of schema", lambda: validator.is_valid(12)) 32 | runner.bench_func("valid", lambda: validator.is_valid(3737)) 33 | -------------------------------------------------------------------------------- /jsonschema/benchmarks/validator_creation.py: -------------------------------------------------------------------------------- 1 | from pyperf import Runner 2 | 3 | from jsonschema import Draft202012Validator 4 | 5 | schema = { 6 | "type": "array", 7 | "minLength": 1, 8 | "maxLength": 1, 9 | "items": {"type": "integer"}, 10 | } 11 | 12 | 13 | if __name__ == "__main__": 14 | Runner().bench_func("validator creation", Draft202012Validator, schema) 15 | -------------------------------------------------------------------------------- /jsonschema/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/python-jsonschema/jsonschema/3e23ee5e695f84565f4175fb972073d787e1ab24/jsonschema/tests/__init__.py -------------------------------------------------------------------------------- /jsonschema/tests/fuzz_validate.py: -------------------------------------------------------------------------------- 1 | """ 2 | Fuzzing setup for OSS-Fuzz. 3 | 4 | See https://github.com/google/oss-fuzz/tree/master/projects/jsonschema for the 5 | other half of the setup here. 6 | """ 7 | import sys 8 | 9 | from hypothesis import given, strategies 10 | 11 | import jsonschema 12 | 13 | PRIM = strategies.one_of( 14 | strategies.booleans(), 15 | strategies.integers(), 16 | strategies.floats(allow_nan=False, allow_infinity=False), 17 | strategies.text(), 18 | ) 19 | DICT = strategies.recursive( 20 | base=strategies.one_of( 21 | strategies.booleans(), 22 | strategies.dictionaries(strategies.text(), PRIM), 23 | ), 24 | extend=lambda inner: strategies.dictionaries(strategies.text(), inner), 25 | ) 26 | 27 | 28 | @given(obj1=DICT, obj2=DICT) 29 | def test_schemas(obj1, obj2): 30 | try: 31 | jsonschema.validate(instance=obj1, schema=obj2) 32 | except jsonschema.exceptions.ValidationError: 33 | pass 34 | except jsonschema.exceptions.SchemaError: 35 | pass 36 | 37 | 38 | def main(): 39 | atheris.instrument_all() 40 | atheris.Setup( 41 | sys.argv, 42 | test_schemas.hypothesis.fuzz_one_input, 43 | enable_python_coverage=True, 44 | ) 45 | atheris.Fuzz() 46 | 47 | 48 | if __name__ == "__main__": 49 | import atheris 50 | main() 51 | --------------------------------------------------------------------------------