├── .github ├── CODEOWNERS ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── dart_ci.yaml │ └── publish.yaml ├── .gitignore ├── .pubignore ├── CHANGELOG.md ├── COPYRIGHT_TRANSFER ├── LICENSE ├── MIGRATION.md ├── Makefile ├── README.md ├── analysis_options.yaml ├── dart_test.yaml ├── example ├── custom_format │ └── custom_format_example.dart ├── custom_vocabulary │ ├── custom_date_range.dart │ ├── date-range-meta-schema.json │ └── example-date-range-schema.json ├── from_json │ ├── movie_sample.dart │ └── validate_json_from_data.dart ├── from_url │ ├── grades_schema.json │ ├── grades_schema.png │ └── validate_instance_from_url.dart └── readme │ ├── asynchronous_creation │ ├── from_file.dart │ ├── from_url.dart │ ├── geo.schema.json │ ├── remote_http_refs.dart │ └── remote_ref_cache.dart │ └── synchronous_creation │ ├── local_ref_cache.dart │ └── self_contained.dart ├── lib ├── fix_data.yaml ├── json_schema.dart └── src │ └── json_schema │ ├── constants.dart │ ├── formats │ ├── date_time_validator.dart │ ├── date_validator.dart │ ├── duration_validator.dart │ ├── email_validator.dart │ ├── hostname_validator.dart │ ├── idn_email_validator.dart │ ├── idn_hostname_validator.dart │ ├── ipv4_validator.dart │ ├── ipv6_validator.dart │ ├── iri_reference_validator.dart │ ├── iri_validator.dart │ ├── json_pointer_validator.dart │ ├── regex_validator.dart │ ├── relative_json_pointer_validator.dart │ ├── time_validator.dart │ ├── uri_reference_validator.dart │ ├── uri_template_validator.dart │ ├── uri_validator.dart │ ├── uuid_validator.dart │ ├── validation_regexes.dart │ └── validators.dart │ ├── global_platform_functions.dart │ ├── json_schema.dart │ ├── models │ ├── concrete_validation_context.dart │ ├── custom_keyword.dart │ ├── custom_vocabulary.dart │ ├── instance.dart │ ├── instance_ref_pair.dart │ ├── ref_provider.dart │ ├── schema_path_pair.dart │ ├── schema_type.dart │ ├── schema_version.dart │ ├── typedefs.dart │ ├── validation_context.dart │ └── validation_results.dart │ ├── schema_url_client │ ├── html_schema_url_client.dart │ ├── io_schema_url_client.dart │ ├── schema_url_client.dart │ └── stub_schema_url_client.dart │ ├── utils │ ├── format_exceptions.dart │ ├── type_validators.dart │ └── utils.dart │ └── validator.dart ├── pubspec.yaml ├── test ├── JSON-Schema-Test-Suite │ ├── .github │ │ └── workflows │ │ │ └── ci.yml │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── bin │ │ └── jsonschema_suite │ ├── index.js │ ├── package.json │ ├── remotes │ │ ├── baseUriChange │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolder │ │ │ └── folderInteger.json │ │ ├── baseUriChangeFolderInSubschema │ │ │ └── folderInteger.json │ │ ├── draft-next │ │ │ ├── format-assertion-false.json │ │ │ ├── format-assertion-true.json │ │ │ └── metaschema-no-validation.json │ │ ├── draft2019-09 │ │ │ └── metaschema-no-validation.json │ │ ├── draft2020-12 │ │ │ ├── format-assertion-false.json │ │ │ ├── format-assertion-true.json │ │ │ └── metaschema-no-validation.json │ │ ├── extendible-dynamic-ref.json │ │ ├── integer.json │ │ ├── name-defs.json │ │ ├── name.json │ │ ├── ref-and-definitions.json │ │ ├── ref-and-defs.json │ │ ├── subSchemas-defs.json │ │ ├── subSchemas.json │ │ └── tree.json │ ├── test-schema.json │ ├── tests │ │ ├── draft-next │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anchor.json │ │ │ ├── anyOf.json │ │ │ ├── boolean_schema.json │ │ │ ├── const.json │ │ │ ├── contains.json │ │ │ ├── content.json │ │ │ ├── default.json │ │ │ ├── defs.json │ │ │ ├── dependentRequired.json │ │ │ ├── dependentSchemas.json │ │ │ ├── dynamicRef.json │ │ │ ├── enum.json │ │ │ ├── exclusiveMaximum.json │ │ │ ├── exclusiveMinimum.json │ │ │ ├── format.json │ │ │ ├── id.json │ │ │ ├── if-then-else.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxContains.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minContains.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── float-overflow.json │ │ │ │ ├── format-assertion.json │ │ │ │ ├── format │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── date.json │ │ │ │ │ ├── duration.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── hostname.json │ │ │ │ │ ├── idn-email.json │ │ │ │ │ ├── idn-hostname.json │ │ │ │ │ ├── ipv4.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── iri-reference.json │ │ │ │ │ ├── iri.json │ │ │ │ │ ├── json-pointer.json │ │ │ │ │ ├── regex.json │ │ │ │ │ ├── relative-json-pointer.json │ │ │ │ │ ├── time.json │ │ │ │ │ ├── uri-reference.json │ │ │ │ │ ├── uri-template.json │ │ │ │ │ ├── uri.json │ │ │ │ │ └── uuid.json │ │ │ │ ├── non-bmp-regex.json │ │ │ │ └── refOfUnknownKeyword.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── prefixItems.json │ │ │ ├── properties.json │ │ │ ├── propertyNames.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ ├── unevaluatedItems.json │ │ │ ├── unevaluatedProperties.json │ │ │ ├── uniqueItems.json │ │ │ ├── unknownKeyword.json │ │ │ └── vocabulary.json │ │ ├── draft2019-09 │ │ │ ├── additionalItems.json │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anchor.json │ │ │ ├── anyOf.json │ │ │ ├── boolean_schema.json │ │ │ ├── const.json │ │ │ ├── contains.json │ │ │ ├── content.json │ │ │ ├── default.json │ │ │ ├── defs.json │ │ │ ├── dependentRequired.json │ │ │ ├── dependentSchemas.json │ │ │ ├── enum.json │ │ │ ├── exclusiveMaximum.json │ │ │ ├── exclusiveMinimum.json │ │ │ ├── format.json │ │ │ ├── id.json │ │ │ ├── if-then-else.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxContains.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minContains.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── float-overflow.json │ │ │ │ ├── format │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── date.json │ │ │ │ │ ├── duration.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── hostname.json │ │ │ │ │ ├── idn-email.json │ │ │ │ │ ├── idn-hostname.json │ │ │ │ │ ├── ipv4.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── iri-reference.json │ │ │ │ │ ├── iri.json │ │ │ │ │ ├── json-pointer.json │ │ │ │ │ ├── regex.json │ │ │ │ │ ├── relative-json-pointer.json │ │ │ │ │ ├── time.json │ │ │ │ │ ├── unknown.json │ │ │ │ │ ├── uri-reference.json │ │ │ │ │ ├── uri-template.json │ │ │ │ │ ├── uri.json │ │ │ │ │ └── uuid.json │ │ │ │ ├── non-bmp-regex.json │ │ │ │ └── refOfUnknownKeyword.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── properties.json │ │ │ ├── propertyNames.json │ │ │ ├── recursiveRef.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ ├── unevaluatedItems.json │ │ │ ├── unevaluatedProperties.json │ │ │ ├── uniqueItems.json │ │ │ ├── unknownKeyword.json │ │ │ └── vocabulary.json │ │ ├── draft2020-12 │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anchor.json │ │ │ ├── anyOf.json │ │ │ ├── boolean_schema.json │ │ │ ├── const.json │ │ │ ├── contains.json │ │ │ ├── content.json │ │ │ ├── default.json │ │ │ ├── defs.json │ │ │ ├── dependentRequired.json │ │ │ ├── dependentSchemas.json │ │ │ ├── dynamicRef.json │ │ │ ├── enum.json │ │ │ ├── exclusiveMaximum.json │ │ │ ├── exclusiveMinimum.json │ │ │ ├── format.json │ │ │ ├── id.json │ │ │ ├── if-then-else.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxContains.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minContains.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── float-overflow.json │ │ │ │ ├── format-assertion.json │ │ │ │ ├── format │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── date.json │ │ │ │ │ ├── duration.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── hostname.json │ │ │ │ │ ├── idn-email.json │ │ │ │ │ ├── idn-hostname.json │ │ │ │ │ ├── ipv4.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── iri-reference.json │ │ │ │ │ ├── iri.json │ │ │ │ │ ├── json-pointer.json │ │ │ │ │ ├── regex.json │ │ │ │ │ ├── relative-json-pointer.json │ │ │ │ │ ├── time.json │ │ │ │ │ ├── unknown.json │ │ │ │ │ ├── uri-reference.json │ │ │ │ │ ├── uri-template.json │ │ │ │ │ ├── uri.json │ │ │ │ │ └── uuid.json │ │ │ │ ├── non-bmp-regex.json │ │ │ │ └── refOfUnknownKeyword.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── prefixItems.json │ │ │ ├── properties.json │ │ │ ├── propertyNames.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ ├── unevaluatedItems.json │ │ │ ├── unevaluatedProperties.json │ │ │ ├── uniqueItems.json │ │ │ ├── unknownKeyword.json │ │ │ └── vocabulary.json │ │ ├── draft3 │ │ │ ├── additionalItems.json │ │ │ ├── additionalProperties.json │ │ │ ├── default.json │ │ │ ├── dependencies.json │ │ │ ├── disallow.json │ │ │ ├── divisibleBy.json │ │ │ ├── enum.json │ │ │ ├── extends.json │ │ │ ├── format.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maximum.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minimum.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── format │ │ │ │ │ ├── color.json │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── date.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── host-name.json │ │ │ │ │ ├── ip-address.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── regex.json │ │ │ │ │ ├── time.json │ │ │ │ │ └── uri.json │ │ │ │ ├── non-bmp-regex.json │ │ │ │ └── zeroTerminatedFloats.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── properties.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ └── uniqueItems.json │ │ ├── draft4 │ │ │ ├── additionalItems.json │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anyOf.json │ │ │ ├── default.json │ │ │ ├── definitions.json │ │ │ ├── dependencies.json │ │ │ ├── enum.json │ │ │ ├── format.json │ │ │ ├── id.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── float-overflow.json │ │ │ │ ├── format │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── hostname.json │ │ │ │ │ ├── ipv4.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── unknown.json │ │ │ │ │ └── uri.json │ │ │ │ ├── non-bmp-regex.json │ │ │ │ └── zeroTerminatedFloats.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── properties.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ └── uniqueItems.json │ │ ├── draft6 │ │ │ ├── additionalItems.json │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anyOf.json │ │ │ ├── boolean_schema.json │ │ │ ├── const.json │ │ │ ├── contains.json │ │ │ ├── default.json │ │ │ ├── definitions.json │ │ │ ├── dependencies.json │ │ │ ├── enum.json │ │ │ ├── exclusiveMaximum.json │ │ │ ├── exclusiveMinimum.json │ │ │ ├── format.json │ │ │ ├── id.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── float-overflow.json │ │ │ │ ├── format │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── hostname.json │ │ │ │ │ ├── ipv4.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── json-pointer.json │ │ │ │ │ ├── unknown.json │ │ │ │ │ ├── uri-reference.json │ │ │ │ │ ├── uri-template.json │ │ │ │ │ └── uri.json │ │ │ │ └── non-bmp-regex.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── properties.json │ │ │ ├── propertyNames.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ ├── uniqueItems.json │ │ │ └── unknownKeyword.json │ │ ├── draft7 │ │ │ ├── additionalItems.json │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anyOf.json │ │ │ ├── boolean_schema.json │ │ │ ├── const.json │ │ │ ├── contains.json │ │ │ ├── default.json │ │ │ ├── definitions.json │ │ │ ├── dependencies.json │ │ │ ├── enum.json │ │ │ ├── exclusiveMaximum.json │ │ │ ├── exclusiveMinimum.json │ │ │ ├── format.json │ │ │ ├── id.json │ │ │ ├── if-then-else.json │ │ │ ├── infinite-loop-detection.json │ │ │ ├── items.json │ │ │ ├── maxItems.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── optional │ │ │ │ ├── bignum.json │ │ │ │ ├── content.json │ │ │ │ ├── ecmascript-regex.json │ │ │ │ ├── float-overflow.json │ │ │ │ ├── format │ │ │ │ │ ├── date-time.json │ │ │ │ │ ├── date.json │ │ │ │ │ ├── email.json │ │ │ │ │ ├── hostname.json │ │ │ │ │ ├── idn-email.json │ │ │ │ │ ├── idn-hostname.json │ │ │ │ │ ├── ipv4.json │ │ │ │ │ ├── ipv6.json │ │ │ │ │ ├── iri-reference.json │ │ │ │ │ ├── iri.json │ │ │ │ │ ├── json-pointer.json │ │ │ │ │ ├── regex.json │ │ │ │ │ ├── relative-json-pointer.json │ │ │ │ │ ├── time.json │ │ │ │ │ ├── unknown.json │ │ │ │ │ ├── uri-reference.json │ │ │ │ │ ├── uri-template.json │ │ │ │ │ └── uri.json │ │ │ │ └── non-bmp-regex.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── properties.json │ │ │ ├── propertyNames.json │ │ │ ├── ref.json │ │ │ ├── refRemote.json │ │ │ ├── required.json │ │ │ ├── type.json │ │ │ ├── uniqueItems.json │ │ │ └── unknownKeyword.json │ │ └── latest │ └── tox.ini ├── additional_remotes │ ├── bar.json │ ├── date-keyword-meta-schema.json │ ├── string.json │ └── string_ref.json ├── custom │ ├── invalid_schemas │ │ └── draft4 │ │ │ ├── additionalProperties.json │ │ │ ├── allOf.json │ │ │ ├── anyOf.json │ │ │ ├── cycle.json │ │ │ ├── definitions.json │ │ │ ├── dependencies.json │ │ │ ├── description.json │ │ │ ├── enum.json │ │ │ ├── exclusiveMaximum.json │ │ │ ├── exclusiveMinimum.json │ │ │ ├── freeFormProperty.json │ │ │ ├── id.json │ │ │ ├── items.json │ │ │ ├── maxLength.json │ │ │ ├── maxProperties.json │ │ │ ├── maximum.json │ │ │ ├── minItems.json │ │ │ ├── minLength.json │ │ │ ├── minProperties.json │ │ │ ├── minimum.json │ │ │ ├── multipleOf.json │ │ │ ├── not.json │ │ │ ├── oneOf.json │ │ │ ├── pattern.json │ │ │ ├── patternProperties.json │ │ │ ├── properties.json │ │ │ ├── ref.json │ │ │ ├── required.json │ │ │ ├── title.json │ │ │ ├── type.json │ │ │ └── uniqueItems.json │ └── valid_schemas │ │ └── draft2019-09 │ │ └── example.json ├── relative_refs │ ├── root.json │ ├── string.json │ └── subdir │ │ └── integer.json └── unit │ ├── additional_remotes.dart │ ├── constants.dart │ ├── json_schema │ ├── configurable_format_validation_test.dart │ ├── custom_formats_test.dart │ ├── custom_vocabularies_test.dart │ ├── draft4_invalid_schemas_test.dart │ ├── empty_schemas.dart │ ├── examples_keyword_test.dart │ ├── nested_refs_in_root_schema_test.dart │ ├── relative_file_uri_test.dart │ ├── resolve_path_test.dart │ ├── schema_create_test.dart │ ├── schema_self_validation.dart │ ├── specification_test.dart │ └── validation_error_test.dart │ ├── specification_remotes.dart │ └── specification_tests.dart ├── test_fixes ├── rename_to_validate.dart └── rename_to_validate.dart.expect └── tool ├── cors_headers.dart ├── gen.dart └── serve_remotes.dart /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @Workiva/configurable-ui 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ## Type 5 | 6 | ## Details 7 | 8 | 9 | 10 | ## Possible Solution 11 | 12 | 13 | 14 | 15 | 16 | ## Steps to Reproduce 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 22 | ## Your Environment 23 | 24 | * Version: 25 | * Browser name / VM and version: 26 | * Operating System and version: 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Ultimate problem: 2 | 3 | 4 | ## How it was fixed: 5 | 6 | 7 | ## Testing suggestions: 8 | 9 | 10 | ## Potential areas of regression: 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.github/workflows/dart_ci.yaml: -------------------------------------------------------------------------------- 1 | name: Dart CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'master' 7 | - 'test_consume_*' 8 | pull_request: 9 | branches: 10 | - '*' 11 | 12 | jobs: 13 | test: 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | sdk: [ 2.19.6, stable ] 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: dart-lang/setup-dart@v1 21 | with: 22 | sdk: ${{ matrix.sdk }} 23 | - name: Install dependencies 24 | run: dart pub get 25 | - name: Validate dependencies 26 | run: dart run dependency_validator 27 | - name: Check formatting 28 | run: dart format --line-length=120 --output=none --set-exit-if-changed . 29 | if: ${{ matrix.sdk == 'stable' }} 30 | - name: Analyze project source 31 | run: dart analyze 32 | - name: Check Generated Fixtures Are Up-To-Date 33 | run: make gen-fixtures --check 34 | - name: Run tests 35 | run: make test-with-serve-remotes 36 | # TODO https://github.com/Workiva/json_schema/issues/184 37 | # When ^^^ is addressed, remove the --skip-validation flag here 38 | - name: Publish - dry run 39 | if: ${{ matrix.sdk == 'stable' }} 40 | run: dart pub publish --dry-run --skip-validation 41 | - name: Test 'dart fix' 42 | # if one of these tests stops working in a future Dart SDK, it may be 43 | # fine to keep entries in lib/fix_data.yaml and just remove the tests. 44 | run: dart fix --compare-to-golden test_fixes/ 45 | -------------------------------------------------------------------------------- /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | tags: 6 | # Releases 7 | - '[0-9]+.[0-9]+.[0-9]+' 8 | 9 | permissions: 10 | contents: write 11 | id-token: write 12 | pull-requests: write 13 | 14 | jobs: 15 | create-sbom-release-asset: 16 | name: Create SBOM Release Asset 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | - name: Publish SBOM to Release Assets 21 | uses: anchore/sbom-action@v0 22 | with: 23 | path: ./ 24 | format: cyclonedx-json 25 | # TODO https://github.com/Workiva/json_schema/issues/184 26 | # Based on https://github.com/dart-lang/setup-dart/blob/main/.github/workflows/publish.yml 27 | publish: 28 | name: Publish to pub.dev 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: actions/checkout@v4 32 | - uses: dart-lang/setup-dart@v1 33 | with: 34 | sdk: stable 35 | - name: Install dependencies 36 | run: dart pub get 37 | - name: Publish - dry run 38 | run: dart pub publish --dry-run --skip-validation 39 | - name: Publish 40 | run: dart pub publish -f 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.~*~ 2 | .idea/ 3 | .packages 4 | .project 5 | .dart_tool/ 6 | *.dart.js 7 | *.iml 8 | *.ipr 9 | *.iws 10 | *.js_ 11 | *.js.deps 12 | *.js.map 13 | build/ 14 | coverage 15 | pubspec.lock 16 | 17 | .tool-versions 18 | asdf-dart.uUid 19 | -------------------------------------------------------------------------------- /.pubignore: -------------------------------------------------------------------------------- 1 | test 2 | tool 3 | Makefile 4 | dart_test.yaml -------------------------------------------------------------------------------- /COPYRIGHT_TRANSFER: -------------------------------------------------------------------------------- 1 | I, Daniel Davidson, hereby assign the copyright of JSON Schema to Workiva Inc., to be carried forward under an open source license. 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | 3 | .PHONY: pubget 4 | pubget: 5 | dart pub get 6 | 7 | .PHONY: pubupgrade 8 | pubupgrade: 9 | dart pub upgrade 10 | 11 | .PHONY: dependency_validator 12 | dependency_validator: 13 | dart run dependency_validator 14 | 15 | .PHONY: format 16 | format: 17 | dart format -l 120 . 18 | 19 | .PHONY: analyze 20 | analyze: 21 | dart analyze 22 | 23 | .PHONY: gen-fixtures 24 | gen-fixtures: 25 | dart run ./tool/gen.dart 26 | 27 | .PHONY: serve-remotes 28 | serve-remotes: stop-serve-remotes 29 | dart run ./tool/serve_remotes.dart 30 | 31 | .PHONY: stop-serve-remotes 32 | stop-serve-remotes: 33 | @if [ ! -z `lsof -t -i tcp:1234 -i tcp:4321` ]; then\ 34 | kill -9 `lsof -t -i tcp:1234 -i tcp:4321`;\ 35 | fi 36 | 37 | .PHONY: test 38 | test: 39 | dart test 40 | 41 | # test-with-serve-remotes recipe does the following: 42 | # 0) kills any previously running HTTP fixture server 43 | # 1) starts a dart process to server specification test remotes 44 | # 2) stores the pid of the serve_remotes.dart process 45 | # 3) waits 3 seconds to give the server time to start 46 | # 4) runs the tests 47 | # 5) stores the exit code of the tests 48 | # 6) stops the server 49 | # 7) exits the process with the return code from the tests 50 | .PHONY: test-with-serve-remotes 51 | test-with-serve-remotes: stop-serve-remotes 52 | { dart run ./tool/serve_remotes.dart & }; \ 53 | pid=$$!; \ 54 | sleep 1; \ 55 | dart test; \ 56 | r=$$?; \ 57 | kill $$pid; \ 58 | exit $$r -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:workiva_analysis_options/v1.yaml -------------------------------------------------------------------------------- /dart_test.yaml: -------------------------------------------------------------------------------- 1 | platforms: 2 | - vm 3 | - chrome 4 | paths: 5 | - test/unit 6 | 7 | timeout: 10s 8 | reporter: expanded -------------------------------------------------------------------------------- /example/custom_vocabulary/date-range-meta-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "date-range-meta-schema.json", 3 | "$id": "date-range-meta-schema.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/core": true, 6 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 7 | "https://json-schema.org/draft/2020-12/vocab/unevaluated": true, 8 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 9 | "https://json-schema.org/draft/2020-12/vocab/meta-data": true, 10 | "https://json-schema.org/draft/2020-12/vocab/format-annotation": true, 11 | "https://json-schema.org/draft/2020-12/vocab/content": true, 12 | "http://localhost/vocab/date-range": true 13 | }, 14 | "allOf": [ 15 | { 16 | "$ref": "https://json-schema.org/draft/2020-12/schema" 17 | } 18 | ], 19 | "properties": { 20 | "minDate": { 21 | "type": "string", 22 | "format": "date" 23 | }, 24 | "maxDate": { 25 | "type": "string", 26 | "format": "date" 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /example/custom_vocabulary/example-date-range-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "date-range-meta-schema.json", 3 | "id": "example-date-range-schema", 4 | "properties": { 5 | "epochDate": { 6 | "minDate": "1970-01-01", 7 | "maxDate": "2038-01-19" 8 | } 9 | }, 10 | "required": ["epochDate"] 11 | } 12 | -------------------------------------------------------------------------------- /example/from_url/grades_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title" : "Grade Tracker", 4 | "type" : "object", 5 | "additionalProperties" : false, 6 | "properties" : { 7 | "semesters" : { 8 | "type" : "array", 9 | "items" : { 10 | "type" : "object", 11 | "additionalProperties" : false, 12 | "properties" : { 13 | "semester": { "type" : "integer" }, 14 | "grades" : { 15 | "type" : "array", 16 | "items" : { 17 | "type" : "object", 18 | "additionalProperties" : false, 19 | "required" : [ "date", "type", "grade", "std" ], 20 | "properties" : { 21 | "date" : { "type" : "string"}, 22 | "type" : { "enum" : [ "homework", "quiz", "test", "final_exam" ] }, 23 | "grade" : { "type" : "number"}, 24 | "std" : { 25 | "oneOf" : [ 26 | {"type" : "number"}, 27 | {"type" : "null"} 28 | ] 29 | }, 30 | "avg" : { 31 | "oneOf" : [ 32 | {"type" : "number"}, 33 | {"type" : "null"} 34 | ] 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /example/from_url/grades_schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Workiva/json_schema/2e5dbafe9a5df1950283a9b6d5f375f6811dd7d1/example/from_url/grades_schema.png -------------------------------------------------------------------------------- /example/readme/asynchronous_creation/geo.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "https://example.com/geographical-location.schema.json", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "title": "Longitude and Latitude Values", 5 | "description": "A geographical coordinate.", 6 | "required": [ "latitude", "longitude" ], 7 | "type": "object", 8 | "properties": { 9 | "latitude": { 10 | "type": "number", 11 | "minimum": -90, 12 | "maximum": 90 13 | }, 14 | "longitude": { 15 | "type": "number", 16 | "minimum": -180, 17 | "maximum": 180 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /lib/fix_data.yaml: -------------------------------------------------------------------------------- 1 | version: 1 2 | transforms: 3 | - title: Rename to validate 4 | date: 2024-10-15 5 | element: 6 | uris: 7 | - json_schema.dart 8 | method: validateWithResults 9 | inClass: Validator 10 | changes: 11 | - kind: rename 12 | newName: validate 13 | - title: Rename to validate 14 | date: 2024-10-15 15 | element: 16 | uris: 17 | - json_schema.dart 18 | method: validateWithResults 19 | inClass: JsonSchema 20 | changes: 21 | - kind: rename 22 | newName: validate 23 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/date_time_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 2 | 3 | ValidationContext defaultDateTimeValidator(ValidationContext context, String instanceData) { 4 | try { 5 | DateTime.parse(instanceData); 6 | } catch (e) { 7 | context.addError('"date-time" format not accepted $instanceData'); 8 | } 9 | return context; 10 | } 11 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/date_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultDateValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft7) return context; 7 | if (JsonSchemaValidationRegexes.fullDate.firstMatch(instanceData) == null) { 8 | context.addError('"date" format not accepted $instanceData'); 9 | } 10 | return context; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/duration_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultDurationValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft2019_09) return context; 7 | if (JsonSchemaValidationRegexes.duration.firstMatch(instanceData) == null) { 8 | context.addError('"duration" format not accepted $instanceData'); 9 | } 10 | return context; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/email_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/global_platform_functions.dart'; 2 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 3 | 4 | ValidationContext defaultEmailValidator(ValidationContext context, String instanceData) { 5 | final isValid = defaultValidators.emailValidator; 6 | 7 | if (!isValid(instanceData)) { 8 | context.addError('"email" format not accepted $instanceData'); 9 | } 10 | return context; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/hostname_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultHostnameValidator(ValidationContext context, String instanceData) { 6 | final regexp = context.schemaVersion < SchemaVersion.draft2019_09 7 | ? JsonSchemaValidationRegexes.hostname 8 | // Updated in Draft 2019-09 9 | : JsonSchemaValidationRegexes.hostnameDraft2019; 10 | 11 | if (regexp.firstMatch(instanceData) == null) { 12 | context.addError('"hostname" format not accepted $instanceData'); 13 | } 14 | return context; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/idn_email_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 2 | 3 | ValidationContext defaultIdnEmailValidator(ValidationContext context, String instanceData) { 4 | // No maintained dart packages exist to validate RFC6531, 5 | // and it's too complex for a regex, so best effort is to pass for now. 6 | return context; 7 | } 8 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/idn_hostname_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultIdnHostnameValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft7) return context; 7 | 8 | final regexp = context.schemaVersion < SchemaVersion.draft2019_09 9 | ? JsonSchemaValidationRegexes.idnHostname 10 | // Updated in Draft 2019-09 11 | : JsonSchemaValidationRegexes.idnHostnameDraft2019; 12 | 13 | if (regexp.firstMatch(instanceData) == null) { 14 | context.addError('"idn-hostname" format not accepted $instanceData'); 15 | } 16 | return context; 17 | } 18 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/ipv4_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 3 | 4 | ValidationContext defaultIpv4Validator(ValidationContext context, String instanceData) { 5 | if (JsonSchemaValidationRegexes.ipv4.firstMatch(instanceData) == null) { 6 | context.addError('"ipv4" format not accepted $instanceData'); 7 | } 8 | return context; 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/ipv6_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 2 | 3 | ValidationContext defaultIpv6Validator(ValidationContext context, String instanceData) { 4 | try { 5 | Uri.parseIPv6Address(instanceData); 6 | } on FormatException catch (_) { 7 | context.addError('"ipv6" format not accepted $instanceData'); 8 | } 9 | return context; 10 | } 11 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/iri_reference_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/global_platform_functions.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultIriReferenceValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft7) return context; 7 | 8 | // Dart's URI class supports parsing IRIs, so we can use the same validator 9 | final isValid = defaultValidators.uriReferenceValidator; 10 | 11 | if (!isValid(instanceData)) { 12 | context.addError('"iri-reference" format not accepted $instanceData'); 13 | } 14 | return context; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/iri_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/global_platform_functions.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultIriValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft7) return context; 7 | // Dart's URI class supports parsing IRIs, so we can use the same validator 8 | final isValid = defaultValidators.uriValidator; 9 | 10 | if (!isValid(instanceData)) { 11 | context.addError('"iri" format not accepted $instanceData'); 12 | } 13 | return context; 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/json_pointer_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 2 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 3 | import 'package:rfc_6901/rfc_6901.dart'; 4 | 5 | ValidationContext defaultJsonPointerValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft6) return context; 7 | try { 8 | JsonPointer(instanceData); 9 | } on FormatException catch (_) { 10 | context.addError('"json-pointer" format not accepted $instanceData'); 11 | } 12 | return context; 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/regex_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 2 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 3 | 4 | ValidationContext defaultRegexValidator(ValidationContext context, String instanceData) { 5 | if (context.schemaVersion < SchemaVersion.draft7) return context; 6 | try { 7 | RegExp(instanceData, unicode: true); 8 | } catch (e) { 9 | context.addError('"regex" format not accepted $instanceData'); 10 | } 11 | return context; 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/relative_json_pointer_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultRelativeJsonPointerValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft7) return context; 7 | if (JsonSchemaValidationRegexes.relativeJsonPointer.firstMatch(instanceData) == null) { 8 | context.addError('"relative-json-pointer" format not accepted $instanceData'); 9 | } 10 | return context; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/time_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultTimeValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft7) return context; 7 | if (JsonSchemaValidationRegexes.fullTime.firstMatch(instanceData) == null) { 8 | context.addError('"time" format not accepted $instanceData'); 9 | } 10 | return context; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/uri_reference_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/global_platform_functions.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultUriReferenceValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft6) return context; 7 | final isValid = defaultValidators.uriReferenceValidator; 8 | 9 | if (!isValid(instanceData)) { 10 | context.addError('"uri-reference" format not accepted $instanceData'); 11 | } 12 | return context; 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/uri_template_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/global_platform_functions.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultUriTemplateValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft6) return context; 7 | final isValid = defaultValidators.uriTemplateValidator; 8 | 9 | if (!isValid(instanceData)) { 10 | context.addError('"uri-template" format not accepted $instanceData'); 11 | } 12 | return context; 13 | } 14 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/uri_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/global_platform_functions.dart'; 2 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 3 | 4 | ValidationContext defaultUriValidator(ValidationContext context, String instanceData) { 5 | final isValid = defaultValidators.uriValidator; 6 | if (!isValid(instanceData)) { 7 | context.addError('"uri" format not accepted $instanceData'); 8 | } 9 | return context; 10 | } 11 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/uuid_validator.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/validation_regexes.dart'; 2 | import 'package:json_schema/src/json_schema/models/schema_version.dart'; 3 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 4 | 5 | ValidationContext defaultUuidValidator(ValidationContext context, String instanceData) { 6 | if (context.schemaVersion < SchemaVersion.draft2019_09) return context; 7 | if (JsonSchemaValidationRegexes.uuid.firstMatch(instanceData) == null) { 8 | context.addError('"uuid" format not accepted $instanceData'); 9 | } 10 | return context; 11 | } 12 | -------------------------------------------------------------------------------- /lib/src/json_schema/formats/validators.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/formats/date_time_validator.dart'; 2 | import 'package:json_schema/src/json_schema/models/validation_context.dart'; 3 | 4 | import 'date_validator.dart'; 5 | import 'duration_validator.dart'; 6 | import 'email_validator.dart'; 7 | import 'hostname_validator.dart'; 8 | import 'idn_email_validator.dart'; 9 | import 'idn_hostname_validator.dart'; 10 | import 'ipv4_validator.dart'; 11 | import 'ipv6_validator.dart'; 12 | import 'iri_validator.dart'; 13 | import 'iri_reference_validator.dart'; 14 | import 'json_pointer_validator.dart'; 15 | import 'regex_validator.dart'; 16 | import 'relative_json_pointer_validator.dart'; 17 | import 'time_validator.dart'; 18 | import 'uri_reference_validator.dart'; 19 | import 'uri_template_validator.dart'; 20 | import 'uri_validator.dart'; 21 | import 'uuid_validator.dart'; 22 | 23 | Map defaultFormatValidators = { 24 | 'date': defaultDateValidator, 25 | 'date-time': defaultDateTimeValidator, 26 | 'duration': defaultDurationValidator, 27 | 'email': defaultEmailValidator, 28 | 'hostname': defaultHostnameValidator, 29 | 'idn-email': defaultIdnEmailValidator, 30 | 'idn-hostname': defaultIdnHostnameValidator, 31 | 'ipv4': defaultIpv4Validator, 32 | 'ipv6': defaultIpv6Validator, 33 | 'iri': defaultIriValidator, 34 | 'iri-reference': defaultIriReferenceValidator, 35 | 'json-pointer': defaultJsonPointerValidator, 36 | 'regex': defaultRegexValidator, 37 | 'relative-json-pointer': defaultRelativeJsonPointerValidator, 38 | 'time': defaultTimeValidator, 39 | 'uri': defaultUriValidator, 40 | 'uri-reference': defaultUriReferenceValidator, 41 | 'uri-template': defaultUriTemplateValidator, 42 | 'uuid': defaultUuidValidator, 43 | }; 44 | -------------------------------------------------------------------------------- /lib/src/json_schema/schema_url_client/schema_url_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/json_schema.dart'; 2 | 3 | abstract class SchemaUrlClient { 4 | Future createFromUrl( 5 | String schemaUrl, { 6 | SchemaVersion? schemaVersion, 7 | List? customVocabularies, 8 | Map customFormats = const {}, 9 | }); 10 | 11 | Future?> getSchemaJsonFromUrl(String schemaUrl); 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/json_schema/schema_url_client/stub_schema_url_client.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/src/json_schema/schema_url_client/schema_url_client.dart'; 2 | 3 | /// Implemented in `html_schema_url_client.dart` and `io_schema_url_client.dart`. 4 | SchemaUrlClient createClient() => throw UnsupportedError('Cannot create a client without dart:html or dart:io.'); 5 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: json_schema 2 | version: 5.2.1 3 | description: JSON Schema implementation in Dart 4 | homepage: https://github.com/workiva/json_schema 5 | 6 | environment: 7 | sdk: '>=2.12.0 <4.0.0' 8 | 9 | dependencies: 10 | collection: ^1.15.0 11 | http: ">=0.13.4 <2.0.0" 12 | logging: ^1.0.0 13 | rfc_6901: '>=0.1.0 <0.3.0' 14 | uri: '>=0.11.1 <2.0.0' 15 | 16 | dev_dependencies: 17 | dependency_validator: ^3.1.2 18 | path: ^1.8.0 19 | shelf: ^1.0.0 20 | shelf_static: ^1.0.0 21 | test: ^1.17.0 22 | workiva_analysis_options: ^1.2.2 23 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/.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 10 | - cron: '42 6 * * *' 11 | 12 | jobs: 13 | ci: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Set up Python 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: 3.7 22 | - name: Install tox 23 | run: python -m pip install tox 24 | - name: Run the sanity checks 25 | run: python -m tox 26 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/.gitignore: -------------------------------------------------------------------------------- 1 | TODO 2 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Ajv = require('ajv'); 4 | const jsonSchemaTest = require('json-schema-test'); 5 | 6 | const refs = { 7 | 'http://localhost:1234/integer.json': require('./remotes/integer.json'), 8 | 'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'), 9 | 'http://localhost:1234/baseUriChange/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'), 10 | 'http://localhost:1234/baseUriChangeFolder/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'), 11 | 'http://localhost:1234/baseUriChangeFolderInSubschema/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'), 12 | 'http://localhost:1234/name.json': require('./remotes/name.json'), 13 | 'http://localhost:1234/name-defs.json': require('./remotes/name-defs.json') 14 | }; 15 | 16 | const SKIP = { 17 | 4: ['optional/zeroTerminatedFloats'], 18 | 7: [ 19 | 'format/idn-email', 20 | 'format/idn-hostname', 21 | 'format/iri', 22 | 'format/iri-reference', 23 | 'optional/content' 24 | ] 25 | }; 26 | 27 | [4, 6, 7].forEach((draft) => { 28 | let ajv; 29 | if (draft == 7) { 30 | ajv = new Ajv({format: 'full'}); 31 | } else { 32 | const schemaId = draft == 4 ? 'id' : '$id'; 33 | ajv = new Ajv({format: 'full', meta: false, schemaId}); 34 | ajv.addMetaSchema(require(`ajv/lib/refs/json-schema-draft-0${draft}.json`)); 35 | ajv._opts.defaultMeta = `http://json-schema.org/draft-0${draft}/schema#`; 36 | } 37 | for (const uri in refs) ajv.addSchema(refs[uri], uri); 38 | 39 | jsonSchemaTest(ajv, { 40 | description: `Test suite draft-0${draft}`, 41 | suites: {tests: `./tests/draft${draft}/{**/,}*.json`}, 42 | skip: SKIP[draft], 43 | cwd: __dirname, 44 | hideFolder: 'tests/' 45 | }); 46 | }); 47 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha index.js -R spec" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git" 12 | }, 13 | "keywords": [ 14 | "json-schema", 15 | "tests" 16 | ], 17 | "author": "http://json-schema.org", 18 | "license": "MIT", 19 | "bugs": { 20 | "url": "https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues" 21 | }, 22 | "homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme", 23 | "devDependencies": { 24 | "ajv": "^6.0.0-rc.1", 25 | "json-schema-test": "^2.0.0", 26 | "mocha": "^3.2.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/draft-next/format-assertion-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/format-assertion-false.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/core": true, 6 | "https://json-schema.org/draft/next/vocab/format-assertion": false 7 | }, 8 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/next/schema/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/next/schema/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/draft-next/format-assertion-true.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/format-assertion-true.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/core": true, 6 | "https://json-schema.org/draft/next/vocab/format-assertion": true 7 | }, 8 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/next/schema/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/next/schema/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/draft-next/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/metaschema-no-validation.json", 3 | "$vocabulary": { 4 | "https://json-schema.org/draft/next/vocab/applicator": true, 5 | "https://json-schema.org/draft/next/vocab/core": true 6 | }, 7 | "allOf": [ 8 | { "$ref": "https://json-schema.org/draft/next/meta/applicator" }, 9 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/draft2019-09/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/metaschema-no-validation.json", 3 | "$vocabulary": { 4 | "https://json-schema.org/draft/2019-09/vocab/applicator": true, 5 | "https://json-schema.org/draft/2019-09/vocab/core": true 6 | }, 7 | "allOf": [ 8 | { "$ref": "https://json-schema.org/draft/2019-09/meta/applicator" }, 9 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/2020-12/schema/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/draft2020-12/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", 3 | "$vocabulary": { 4 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 5 | "https://json-schema.org/draft/2020-12/vocab/core": true 6 | }, 7 | "allOf": [ 8 | { "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" }, 9 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/ref-and-definitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/ref-and-definitions.json", 3 | "definitions": { 4 | "inner": { 5 | "properties": { 6 | "bar": { "type": "string" } 7 | } 8 | } 9 | }, 10 | "allOf": [ { "$ref": "#/definitions/inner" } ] 11 | } 12 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/subSchemas-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/$defs/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "integer": { 3 | "type": "integer" 4 | }, 5 | "refToInteger": { 6 | "$ref": "#/integer" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/remotes/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$id": "http://localhost:1234/tree.json", 4 | "$dynamicAnchor": "node", 5 | 6 | "type": "object", 7 | "properties": { 8 | "data": true, 9 | "children": { 10 | "type": "array", 11 | "items": { 12 | "$dynamicRef": "#node" 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$ref": "https://json-schema.org/draft/next/schema" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "valid definition schema", 10 | "data": {"$defs": {"foo": {"type": "integer"}}}, 11 | "valid": true 12 | }, 13 | { 14 | "description": "invalid definition schema", 15 | "data": {"$defs": {"foo": {"type": 1}}}, 16 | "valid": false 17 | } 18 | ] 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/infinite-loop-detection.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", 4 | "schema": { 5 | "$defs": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/$defs/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/$defs/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/optional/format-assertion.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "schema that uses custom metaschema with format-assertion: false", 4 | "schema": { 5 | "$id": "https://schema/using/format-assertion/false", 6 | "$schema": "http://localhost:1234/draft-next/format-assertion-false.json", 7 | "format": "ipv4" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "format-assertion: false: valid string", 12 | "data": "127.0.0.1", 13 | "valid": true 14 | }, 15 | { 16 | "description": "format-assertion: false: invalid string", 17 | "data": "not-an-ipv4", 18 | "valid": false 19 | } 20 | ] 21 | }, 22 | { 23 | "description": "schema that uses custom metaschema with format-assertion: true", 24 | "schema": { 25 | "$id": "https://schema/using/format-assertion/true", 26 | "$schema": "http://localhost:1234/draft-next/format-assertion-true.json", 27 | "format": "ipv4" 28 | }, 29 | "tests": [ 30 | { 31 | "description": "format-assertion: true: valid string", 32 | "data": "127.0.0.1", 33 | "valid": true 34 | }, 35 | { 36 | "description": "format-assertion: true: invalid string", 37 | "data": "not-an-ipv4", 38 | "valid": false 39 | } 40 | ] 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/optional/refOfUnknownKeyword.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "reference of a root arbitrary keyword ", 4 | "schema": { 5 | "unknown-keyword": {"type": "integer"}, 6 | "properties": { 7 | "bar": {"$ref": "#/unknown-keyword"} 8 | } 9 | }, 10 | "tests": [ 11 | { 12 | "description": "match", 13 | "data": {"bar": 3}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "mismatch", 18 | "data": {"bar": true}, 19 | "valid": false 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "reference of an arbitrary keyword of a sub-schema", 25 | "schema": { 26 | "properties": { 27 | "foo": {"unknown-keyword": {"type": "integer"}}, 28 | "bar": {"$ref": "#/properties/foo/unknown-keyword"} 29 | } 30 | }, 31 | "tests": [ 32 | { 33 | "description": "match", 34 | "data": {"bar": 3}, 35 | "valid": true 36 | }, 37 | { 38 | "description": "mismatch", 39 | "data": {"bar": true}, 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft-next/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/draft-next/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": {"$ref": "https://json-schema.org/draft/2019-09/schema"}, 5 | "tests": [ 6 | { 7 | "description": "valid definition schema", 8 | "data": {"$defs": {"foo": {"type": "integer"}}}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "invalid definition schema", 13 | "data": {"$defs": {"foo": {"type": 1}}}, 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | "$defs": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/$defs/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/$defs/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/optional/refOfUnknownKeyword.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "reference of a root arbitrary keyword ", 4 | "schema": { 5 | "unknown-keyword": {"type": "integer"}, 6 | "properties": { 7 | "bar": {"$ref": "#/unknown-keyword"} 8 | } 9 | }, 10 | "tests": [ 11 | { 12 | "description": "match", 13 | "data": {"bar": 3}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "mismatch", 18 | "data": {"bar": true}, 19 | "valid": false 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "reference of an arbitrary keyword of a sub-schema", 25 | "schema": { 26 | "properties": { 27 | "foo": {"unknown-keyword": {"type": "integer"}}, 28 | "bar": {"$ref": "#/properties/foo/unknown-keyword"} 29 | } 30 | }, 31 | "tests": [ 32 | { 33 | "description": "match", 34 | "data": {"bar": 3}, 35 | "valid": true 36 | }, 37 | { 38 | "description": "mismatch", 39 | "data": {"bar": true}, 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2019-09/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$ref": "https://json-schema.org/draft/2020-12/schema" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "valid definition schema", 10 | "data": {"$defs": {"foo": {"type": "integer"}}}, 11 | "valid": true 12 | }, 13 | { 14 | "description": "invalid definition schema", 15 | "data": {"$defs": {"foo": {"type": 1}}}, 16 | "valid": false 17 | } 18 | ] 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | "$defs": { 6 | "int": { "type": "integer" } 7 | }, 8 | "allOf": [ 9 | { 10 | "properties": { 11 | "foo": { 12 | "$ref": "#/$defs/int" 13 | } 14 | } 15 | }, 16 | { 17 | "additionalProperties": { 18 | "$ref": "#/$defs/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/optional/refOfUnknownKeyword.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "reference of a root arbitrary keyword ", 4 | "schema": { 5 | "unknown-keyword": {"type": "integer"}, 6 | "properties": { 7 | "bar": {"$ref": "#/unknown-keyword"} 8 | } 9 | }, 10 | "tests": [ 11 | { 12 | "description": "match", 13 | "data": {"bar": 3}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "mismatch", 18 | "data": {"bar": true}, 19 | "valid": false 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "reference of an arbitrary keyword of a sub-schema", 25 | "schema": { 26 | "properties": { 27 | "foo": {"unknown-keyword": {"type": "integer"}}, 28 | "bar": {"$ref": "#/properties/foo/unknown-keyword"} 29 | } 30 | }, 31 | "tests": [ 32 | { 33 | "description": "match", 34 | "data": {"bar": 3}, 35 | "valid": true 36 | }, 37 | { 38 | "description": "mismatch", 39 | "data": {"bar": true}, 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft2020-12/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft3/items.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "a schema given for items", 4 | "schema": { 5 | "items": {"type": "integer"} 6 | }, 7 | "tests": [ 8 | { 9 | "description": "valid items", 10 | "data": [ 1, 2, 3 ], 11 | "valid": true 12 | }, 13 | { 14 | "description": "wrong type of items", 15 | "data": [1, "x"], 16 | "valid": false 17 | }, 18 | { 19 | "description": "ignores non-arrays", 20 | "data": {"foo" : "bar"}, 21 | "valid": true 22 | } 23 | ] 24 | }, 25 | { 26 | "description": "an array of schemas for items", 27 | "schema": { 28 | "items": [ 29 | {"type": "integer"}, 30 | {"type": "string"} 31 | ] 32 | }, 33 | "tests": [ 34 | { 35 | "description": "correct types", 36 | "data": [ 1, "foo" ], 37 | "valid": true 38 | }, 39 | { 40 | "description": "wrong types", 41 | "data": [ "foo", 1 ], 42 | "valid": false 43 | } 44 | ] 45 | } 46 | ] 47 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft3/optional/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft3/optional/format/date-time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of date-time strings", 4 | "schema": { "format": "date-time" }, 5 | "tests": [ 6 | { 7 | "description": "a valid date-time string", 8 | "data": "1963-06-19T08:30:06.283185Z", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid date-time string", 13 | "data": "06/19/1963 08:30:06 PST", 14 | "valid": false 15 | }, 16 | { 17 | "description": "case-insensitive T and Z", 18 | "data": "1963-06-19t08:30:06.283185z", 19 | "valid": true 20 | }, 21 | { 22 | "description": "only RFC3339 not all of ISO 8601 are valid", 23 | "data": "2013-350T01:01:01", 24 | "valid": false 25 | }, 26 | { 27 | "description": "invalid non-padded month dates", 28 | "data": "1963-6-19T08:30:06.283185Z", 29 | "valid": false 30 | }, 31 | { 32 | "description": "invalid non-padded day dates", 33 | "data": "1963-06-1T08:30:06.283185Z", 34 | "valid": false 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft3/optional/format/email.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of e-mail addresses", 4 | "schema": { "format": "email" }, 5 | "tests": [ 6 | { 7 | "description": "a valid e-mail address", 8 | "data": "joe.bloggs@example.com", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid e-mail address", 13 | "data": "2962", 14 | "valid": false 15 | }, 16 | { 17 | "description": "tilde in local part is valid", 18 | "data": "te~st@example.com", 19 | "valid": true 20 | }, 21 | { 22 | "description": "tilde before local part is valid", 23 | "data": "~test@example.com", 24 | "valid": true 25 | }, 26 | { 27 | "description": "tilde after local part is valid", 28 | "data": "test~@example.com", 29 | "valid": true 30 | }, 31 | { 32 | "description": "dot before local part is not valid", 33 | "data": ".test@example.com", 34 | "valid": false 35 | }, 36 | { 37 | "description": "dot after local part is not valid", 38 | "data": "test.@example.com", 39 | "valid": false 40 | }, 41 | { 42 | "description": "two separated dots inside local part are valid", 43 | "data": "te.s.t@example.com", 44 | "valid": true 45 | }, 46 | { 47 | "description": "two subsequent dots inside local part are not valid", 48 | "data": "te..st@example.com", 49 | "valid": false 50 | } 51 | ] 52 | } 53 | ] 54 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft3/optional/format/time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of time strings", 4 | "schema": { "format": "time" }, 5 | "tests": [ 6 | { 7 | "description": "a valid time string", 8 | "data": "08:30:06", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid time string", 13 | "data": "8:30 AM", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft4/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft6/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/draft7/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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 | -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/tests/latest: -------------------------------------------------------------------------------- 1 | draft2020-12 -------------------------------------------------------------------------------- /test/JSON-Schema-Test-Suite/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==3.2.0 9 | commands = {envpython} bin/jsonschema_suite check 10 | -------------------------------------------------------------------------------- /test/additional_remotes/bar.json: -------------------------------------------------------------------------------- 1 | { 2 | "baz": { "$ref": "http://localhost:4321/string.json#" } 3 | } -------------------------------------------------------------------------------- /test/additional_remotes/date-keyword-meta-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://localhost:4321/date-keyword-meta-schema.json", 3 | "$id": "http://localhost:4321/date-keyword-meta-schema.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/core": true, 6 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 7 | "https://json-schema.org/draft/2020-12/vocab/unevaluated": true, 8 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 9 | "https://json-schema.org/draft/2020-12/vocab/meta-data": true, 10 | "https://json-schema.org/draft/2020-12/vocab/format-annotation": true, 11 | "https://json-schema.org/draft/2020-12/vocab/content": true, 12 | "http://localhost:4321/vocab/min-date": true 13 | }, 14 | "allOf": [ 15 | {"$ref": "https://json-schema.org/draft/2020-12/schema" } 16 | ], 17 | "properties":{ 18 | "minDate": { 19 | "type": "string", 20 | "format": "date" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test/additional_remotes/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } -------------------------------------------------------------------------------- /test/additional_remotes/string_ref.json: -------------------------------------------------------------------------------- 1 | { "$ref": "http://localhost:4321/string.json" } -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/additionalProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "additionalProperties: must be a boolean or object - not string", 4 | "schema" : { "additionalProperties" : "foo" } 5 | }, 6 | { 7 | "description" : "additionalProperties: must be a boolean or object - not int", 8 | "schema" : { "additionalProperties" : 3 } 9 | }, 10 | { 11 | "description" : "additionalProperties: must be a boolean or object - not number", 12 | "schema" : { "additionalProperties" : 3.14 } 13 | }, 14 | { 15 | "description" : "additionalProperties: must be a boolean or object - not array", 16 | "schema" : { "additionalProperties" : [] } 17 | }, 18 | { 19 | "description" : "additionalProperties: if object must be valid json schema", 20 | "schema" : { 21 | "additionalProperties" : [] 22 | } 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/allOf.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "allOf: must be an array - not string", 4 | "schema" : { "allOf" : "foo" } 5 | }, 6 | { 7 | "description" : "allOf: must be an array - not int", 8 | "schema" : { "allOf" : 42 } 9 | }, 10 | { 11 | "description" : "allOf: must be an array - not num", 12 | "schema" : { "allOf" : 3.14 } 13 | }, 14 | { 15 | "description" : "allOf: must be an array - not object", 16 | "schema" : { "allOf" : {} } 17 | }, 18 | { 19 | "description" : "allOf: must be a non-empty array", 20 | "schema" : { "allOf" : [] } 21 | }, 22 | { 23 | "description" : "allOf: elements must be valid schemas", 24 | "schema" : { 25 | "allOf" : [ 26 | { 27 | "minimum" : "foo" 28 | } 29 | ] 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/anyOf.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "anyOf: must be an array - not string", 4 | "schema" : { "anyOf" : "foo" } 5 | }, 6 | { 7 | "description" : "anyOf: must be an array - not int", 8 | "schema" : { "anyOf" : 42 } 9 | }, 10 | { 11 | "description" : "anyOf: must be an array - not num", 12 | "schema" : { "anyOf" : 3.14 } 13 | }, 14 | { 15 | "description" : "anyOf: must be an array - not object", 16 | "schema" : { "anyOf" : {} } 17 | }, 18 | { 19 | "description" : "anyOf: must be a non-empty array", 20 | "schema" : { "anyOf" : [] } 21 | }, 22 | { 23 | "description" : "anyOf: elements must be valid schemas", 24 | "schema" : { 25 | "anyOf" : [ 26 | { 27 | "minimum" : "foo" 28 | } 29 | ] 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/cycle.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "schema can not have cycles", 4 | "schema" : { 5 | "definitions" : { 6 | "a" : { "$ref" : "#/definitions/b" }, 7 | "b" : { "$ref" : "#/definitions/a" } 8 | } 9 | } 10 | } 11 | ] 12 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "definitions: must be an object - not string", 4 | "schema" : { "definitions" : "foo" } 5 | }, 6 | { 7 | "description" : "definitions: must be an object - not int", 8 | "schema" : { "definitions" : 3 } 9 | }, 10 | { 11 | "description" : "definitions: must be an object - not num", 12 | "schema" : { "definitions" : 3.14 } 13 | }, 14 | { 15 | "description" : "definitions: must be an object - not array", 16 | "schema" : { "definitions" : [] } 17 | }, 18 | { 19 | "description" : "definitions: must be an object and each value must be valid schema", 20 | "schema" : { 21 | "definitions" : { 22 | "definition_1" : { 23 | "minimum" : "goo" 24 | } 25 | } 26 | } 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/dependencies.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "dependencies: must be an object - not string", 4 | "schema" : { "dependencies" : "foo" } 5 | }, 6 | { 7 | "description" : "dependencies: must be an object - not int", 8 | "schema" : { "dependencies" : 3 } 9 | }, 10 | { 11 | "description" : "dependencies: must be an object - not num", 12 | "schema" : { "dependencies" : 3.14 } 13 | }, 14 | { 15 | "description" : "dependencies: must be an object - not array", 16 | "schema" : { "dependencies" : [] } 17 | }, 18 | { 19 | "description" : "dependencies: property dependencies non-empty array", 20 | "schema" : { 21 | "dependencies" : { 22 | "p1" : [] 23 | } 24 | } 25 | }, 26 | { 27 | "description" : "dependencies: values must be object (schema) or array", 28 | "schema" : { 29 | "dependencies" : { 30 | "p1" : "goo" 31 | } 32 | } 33 | }, 34 | { 35 | "description" : "dependencies: property dependencies must be strings", 36 | "schema" : { 37 | "dependencies" : { 38 | "p1" : [ 1 ] 39 | } 40 | } 41 | }, 42 | { 43 | "description" : "dependencies: property dependencies must be strings with no dupes", 44 | "schema" : { 45 | "dependencies" : { 46 | "p1" : [ "a", "b", "a" ] 47 | } 48 | } 49 | }, 50 | { 51 | "description" : "dependencies: schema dependencies must be valid schema", 52 | "schema" : { 53 | "dependencies" : { 54 | "p1" : { "minimum" : "oops" } 55 | } 56 | } 57 | } 58 | ] 59 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/description.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "description: must be a string - not object", 4 | "schema" : { "description" : {} } 5 | }, 6 | { 7 | "description" : "description: must be a string - not array", 8 | "schema" : { "description" : [] } 9 | }, 10 | { 11 | "description" : "description: must be a string - not int", 12 | "schema" : { "description" : 3 } 13 | }, 14 | { 15 | "description" : "description: must be a string - not number", 16 | "schema" : { "description" : 3.14 } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/enum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "enum: must be an array - not string", 4 | "schema" : { "enum" : "foo" } 5 | }, 6 | { 7 | "description" : "enum: must be an array - not int", 8 | "schema" : { "enum" : 42 } 9 | }, 10 | { 11 | "description" : "enum: must be an array - not num", 12 | "schema" : { "enum" : 3.14 } 13 | }, 14 | { 15 | "description" : "enum: must be an array - not object", 16 | "schema" : { "enum" : {} } 17 | }, 18 | { 19 | "description" : "enum: must be a non-empty array", 20 | "schema" : { "enum" : [] } 21 | }, 22 | { 23 | "description" : "enum: elements must be unique", 24 | "schema" : { "enum" : [3,4,3] } 25 | }, 26 | { 27 | "description" : "enum: elements must be deeply unique", 28 | "schema" : { "enum" : [ 29 | {"c":"d", "a":"b"}, 30 | 4, 31 | {"a":"b", "c":"d"} 32 | ] } 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "exclusiveMaximum: must be a boolean", 4 | "schema" : { "maximum" : 3, "exclusiveMaximum" : "foo" } 5 | }, 6 | { 7 | "description" : "exclusiveMaximum: requires maximum if true", 8 | "schema" : { "exclusiveMaximum" : true } 9 | }, 10 | { 11 | "description" : "exclusiveMaximum: requires maximum if false", 12 | "schema" : { "exclusiveMaximum" : false } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "exclusiveMinimum: must be a boolean", 4 | "schema" : { "minimum" : 3, "exclusiveMinimum" : "foo" } 5 | }, 6 | { 7 | "description" : "exclusiveMinimum: requires minimum if true", 8 | "schema" : { "exclusiveMinimum" : true } 9 | }, 10 | { 11 | "description" : "exclusiveMinimum: requires minimum if false", 12 | "schema" : { "exclusiveMinimum" : false } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/freeFormProperty.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "referenced non-keyword property must be valid schema - not array", 4 | "schema" : { 5 | "foo" : [], 6 | "properties" : { 7 | "goo" : { "$ref" : "#/foo" } 8 | } 9 | } 10 | }, 11 | { 12 | "description" : "referenced non-keyword property must be valid schema - invalid schema", 13 | "schema" : { 14 | "foo" : { 15 | "type" : "foo" 16 | }, 17 | "properties" : { 18 | "goo" : { "$ref" : "#/foo" } 19 | } 20 | } 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/id.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "id must be a string - not int", 4 | "schema" : { "id" : 1 } 5 | }, 6 | { 7 | "description" : "id must be a string - not object", 8 | "schema" : { "id" : {} } 9 | }, 10 | { 11 | "description" : "id must be a string - not array", 12 | "schema" : { "id" : [] } 13 | }, 14 | { 15 | "description" : "id must be a string - not int", 16 | "schema" : { "id" : 3 } 17 | }, 18 | { 19 | "description" : "id must be a string - not num", 20 | "schema" : { "id" : 3.14 } 21 | }, 22 | { 23 | "description" : "id must be a valid URI", 24 | "schema" : { "id" : "127.0.0.1:0xfff" } 25 | }, 26 | { 27 | "description" : "id must be a valid URI", 28 | "schema" : { "id" : "http://localhost:^" } 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/items.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "items: must be an array or object, not a string", 4 | "schema" : { "items" : "foo" } 5 | }, 6 | { 7 | "description" : "items: must be an array or object, not a int", 8 | "schema" : { "items" : 42 } 9 | }, 10 | { 11 | "description" : "items: must be an array or object, not a num", 12 | "schema" : { "items" : 3.14 } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "maxLength: must be an integer - not string", 4 | "schema" : { "maxLength" : "foo" } 5 | }, 6 | { 7 | "description" : "maxLength: must be an integer - not num", 8 | "schema" : { "maxLength" : 1.5 } 9 | }, 10 | { 11 | "description" : "maxLength: must be >= 0", 12 | "schema" : { "maxLength" : -1 } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/maxProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "maxProperties: must be a non-negative int - not string", 4 | "schema" : { "maxProperties" : "foo" } 5 | }, 6 | { 7 | "description" : "maxProperties: must be a non-negative int - not object", 8 | "schema" : { "maxProperties" : {} } 9 | }, 10 | { 11 | "description" : "maxProperties: must be a non-negative int - not array", 12 | "schema" : { "maxProperties" : [] } 13 | }, 14 | { 15 | "description" : "maxProperties: must be a non-negative int - not num", 16 | "schema" : { "maxProperties" : 3.14 } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "maximum: must be a JSON number, not a string", 4 | "schema" : { "maximum" : "foo" } 5 | }, 6 | { 7 | "description" : "maximum: must be a JSON number, not an array", 8 | "schema" : { "maximum" : [] } 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "minItems: must be an integer - not string", 4 | "schema" : { "minItems" : "foo" } 5 | }, 6 | { 7 | "description" : "minItems: must be an integer - not num", 8 | "schema" : { "minItems" : 1.5 } 9 | }, 10 | { 11 | "description" : "minItems: must be >= 0", 12 | "schema" : { "minItems" : -1 } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "minLength: must be an integer - not string", 4 | "schema" : { "minLength" : "foo" } 5 | }, 6 | { 7 | "description" : "minLength: must be an integer - not num", 8 | "schema" : { "minLength" : 1.5 } 9 | }, 10 | { 11 | "description" : "minLength: must be >= 0", 12 | "schema" : { "minLength" : -1 } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "minProperties: must be a non-negative int - not string", 4 | "schema" : { "minProperties" : "foo" } 5 | }, 6 | { 7 | "description" : "minProperties: must be a non-negative int - not object", 8 | "schema" : { "minProperties" : {} } 9 | }, 10 | { 11 | "description" : "minProperties: must be a non-negative int - not array", 12 | "schema" : { "minProperties" : [] } 13 | }, 14 | { 15 | "description" : "minProperties: must be a non-negative int - not num", 16 | "schema" : { "minProperties" : 3.14 } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/minimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "minimum: must be a JSON number, not a string", 4 | "schema" : { "minimum" : "foo" } 5 | }, 6 | { 7 | "description" : "minimum: must be a JSON number, not an array", 8 | "schema" : { "minimum" : [] } 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/multipleOf.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "multipleOf: must be 'num', not a 'string'", 4 | "schema" : { "multipleOf" : "foo" } 5 | }, 6 | { 7 | "description" : "multipleOf: must be 'num', not a 'array'", 8 | "schema" : { "multipleOf" : [] } 9 | }, 10 | { 11 | "description" : "multipleOf: must be 'num' greater than 0", 12 | "schema" : { "multipleOf" : 0 } 13 | }, 14 | { 15 | "description" : "multipleOf: must be 'num' greater than 0.0", 16 | "schema" : { "multipleOf" : 0.0 } 17 | }, 18 | { 19 | "description" : "multipleOf: must be 'num' greater than 0", 20 | "schema" : { "multipleOf" : -1 } 21 | }, 22 | { 23 | "description" : "multipleOf: must be 'num' greater than 0", 24 | "schema" : { "multipleOf" : -1.5 } 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/not.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "not: must be an object - not string", 4 | "schema" : { "not" : "foo" } 5 | }, 6 | { 7 | "description" : "not: must be an object - not int", 8 | "schema" : { "not" : 42 } 9 | }, 10 | { 11 | "description" : "not: must be an object - not num", 12 | "schema" : { "not" : 3.14 } 13 | }, 14 | { 15 | "description" : "not: must be an object - not num", 16 | "schema" : { "not" : [] } 17 | }, 18 | { 19 | "description" : "not: object must valid schema", 20 | "schema" : { 21 | "not" : { 22 | "minimum" : "foo" 23 | } 24 | } 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/oneOf.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "oneOf: must be an array - not string", 4 | "schema" : { "oneOf" : "foo" } 5 | }, 6 | { 7 | "description" : "oneOf: must be an array - not int", 8 | "schema" : { "oneOf" : 42 } 9 | }, 10 | { 11 | "description" : "oneOf: must be an array - not num", 12 | "schema" : { "oneOf" : 3.14 } 13 | }, 14 | { 15 | "description" : "oneOf: must be an array - not object", 16 | "schema" : { "oneOf" : {} } 17 | }, 18 | { 19 | "description" : "oneOf: must be a non-empty array", 20 | "schema" : { "oneOf" : [] } 21 | }, 22 | { 23 | "description" : "oneOf: elements must be valid schemas", 24 | "schema" : { 25 | "oneOf" : [ 26 | { 27 | "minimum" : "foo" 28 | } 29 | ] 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "pattern: must be a string - not object", 4 | "schema" : { "pattern" : {} } 5 | }, 6 | { 7 | "description" : "pattern: must be a string - not array", 8 | "schema" : { "pattern" : [] } 9 | }, 10 | { 11 | "description" : "pattern: must be a string - not number", 12 | "schema" : { "pattern" : 3.14 } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/patternProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "patternProperties: must be an object - not array", 4 | "schema" : { "patternProperties" : [] } 5 | }, 6 | { 7 | "description" : "patternProperties: must be an object - not int", 8 | "schema" : { "patternProperties" : 3 } 9 | }, 10 | { 11 | "description" : "patternProperties: must be an object - not number", 12 | "schema" : { "patternProperties" : 3.14 } 13 | }, 14 | { 15 | "description" : "patternProperties: must be an object and each value must be valid schema", 16 | "schema" : { 17 | "patternProperties" : { 18 | "foo" : [] 19 | } 20 | } 21 | } 22 | ] 23 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/properties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "properties: must be an object", 4 | "schema" : { "properties" : "foo" } 5 | }, 6 | { 7 | "description" : "properties: must be an object", 8 | "schema" : { "properties" : 3 } 9 | }, 10 | { 11 | "description" : "properties: must be an object", 12 | "schema" : { "properties" : 3.14 } 13 | }, 14 | { 15 | "description" : "properties: must be an object", 16 | "schema" : { "properties" : [] } 17 | }, 18 | { 19 | "description" : "properties: must be an object where values are schemas", 20 | "schema" : { 21 | "properties" : { 22 | "foo" : [] 23 | } 24 | } 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/ref.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "ref: must be a string - not object", 4 | "schema" : { "$ref" : {} } 5 | }, 6 | { 7 | "description" : "ref: must be a string - not array", 8 | "schema" : { "$ref" : [] } 9 | }, 10 | { 11 | "description" : "ref: must be a string - not number", 12 | "schema" : { "$ref" : 3.14 } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/required.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "required: must be non-empty array, not a string ", 4 | "schema" : { "required" : "foo" } 5 | }, 6 | { 7 | "description" : "required: must be non-empty array, not an object", 8 | "schema" : { "required" : {} } 9 | }, 10 | { 11 | "description" : "required: must be non-empty array, not an int", 12 | "schema" : { "required" : 3 } 13 | }, 14 | { 15 | "description" : "required: must be non-empty array", 16 | "schema" : { "required" : [] } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/title.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "title: must be a string - not object", 4 | "schema" : { "title" : {} } 5 | }, 6 | { 7 | "description" : "title: must be a string - not array", 8 | "schema" : { "title" : [] } 9 | }, 10 | { 11 | "description" : "title: must be a string - not int", 12 | "schema" : { "title" : 3 } 13 | }, 14 | { 15 | "description" : "title: must be a string - not number", 16 | "schema" : { "title" : 3.14 } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/type.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "type: must be 'string' or 'array', not integer", 4 | "schema" : { "type" : 3 } 5 | }, 6 | { 7 | "description" : "type: must be 'string' or 'array', not object", 8 | "schema" : { "type" : {} } 9 | }, 10 | { 11 | "description" : "type: should be integer, not int", 12 | "schema" : { "type" : "int" } 13 | }, 14 | { 15 | "description" : "type: sould be boolean not bool", 16 | "schema" : { "type" : ["bool"] } 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/custom/invalid_schemas/draft4/uniqueItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description" : "uniqueItems: must be a boolean - not a string", 4 | "schema" : { "uniqueItems" : "foo" } 5 | }, 6 | { 7 | "description" : "uniqueItems: must be a boolean - not an array ", 8 | "schema" : { "maximum" : [] } 9 | }, 10 | { 11 | "description" : "uniqueItems: must be a boolean - not an object ", 12 | "schema" : { "maximum" : {} } 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/custom/valid_schemas/draft2019-09/example.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "Simple test that passes", 4 | "schema": { 5 | "properties": { 6 | "foo": {"type": "string"} 7 | } 8 | }, 9 | "tests": [ 10 | { 11 | "description": "passes", 12 | "data": {"foo": "string"}, 13 | "valid": true 14 | }, 15 | { 16 | "description": "fails", 17 | "data": {"foo": 42}, 18 | "valid": false 19 | } 20 | ] 21 | }, 22 | { 23 | "description": "Properties in refs are evaluated", 24 | "schema": { 25 | "$defs": { 26 | "a": { 27 | "multipleOf": 10, 28 | "$ref": "#/$defs/b" 29 | }, 30 | "b": { 31 | "multipleOf": 3, 32 | "$ref": "#/$defs/c" 33 | }, 34 | "c": { 35 | "type": "number" 36 | } 37 | }, 38 | "properties": { 39 | "foo": {"$ref": "#/$defs/a"} 40 | } 41 | }, 42 | "tests": [ 43 | { 44 | "description": "30 passes", 45 | "data": {"foo": 30}, 46 | "valid": true 47 | }, 48 | { 49 | "description": "20 is not a multiple of 3", 50 | "data": {"foo": 20}, 51 | "valid": false 52 | }, 53 | { 54 | "description": "A String fails", 55 | "data": {"foo": "String"}, 56 | "valid": false 57 | } 58 | ] 59 | } 60 | ] 61 | -------------------------------------------------------------------------------- /test/relative_refs/root.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "root.json", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "title": "Root Schema", 5 | "description": "A schema with relative refs to other schema files", 6 | "type": "object", 7 | "properties": { 8 | "integer": {"$ref": "subdir/integer.json"}, 9 | "string": {"$ref": "string.json"} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/relative_refs/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } -------------------------------------------------------------------------------- /test/relative_refs/subdir/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "some_id_that_doesn't_match_ref#", 3 | "type": "integer" 4 | } -------------------------------------------------------------------------------- /test/unit/additional_remotes.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | Map additionalRemotes = { 3 | "http://localhost:4321/bar.json": r"""{ 4 | "baz": { "$ref": "http://localhost:4321/string.json#" } 5 | } """, 6 | "http://localhost:4321/date-keyword-meta-schema.json": r"""{ 7 | "$schema": "http://localhost:4321/date-keyword-meta-schema.json", 8 | "$id": "http://localhost:4321/date-keyword-meta-schema.json", 9 | "$vocabulary": { 10 | "https://json-schema.org/draft/2020-12/vocab/core": true, 11 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 12 | "https://json-schema.org/draft/2020-12/vocab/unevaluated": true, 13 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 14 | "https://json-schema.org/draft/2020-12/vocab/meta-data": true, 15 | "https://json-schema.org/draft/2020-12/vocab/format-annotation": true, 16 | "https://json-schema.org/draft/2020-12/vocab/content": true, 17 | "http://localhost:4321/vocab/min-date": true 18 | }, 19 | "allOf": [ 20 | {"$ref": "https://json-schema.org/draft/2020-12/schema" } 21 | ], 22 | "properties":{ 23 | "minDate": { 24 | "type": "string", 25 | "format": "date" 26 | } 27 | } 28 | } 29 | """, 30 | "http://localhost:4321/string.json": r"""{ 31 | "type": "string" 32 | }""", 33 | "http://localhost:4321/string_ref.json": r"""{ "$ref": "http://localhost:4321/string.json" }""" 34 | }; 35 | -------------------------------------------------------------------------------- /test/unit/json_schema/configurable_format_validation_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/json_schema.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | main() { 5 | test('Should respect configurable format validation', () { 6 | final schemaDraft7 = JsonSchema.create({ 7 | 'properties': { 8 | 'someKey': {'format': 'email'} 9 | } 10 | }, schemaVersion: SchemaVersion.draft7); 11 | 12 | final schemaDraft2019 = JsonSchema.create({ 13 | 'properties': { 14 | 'someKey': {'format': 'email'} 15 | } 16 | }, schemaVersion: SchemaVersion.draft2019_09); 17 | 18 | final badlyFormatted = {'someKey': '@@@@@'}; 19 | 20 | expect(schemaDraft7.validate(badlyFormatted).isValid, isFalse); 21 | expect(schemaDraft7.validate(badlyFormatted, validateFormats: false).isValid, isTrue); 22 | 23 | expect(schemaDraft2019.validate(badlyFormatted).isValid, isTrue); 24 | expect(schemaDraft2019.validate(badlyFormatted, validateFormats: true).isValid, isFalse); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/unit/json_schema/empty_schemas.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/json_schema.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | main() { 5 | group('JsonSchema.empty', () { 6 | test('can get an empty schema for any version', () { 7 | for (final version in SchemaVersion.values) { 8 | final emptySchema = JsonSchema.empty(schemaVersion: version); 9 | expect(emptySchema.schemaVersion, equals(version)); 10 | } 11 | }); 12 | test('defaults to the current default version', () { 13 | final emptySchema = JsonSchema.empty(); 14 | expect(emptySchema.schemaVersion, equals(SchemaVersion.defaultVersion)); 15 | }); 16 | test('calling JsonSchema.empty on the same version has same identity', () { 17 | final thing1 = JsonSchema.empty(); 18 | final thing2 = JsonSchema.empty(); 19 | expect(identical(thing1, thing2), isTrue); 20 | }); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/unit/json_schema/examples_keyword_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/json_schema.dart'; 2 | import 'package:test/test.dart'; 3 | 4 | main() { 5 | group('examples keyword', () { 6 | group('in draft4', () { 7 | test('should NOT be supported', () { 8 | final schema = JsonSchema.create({ 9 | "type": "string", 10 | "examples": ["This", "message", "is", "lost."] 11 | }, schemaVersion: SchemaVersion.draft4); 12 | 13 | expect(schema.examples.isEmpty, isTrue); 14 | }); 15 | test('should still pass the default value to the examples getter', () { 16 | final schema = JsonSchema.create({ 17 | "type": "string", 18 | "examples": ["This", "message", "is", "lost."], 19 | "default": "But this one isn't.", 20 | }, schemaVersion: SchemaVersion.draft4); 21 | 22 | expect(schema.examples.length, equals(1)); 23 | expect(schema.examples.single, equals("But this one isn't.")); 24 | }); 25 | }); 26 | 27 | group('in draft 6', () { 28 | test('should be supported', () { 29 | final schema = JsonSchema.create({ 30 | "type": "string", 31 | "examples": ["This", "message", "is", "not", "lost!"] 32 | }, schemaVersion: SchemaVersion.draft6); 33 | 34 | expect(schema.examples.length, equals(5)); 35 | expect(schema.examples[4], equals('lost!')); 36 | }); 37 | test('should append the default value to the examples getter', () { 38 | final schema = JsonSchema.create({ 39 | "type": "string", 40 | "examples": ["This", "message", "is", "not", "lost!"], 41 | "default": "And neither is this one", 42 | }, schemaVersion: SchemaVersion.draft6); 43 | 44 | expect(schema.examples.length, equals(6)); 45 | expect(schema.examples[0], equals("This")); 46 | expect(schema.examples[5], equals("And neither is this one")); 47 | }); 48 | }); 49 | }); 50 | } 51 | -------------------------------------------------------------------------------- /test/unit/json_schema/relative_file_uri_test.dart: -------------------------------------------------------------------------------- 1 | @TestOn('vm') 2 | // Runs on VM because filesystem paths can only be resolved on a server. 3 | 4 | import 'package:json_schema/json_schema.dart'; 5 | import 'package:test/test.dart'; 6 | 7 | main() { 8 | test('Schema from relative filesystem URI should be supported', () async { 9 | // this assumes that tests are run from the root directory of the project 10 | final schema = await JsonSchema.createFromUrl('test/relative_refs/root.json'); 11 | 12 | expect(schema.validate({"string": 123, "integer": 123}).isValid, isFalse); 13 | expect(schema.validate({"string": "a string", "integer": "a string"}).isValid, isFalse); 14 | expect(schema.validate({"string": "a string", "integer": 123}).isValid, isTrue); 15 | }); 16 | } 17 | -------------------------------------------------------------------------------- /test_fixes/rename_to_validate.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/json_schema.dart'; 2 | 3 | void main() { 4 | final schema = JsonSchema.empty(); 5 | schema.validateWithResults(null); 6 | final validator = Validator(schema); 7 | validator.validateWithResults(null); 8 | } 9 | -------------------------------------------------------------------------------- /test_fixes/rename_to_validate.dart.expect: -------------------------------------------------------------------------------- 1 | import 'package:json_schema/json_schema.dart'; 2 | 3 | void main() { 4 | final schema = JsonSchema.empty(); 5 | schema.validate(null); 6 | final validator = Validator(schema); 7 | validator.validate(null); 8 | } 9 | -------------------------------------------------------------------------------- /tool/serve_remotes.dart: -------------------------------------------------------------------------------- 1 | import 'package:shelf/shelf.dart'; 2 | import 'package:shelf/shelf_io.dart' as io; 3 | import 'package:shelf_static/shelf_static.dart'; 4 | 5 | import 'cors_headers.dart'; 6 | 7 | main() { 8 | // Serve remotes for ref tests. 9 | final specFileHandler = createStaticHandler('test/JSON-Schema-Test-Suite/remotes'); 10 | var specFileHandlerWithCors = const Pipeline().addMiddleware(corsHeaders()).addHandler(specFileHandler); 11 | io.serve(specFileHandlerWithCors, 'localhost', 1234); 12 | 13 | final additionalRemotesHandler = createStaticHandler('test/additional_remotes'); 14 | var additionalRemotesHandlerWithCors = 15 | const Pipeline().addMiddleware(corsHeaders()).addHandler(additionalRemotesHandler); 16 | io.serve(additionalRemotesHandlerWithCors, 'localhost', 4321); 17 | } 18 | --------------------------------------------------------------------------------