├── tests ├── latest ├── v1 │ ├── format │ │ ├── ecmascript-regex.json │ │ └── regex.json │ ├── optional │ │ ├── float-overflow.json │ │ └── id.json │ ├── defs.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── proposals │ │ ├── README.md │ │ └── propertyDependencies │ │ │ └── additionalProperties.json │ ├── infinite-loop-detection.json │ ├── minItems.json │ ├── maxItems.json │ ├── minLength.json │ ├── maxLength.json │ ├── minProperties.json │ ├── maximum.json │ └── pattern.json ├── draft2020-12 │ ├── optional │ │ ├── format │ │ │ ├── ecmascript-regex.json │ │ │ ├── unknown.json │ │ │ └── regex.json │ │ ├── float-overflow.json │ │ ├── cross-draft.json │ │ ├── no-schema.json │ │ └── format-assertion.json │ ├── defs.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── infinite-loop-detection.json │ ├── minItems.json │ ├── maxItems.json │ ├── minLength.json │ ├── maxLength.json │ ├── minProperties.json │ ├── maximum.json │ ├── vocabulary.json │ └── pattern.json ├── draft4 │ ├── optional │ │ ├── float-overflow.json │ │ ├── zeroTerminatedFloats.json │ │ ├── format │ │ │ └── unknown.json │ │ └── id.json │ ├── minItems.json │ ├── maxItems.json │ ├── definitions.json │ ├── minLength.json │ ├── maxLength.json │ ├── infinite-loop-detection.json │ ├── minProperties.json │ ├── maxProperties.json │ └── pattern.json ├── draft6 │ ├── optional │ │ ├── float-overflow.json │ │ └── format │ │ │ ├── unknown.json │ │ │ └── uri-template.json │ ├── definitions.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── infinite-loop-detection.json │ ├── minItems.json │ ├── maxItems.json │ ├── minLength.json │ ├── maxLength.json │ ├── minProperties.json │ ├── maximum.json │ └── pattern.json ├── draft7 │ ├── optional │ │ ├── float-overflow.json │ │ ├── cross-draft.json │ │ └── format │ │ │ ├── unknown.json │ │ │ ├── regex.json │ │ │ ├── idn-email.json │ │ │ └── uri-template.json │ ├── definitions.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── infinite-loop-detection.json │ ├── minItems.json │ ├── maxItems.json │ ├── minLength.json │ ├── maxLength.json │ ├── minProperties.json │ ├── maximum.json │ └── pattern.json ├── draft3 │ ├── optional │ │ ├── zeroTerminatedFloats.json │ │ └── format │ │ │ ├── ecmascript-regex.json │ │ │ ├── regex.json │ │ │ ├── time.json │ │ │ ├── ip-address.json │ │ │ ├── uri.json │ │ │ ├── color.json │ │ │ └── date-time.json │ ├── minItems.json │ ├── maxItems.json │ ├── minLength.json │ ├── maxLength.json │ ├── infinite-loop-detection.json │ ├── required.json │ ├── pattern.json │ └── divisibleBy.json └── draft2019-09 │ ├── optional │ ├── float-overflow.json │ ├── no-schema.json │ ├── format │ │ ├── unknown.json │ │ └── regex.json │ ├── cross-draft.json │ └── id.json │ ├── defs.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── infinite-loop-detection.json │ ├── minItems.json │ ├── maxItems.json │ ├── minLength.json │ ├── maxLength.json │ ├── minProperties.json │ ├── maximum.json │ ├── vocabulary.json │ └── pattern.json ├── .editorconfig ├── remotes ├── integer.json ├── nested │ ├── string.json │ └── foo-ref-string.json ├── baseUriChange │ └── folderInteger.json ├── baseUriChangeFolder │ └── folderInteger.json ├── baseUriChangeFolderInSubschema │ └── folderInteger.json ├── v1 │ ├── integer.json │ ├── nested │ │ ├── string.json │ │ └── foo-ref-string.json │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── subSchemas.json │ ├── locationIndependentIdentifier.json │ ├── detached-ref.json │ ├── ref-and-defs.json │ ├── detached-dynamicref.json │ ├── name-defs.json │ ├── tree.json │ └── extendible-dynamic-ref.json ├── draft2019-09 │ ├── integer.json │ ├── nested │ │ ├── string.json │ │ └── foo-ref-string.json │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── dependentRequired.json │ ├── ignore-prefixItems.json │ ├── subSchemas.json │ ├── locationIndependentIdentifier.json │ ├── detached-ref.json │ ├── ref-and-defs.json │ ├── name-defs.json │ ├── metaschema-no-validation.json │ ├── extendible-dynamic-ref.json │ └── metaschema-optional-vocabulary.json ├── draft2020-12 │ ├── integer.json │ ├── nested │ │ ├── string.json │ │ └── foo-ref-string.json │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── prefixItems.json │ ├── subSchemas.json │ ├── locationIndependentIdentifier.json │ ├── detached-ref.json │ ├── detached-dynamicref.json │ ├── ref-and-defs.json │ ├── name-defs.json │ ├── tree.json │ ├── metaschema-no-validation.json │ ├── format-assertion-true.json │ ├── format-assertion-false.json │ ├── extendible-dynamic-ref.json │ └── metaschema-optional-vocabulary.json ├── urn-ref-string.json ├── different-id-ref-string.json ├── draft7 │ ├── ignore-dependentRequired.json │ ├── subSchemas.json │ ├── locationIndependentIdentifier.json │ ├── detached-ref.json │ ├── name.json │ └── ref-and-definitions.json ├── draft3 │ └── subSchemas.json ├── draft4 │ ├── subSchemas.json │ ├── locationIndependentIdentifier.json │ └── name.json ├── draft6 │ ├── subSchemas.json │ ├── locationIndependentIdentifier.json │ ├── detached-ref.json │ ├── name.json │ └── ref-and-definitions.json ├── locationIndependentIdentifier.json ├── nested-absolute-ref-to-string.json ├── ref-and-defs.json ├── name-defs.json └── extendible-dynamic-ref.json ├── .github ├── CODEOWNERS └── workflows │ ├── pr-dependencies.yml │ ├── show_specification_annotations.yml │ ├── annotation-tests.yml │ └── ci.yml ├── tox.ini ├── package.json ├── annotations ├── test-suite.schema.json ├── test.schema.json ├── tests │ ├── format.json │ ├── unknown.json │ └── core.json ├── assertion.schema.json └── test-case.schema.json ├── bin ├── annotation-tests.ts └── specification_urls.json ├── LICENSE └── output-tests ├── draft2019-09 └── content │ ├── general.json │ ├── type.json │ ├── readOnly.json │ └── escape.json ├── draft2020-12 └── content │ ├── general.json │ ├── type.json │ ├── readOnly.json │ └── escape.json └── v1 └── content ├── type.json ├── readOnly.json └── general.json /tests/latest: -------------------------------------------------------------------------------- 1 | draft2020-12 -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | insert_final_newline = true 2 | -------------------------------------------------------------------------------- /remotes/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /remotes/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } 4 | -------------------------------------------------------------------------------- /remotes/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /remotes/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /remotes/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Ping the entire test suite team by default. 2 | * @json-schema-org/test-suite-team 3 | -------------------------------------------------------------------------------- /remotes/v1/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/v1/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/v1/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2019-09/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2020-12/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/v1/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2019-09/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2020-12/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/v1/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": {"$ref": "string.json"} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /remotes/draft2019-09/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2020-12/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2019-09/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2020-12/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2019-09/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /remotes/draft2020-12/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/draft3/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /remotes/draft4/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /remotes/draft6/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /remotes/draft7/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$anchor": "foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /remotes/v1/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/v1/detached-ref.json", 3 | "$schema": "https://json-schema.org/v1", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.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 }} -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "$id": "http://localhost:1234/v1/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /remotes/v1/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/v1/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/v1", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /tests/v1/format/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "\\a is not an ECMA 262 control escape", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | ] -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "description": "tree schema, extensible", 4 | "$id": "http://localhost:1234/v1/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /tests/v1/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/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /remotes/v1/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/v1", 3 | "description": "extendible array", 4 | "$id": "http://localhost:1234/v1/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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 6 | "$ref": "https://json-schema.org/v1" 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | "description": "an invalid time string in date-time format", 18 | "data": "2020-11-28T23:55:45Z", 19 | "valid": false 20 | } 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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 | -------------------------------------------------------------------------------- /tests/v1/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/proposals/README.md: -------------------------------------------------------------------------------- 1 | # JSON Schema Proposals Tests 2 | 3 | The subfolders herein represent tests for each active proposal to the specification. If the proposal is a keyword (generally the case), then the subfolder will bear the name of that keyword. Inside the proposal subfolder is a series of test files that would contain amendments to the required test suite should the proposal be incorporated into the specification. These test should be considered volitile while the proposal is in development, however implementations claiming to support the proposal are expected to pass its tests. 4 | 5 | > [!IMPORTANT] 6 | > This folder is NOT intended for proposed additions to the test suite or the specification. 7 | 8 | Proposals to the test suite can be made by [opening an issue](https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues/new) in this repository. 9 | 10 | Proposals to the specification should be made by following the process defined by our [Feature Life Cycle](https://github.com/json-schema-org/json-schema-spec/blob/main/PROCESS.md#feature-life-cycle). -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/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/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/proposals/propertyDependencies/additionalProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "propertyDependencies with additionalProperties", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 6 | "properties" : {"foo2" : {}}, 7 | "propertyDependencies": { 8 | "foo" : {}, 9 | "foo2": { 10 | "bar": { 11 | "properties": { 12 | "buz": {} 13 | } 14 | } 15 | } 16 | }, 17 | "additionalProperties": false 18 | }, 19 | "tests": [ 20 | { 21 | "description": "additionalProperties doesn't consider propertyDependencies properties" , 22 | "data": {"foo": ""}, 23 | "valid": false 24 | }, 25 | { 26 | "description": "additionalProperties can't see buz even when foo2 is present", 27 | "data": {"foo2": "bar", "buz": ""}, 28 | "valid": false 29 | }, 30 | { 31 | "description": "additionalProperties can't see buz", 32 | "data": {"buz": ""}, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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/v1", 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 | -------------------------------------------------------------------------------- /tests/v1/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | "description": "invalid extended year", 38 | "data": "+11963-06-19T08:30:06.283185Z", 39 | "valid": false 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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/v1", 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 | -------------------------------------------------------------------------------- /tests/v1/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/format/regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of regular expressions", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /output-tests/v1/content/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "incorrect type", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 6 | "$id": "https://json-schema.org/tests/content/v1/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/v1/type/0/tests/0/basic", 16 | "$ref": "/v1/output/schema", 17 | "properties": { 18 | "details": { 19 | "contains": { 20 | "properties": { 21 | "evaluationPath": {"const": ""}, 22 | "schemaLocation": {"const": "https://json-schema.org/tests/content/v1/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tests/v1/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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/v1", 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 | -------------------------------------------------------------------------------- /tests/v1/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 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/v1", 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /output-tests/v1/content/readOnly.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "readOnly generates its value as an annotation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 6 | "$id": "https://json-schema.org/tests/content/v1/readOnly/0", 7 | "readOnly": true 8 | }, 9 | "tests": [ 10 | { 11 | "description": "readOnly is true", 12 | "data": 1, 13 | "output": { 14 | "list": { 15 | "$id": "https://json-schema.org/tests/content/v1/readOnly/0/tests/0/basic", 16 | "$ref": "/v1/output/schema", 17 | "properties": { 18 | "details": { 19 | "contains": { 20 | "properties": { 21 | "evaluationPath": {"const": ""}, 22 | "schemaLocation": {"const": "https://json-schema.org/tests/content/v1/readOnly/0#"}, 23 | "instanceLocation": {"const": ""}, 24 | "annotations": { 25 | "properties": { 26 | "readOnly": {"const": true} 27 | }, 28 | "required": ["readOnly"] 29 | } 30 | }, 31 | "required": ["evaluationPath", "schemaLocation", "instanceLocation", "annotations"] 32 | } 33 | } 34 | }, 35 | "required": ["details"] 36 | } 37 | } 38 | } 39 | ] 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /tests/draft4/optional/id.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "id inside an enum is not a real identifier", 4 | "comment": "the implementation must not be confused by an id buried in the enum", 5 | "schema": { 6 | "definitions": { 7 | "id_in_enum": { 8 | "enum": [ 9 | { 10 | "id": "https://localhost:1234/my_identifier.json", 11 | "type": "null" 12 | } 13 | ] 14 | }, 15 | "real_id_in_schema": { 16 | "id": "https://localhost:1234/my_identifier.json", 17 | "type": "string" 18 | }, 19 | "zzz_id_in_const": { 20 | "const": { 21 | "id": "https://localhost:1234/my_identifier.json", 22 | "type": "null" 23 | } 24 | } 25 | }, 26 | "anyOf": [ 27 | { "$ref": "#/definitions/id_in_enum" }, 28 | { "$ref": "https://localhost:1234/my_identifier.json" } 29 | ] 30 | }, 31 | "tests": [ 32 | { 33 | "description": "exact match to enum, and type matches", 34 | "data": { 35 | "id": "https://localhost:1234/my_identifier.json", 36 | "type": "null" 37 | }, 38 | "valid": true 39 | }, 40 | { 41 | "description": "match $ref to id", 42 | "data": "a string to match #/definitions/id_in_enum", 43 | "valid": true 44 | }, 45 | { 46 | "description": "no match on enum or $ref to id", 47 | "data": 1, 48 | "valid": false 49 | } 50 | ] 51 | } 52 | 53 | ] 54 | -------------------------------------------------------------------------------- /tests/draft2020-12/vocabulary.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with with no validation vocabulary", 4 | "schema": { 5 | "$id": "https://schema/using/no/validation", 6 | "$schema": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", 7 | "properties": { 8 | "badProperty": false, 9 | "numberProperty": { 10 | "minimum": 10 11 | } 12 | } 13 | }, 14 | "tests": [ 15 | { 16 | "description": "applicator vocabulary still works", 17 | "data": { 18 | "badProperty": "this property should not exist" 19 | }, 20 | "valid": false 21 | }, 22 | { 23 | "description": "no validation: valid number", 24 | "data": { 25 | "numberProperty": 20 26 | }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "no validation: invalid number, but it still validates", 31 | "data": { 32 | "numberProperty": 1 33 | }, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "ignore unrecognized optional vocabulary", 40 | "schema": { 41 | "$schema": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json", 42 | "type": "number" 43 | }, 44 | "tests": [ 45 | { 46 | "description": "string value", 47 | "data": "foobar", 48 | "valid": false 49 | }, 50 | { 51 | "description": "number value", 52 | "data": 20, 53 | "valid": true 54 | } 55 | ] 56 | } 57 | ] 58 | -------------------------------------------------------------------------------- /tests/v1/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 6 | "pattern": "^a*$" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a matching pattern is valid", 11 | "data": "aaa", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a non-matching pattern is invalid", 16 | "data": "abc", 17 | "valid": false 18 | }, 19 | { 20 | "description": "ignores booleans", 21 | "data": true, 22 | "valid": true 23 | }, 24 | { 25 | "description": "ignores integers", 26 | "data": 123, 27 | "valid": true 28 | }, 29 | { 30 | "description": "ignores floats", 31 | "data": 1.0, 32 | "valid": true 33 | }, 34 | { 35 | "description": "ignores objects", 36 | "data": {}, 37 | "valid": true 38 | }, 39 | { 40 | "description": "ignores arrays", 41 | "data": [], 42 | "valid": true 43 | }, 44 | { 45 | "description": "ignores null", 46 | "data": null, 47 | "valid": true 48 | } 49 | ] 50 | }, 51 | { 52 | "description": "pattern is not anchored", 53 | "schema": { 54 | "$schema": "https://json-schema.org/v1", 55 | "pattern": "a+" 56 | }, 57 | "tests": [ 58 | { 59 | "description": "matches a substring", 60 | "data": "xxaayy", 61 | "valid": true 62 | } 63 | ] 64 | } 65 | ] 66 | -------------------------------------------------------------------------------- /tests/draft2019-09/vocabulary.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with with no validation vocabulary", 4 | "schema": { 5 | "$id": "https://schema/using/no/validation", 6 | "$schema": "http://localhost:1234/draft2019-09/metaschema-no-validation.json", 7 | "properties": { 8 | "badProperty": false, 9 | "numberProperty": { 10 | "minimum": 10 11 | } 12 | } 13 | }, 14 | "tests": [ 15 | { 16 | "description": "applicator vocabulary still works", 17 | "data": { 18 | "badProperty": "this property should not exist" 19 | }, 20 | "valid": false 21 | }, 22 | { 23 | "description": "no validation: valid number", 24 | "data": { 25 | "numberProperty": 20 26 | }, 27 | "valid": true 28 | }, 29 | { 30 | "description": "no validation: invalid number, but it still validates", 31 | "data": { 32 | "numberProperty": 1 33 | }, 34 | "valid": true 35 | } 36 | ] 37 | }, 38 | { 39 | "description": "ignore unrecognized optional vocabulary", 40 | "schema": { 41 | "$schema": "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json", 42 | "type": "number" 43 | }, 44 | "tests": [ 45 | { 46 | "description": "string value", 47 | "data": "foobar", 48 | "valid": false 49 | }, 50 | { 51 | "description": "number value", 52 | "data": 20, 53 | "valid": true 54 | } 55 | ] 56 | } 57 | ] 58 | -------------------------------------------------------------------------------- /tests/draft2019-09/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "pattern": "^a*$" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a matching pattern is valid", 11 | "data": "aaa", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a non-matching pattern is invalid", 16 | "data": "abc", 17 | "valid": false 18 | }, 19 | { 20 | "description": "ignores booleans", 21 | "data": true, 22 | "valid": true 23 | }, 24 | { 25 | "description": "ignores integers", 26 | "data": 123, 27 | "valid": true 28 | }, 29 | { 30 | "description": "ignores floats", 31 | "data": 1.0, 32 | "valid": true 33 | }, 34 | { 35 | "description": "ignores objects", 36 | "data": {}, 37 | "valid": true 38 | }, 39 | { 40 | "description": "ignores arrays", 41 | "data": [], 42 | "valid": true 43 | }, 44 | { 45 | "description": "ignores null", 46 | "data": null, 47 | "valid": true 48 | } 49 | ] 50 | }, 51 | { 52 | "description": "pattern is not anchored", 53 | "schema": { 54 | "$schema": "https://json-schema.org/draft/2019-09/schema", 55 | "pattern": "a+" 56 | }, 57 | "tests": [ 58 | { 59 | "description": "matches a substring", 60 | "data": "xxaayy", 61 | "valid": true 62 | } 63 | ] 64 | } 65 | ] 66 | -------------------------------------------------------------------------------- /tests/draft2020-12/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "pattern": "^a*$" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a matching pattern is valid", 11 | "data": "aaa", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a non-matching pattern is invalid", 16 | "data": "abc", 17 | "valid": false 18 | }, 19 | { 20 | "description": "ignores booleans", 21 | "data": true, 22 | "valid": true 23 | }, 24 | { 25 | "description": "ignores integers", 26 | "data": 123, 27 | "valid": true 28 | }, 29 | { 30 | "description": "ignores floats", 31 | "data": 1.0, 32 | "valid": true 33 | }, 34 | { 35 | "description": "ignores objects", 36 | "data": {}, 37 | "valid": true 38 | }, 39 | { 40 | "description": "ignores arrays", 41 | "data": [], 42 | "valid": true 43 | }, 44 | { 45 | "description": "ignores null", 46 | "data": null, 47 | "valid": true 48 | } 49 | ] 50 | }, 51 | { 52 | "description": "pattern is not anchored", 53 | "schema": { 54 | "$schema": "https://json-schema.org/draft/2020-12/schema", 55 | "pattern": "a+" 56 | }, 57 | "tests": [ 58 | { 59 | "description": "matches a substring", 60 | "data": "xxaayy", 61 | "valid": true 62 | } 63 | ] 64 | } 65 | ] 66 | -------------------------------------------------------------------------------- /tests/v1/optional/id.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "$id inside an enum is not a real identifier", 4 | "comment": "the implementation must not be confused by an $id buried in the enum", 5 | "schema": { 6 | "$schema": "https://json-schema.org/v1", 7 | "$defs": { 8 | "id_in_enum": { 9 | "enum": [ 10 | { 11 | "$id": "https://localhost:1234/v1/id/my_identifier.json", 12 | "type": "null" 13 | } 14 | ] 15 | }, 16 | "real_id_in_schema": { 17 | "$id": "https://localhost:1234/v1/id/my_identifier.json", 18 | "type": "string" 19 | }, 20 | "zzz_id_in_const": { 21 | "const": { 22 | "$id": "https://localhost:1234/v1/id/my_identifier.json", 23 | "type": "null" 24 | } 25 | } 26 | }, 27 | "anyOf": [ 28 | { "$ref": "#/$defs/id_in_enum" }, 29 | { "$ref": "https://localhost:1234/v1/id/my_identifier.json" } 30 | ] 31 | }, 32 | "tests": [ 33 | { 34 | "description": "exact match to enum, and type matches", 35 | "data": { 36 | "$id": "https://localhost:1234/v1/id/my_identifier.json", 37 | "type": "null" 38 | }, 39 | "valid": true 40 | }, 41 | { 42 | "description": "match $ref to $id", 43 | "data": "a string to match #/$defs/id_in_enum", 44 | "valid": true 45 | }, 46 | { 47 | "description": "no match on enum or $ref to $id", 48 | "data": 1, 49 | "valid": false 50 | } 51 | ] 52 | } 53 | ] 54 | -------------------------------------------------------------------------------- /tests/draft7/optional/format/idn-email.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of an internationalized e-mail addresses", 4 | "schema": { "format": "idn-email" }, 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 idn e-mail (example@example.test in Hangul)", 38 | "data": "실례@실례.테스트", 39 | "valid": true 40 | }, 41 | { 42 | "description": "an invalid idn e-mail address", 43 | "data": "2962", 44 | "valid": false 45 | }, 46 | { 47 | "description": "a valid e-mail address", 48 | "data": "joe.bloggs@example.com", 49 | "valid": true 50 | }, 51 | { 52 | "description": "an invalid e-mail address", 53 | "data": "2962", 54 | "valid": false 55 | } 56 | ] 57 | } 58 | ] 59 | -------------------------------------------------------------------------------- /output-tests/v1/content/general.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "failed validation produces no annotations", 4 | "schema": { 5 | "$schema": "https://json-schema.org/v1", 6 | "$id": "https://json-schema.org/tests/content/v1/general/0", 7 | "type": "string", 8 | "readOnly": true 9 | }, 10 | "tests": [ 11 | { 12 | "description": "dropped annotations MAY appear in droppedAnnotations", 13 | "data": 1, 14 | "output": { 15 | "list": { 16 | "$id": "https://json-schema.org/tests/content/v1/general/0/tests/0/basic", 17 | "$ref": "/v1/output/schema", 18 | "properties": { 19 | "details": { 20 | "contains": { 21 | "properties": { 22 | "evaluationPath": {"const": ""}, 23 | "schemaLocation": {"const": "https://json-schema.org/tests/content/v1/general/0#"}, 24 | "instanceLocation": {"const": ""}, 25 | "annotations": false, 26 | "droppedAnnotations": { 27 | "properties": { 28 | "readOnly": {"const": true} 29 | }, 30 | "required": ["readOnly"] 31 | } 32 | }, 33 | "required": ["evaluationPath", "schemaLocation", "instanceLocation"] 34 | } 35 | } 36 | }, 37 | "required": ["details"] 38 | } 39 | } 40 | } 41 | ] 42 | } 43 | ] 44 | -------------------------------------------------------------------------------- /tests/draft6/optional/format/uri-template.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "format: uri-template", 4 | "schema": { "format": "uri-template" }, 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 uri-template", 38 | "data": "http://example.com/dictionary/{term:1}/{term}", 39 | "valid": true 40 | }, 41 | { 42 | "description": "an invalid uri-template", 43 | "data": "http://example.com/dictionary/{term:1}/{term", 44 | "valid": false 45 | }, 46 | { 47 | "description": "a valid uri-template without variables", 48 | "data": "http://example.com/dictionary", 49 | "valid": true 50 | }, 51 | { 52 | "description": "a valid relative uri-template", 53 | "data": "dictionary/{term:1}/{term}", 54 | "valid": true 55 | } 56 | ] 57 | } 58 | ] 59 | -------------------------------------------------------------------------------- /tests/draft7/optional/format/uri-template.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "format: uri-template", 4 | "schema": { "format": "uri-template" }, 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 uri-template", 38 | "data": "http://example.com/dictionary/{term:1}/{term}", 39 | "valid": true 40 | }, 41 | { 42 | "description": "an invalid uri-template", 43 | "data": "http://example.com/dictionary/{term:1}/{term", 44 | "valid": false 45 | }, 46 | { 47 | "description": "a valid uri-template without variables", 48 | "data": "http://example.com/dictionary", 49 | "valid": true 50 | }, 51 | { 52 | "description": "a valid relative uri-template", 53 | "data": "dictionary/{term:1}/{term}", 54 | "valid": true 55 | } 56 | ] 57 | } 58 | ] 59 | -------------------------------------------------------------------------------- /tests/draft2019-09/optional/id.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "$id inside an enum is not a real identifier", 4 | "comment": "the implementation must not be confused by an $id buried in the enum", 5 | "schema": { 6 | "$schema": "https://json-schema.org/draft/2019-09/schema", 7 | "$defs": { 8 | "id_in_enum": { 9 | "enum": [ 10 | { 11 | "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", 12 | "type": "null" 13 | } 14 | ] 15 | }, 16 | "real_id_in_schema": { 17 | "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", 18 | "type": "string" 19 | }, 20 | "zzz_id_in_const": { 21 | "const": { 22 | "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", 23 | "type": "null" 24 | } 25 | } 26 | }, 27 | "anyOf": [ 28 | { "$ref": "#/$defs/id_in_enum" }, 29 | { "$ref": "https://localhost:1234/draft2019-09/id/my_identifier.json" } 30 | ] 31 | }, 32 | "tests": [ 33 | { 34 | "description": "exact match to enum, and type matches", 35 | "data": { 36 | "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json", 37 | "type": "null" 38 | }, 39 | "valid": true 40 | }, 41 | { 42 | "description": "match $ref to $id", 43 | "data": "a string to match #/$defs/id_in_enum", 44 | "valid": true 45 | }, 46 | { 47 | "description": "no match on enum or $ref to $id", 48 | "data": 1, 49 | "valid": false 50 | } 51 | ] 52 | } 53 | ] 54 | --------------------------------------------------------------------------------