├── .github └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── NOTICE ├── README.md ├── doc ├── collector-context.md ├── compatibility.md ├── config.md ├── cust-msg.md ├── custom-meta-schema.md ├── duration.md ├── ecma-262.md ├── metaschema-validation.md ├── multiple-language.md ├── openapi-discriminators.md ├── openapi.md ├── quickstart.md ├── schema-retrieval.md ├── specversion.md ├── upgrading.md ├── validators.md ├── walk_flow.png ├── walkers.md ├── yaml-line-numbers.md └── yaml.md ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── networknt │ │ ├── org │ │ └── apache │ │ │ └── commons │ │ │ └── validator │ │ │ └── routines │ │ │ ├── DomainValidator.java │ │ │ ├── EmailValidator.java │ │ │ ├── InetAddressValidator.java │ │ │ └── RegexValidator.java │ │ └── schema │ │ ├── AbsoluteIri.java │ │ ├── AbstractCollector.java │ │ ├── AbstractJsonValidator.java │ │ ├── AbstractKeyword.java │ │ ├── AdditionalPropertiesValidator.java │ │ ├── AllOfValidator.java │ │ ├── AnnotationKeyword.java │ │ ├── AnyOfValidator.java │ │ ├── ApplyDefaultsStrategy.java │ │ ├── BaseJsonValidator.java │ │ ├── CachedSupplier.java │ │ ├── Collector.java │ │ ├── CollectorContext.java │ │ ├── ConstValidator.java │ │ ├── ContainsValidator.java │ │ ├── ContentEncodingValidator.java │ │ ├── ContentMediaTypeValidator.java │ │ ├── CustomErrorMessageType.java │ │ ├── DefaultJsonMetaSchemaFactory.java │ │ ├── DependenciesValidator.java │ │ ├── DependentRequired.java │ │ ├── DependentSchemas.java │ │ ├── DisallowUnknownJsonMetaSchemaFactory.java │ │ ├── DisallowUnknownKeywordFactory.java │ │ ├── DiscriminatorContext.java │ │ ├── DiscriminatorValidator.java │ │ ├── DynamicRefValidator.java │ │ ├── EnumValidator.java │ │ ├── ErrorMessageType.java │ │ ├── ExclusiveMaximumValidator.java │ │ ├── ExclusiveMinimumValidator.java │ │ ├── ExecutionConfig.java │ │ ├── ExecutionContext.java │ │ ├── ExecutionContextCustomizer.java │ │ ├── FailFastAssertionException.java │ │ ├── FalseValidator.java │ │ ├── Format.java │ │ ├── FormatKeyword.java │ │ ├── FormatValidator.java │ │ ├── Formats.java │ │ ├── IfValidator.java │ │ ├── InputFormat.java │ │ ├── InvalidSchemaException.java │ │ ├── InvalidSchemaRefException.java │ │ ├── ItemsValidator.java │ │ ├── ItemsValidator202012.java │ │ ├── JsonMetaSchema.java │ │ ├── JsonMetaSchemaFactory.java │ │ ├── JsonNodePath.java │ │ ├── JsonSchema.java │ │ ├── JsonSchemaException.java │ │ ├── JsonSchemaFactory.java │ │ ├── JsonSchemaIdValidator.java │ │ ├── JsonSchemaRef.java │ │ ├── JsonSchemaVersion.java │ │ ├── JsonType.java │ │ ├── JsonValidator.java │ │ ├── Keyword.java │ │ ├── KeywordFactory.java │ │ ├── MaxItemsValidator.java │ │ ├── MaxLengthValidator.java │ │ ├── MaxPropertiesValidator.java │ │ ├── MaximumValidator.java │ │ ├── MessageSourceValidationMessage.java │ │ ├── MinItemsValidator.java │ │ ├── MinLengthValidator.java │ │ ├── MinMaxContainsValidator.java │ │ ├── MinPropertiesValidator.java │ │ ├── MinimumValidator.java │ │ ├── MultipleOfValidator.java │ │ ├── NonValidationKeyword.java │ │ ├── NotAllowedValidator.java │ │ ├── NotValidator.java │ │ ├── OneOfValidator.java │ │ ├── OutputFormat.java │ │ ├── PathType.java │ │ ├── PatternPropertiesValidator.java │ │ ├── PatternValidator.java │ │ ├── PrefixItemsValidator.java │ │ ├── PropertiesValidator.java │ │ ├── PropertyNamesValidator.java │ │ ├── ReadOnlyValidator.java │ │ ├── RecursiveRefValidator.java │ │ ├── RefValidator.java │ │ ├── RequiredValidator.java │ │ ├── SchemaId.java │ │ ├── SchemaLocation.java │ │ ├── SchemaValidatorsConfig.java │ │ ├── SpecVersion.java │ │ ├── SpecVersionDetector.java │ │ ├── ThresholdMixin.java │ │ ├── TrueValidator.java │ │ ├── TypeFactory.java │ │ ├── TypeValidator.java │ │ ├── UnevaluatedItemsValidator.java │ │ ├── UnevaluatedPropertiesValidator.java │ │ ├── UnionTypeValidator.java │ │ ├── UniqueItemsValidator.java │ │ ├── UnknownKeywordFactory.java │ │ ├── ValidationContext.java │ │ ├── ValidationMessage.java │ │ ├── ValidationMessageHandler.java │ │ ├── ValidationResult.java │ │ ├── ValidatorTypeCode.java │ │ ├── Version201909.java │ │ ├── Version202012.java │ │ ├── Version4.java │ │ ├── Version6.java │ │ ├── Version7.java │ │ ├── Vocabularies.java │ │ ├── Vocabulary.java │ │ ├── VocabularyFactory.java │ │ ├── WriteOnlyValidator.java │ │ ├── annotation │ │ ├── JsonNodeAnnotation.java │ │ ├── JsonNodeAnnotationPredicate.java │ │ └── JsonNodeAnnotations.java │ │ ├── format │ │ ├── AbstractFormat.java │ │ ├── AbstractRFC3986Format.java │ │ ├── BaseFormat.java │ │ ├── BaseFormatJsonValidator.java │ │ ├── DateFormat.java │ │ ├── DateTimeFormat.java │ │ ├── DurationFormat.java │ │ ├── EmailFormat.java │ │ ├── IPv6AwareEmailValidator.java │ │ ├── IPv6Format.java │ │ ├── IdnEmailFormat.java │ │ ├── IdnHostnameFormat.java │ │ ├── IriFormat.java │ │ ├── IriReferenceFormat.java │ │ ├── PatternFormat.java │ │ ├── RegexFormat.java │ │ ├── TimeFormat.java │ │ ├── UriFormat.java │ │ └── UriReferenceFormat.java │ │ ├── i18n │ │ ├── DefaultMessageSource.java │ │ ├── Locales.java │ │ ├── MessageFormatter.java │ │ ├── MessageSource.java │ │ └── ResourceBundleMessageSource.java │ │ ├── oas │ │ ├── OpenApi30.java │ │ └── OpenApi31.java │ │ ├── output │ │ ├── HierarchicalOutputUnitFormatter.java │ │ ├── ListOutputUnitFormatter.java │ │ ├── OutputFlag.java │ │ ├── OutputUnit.java │ │ ├── OutputUnitData.java │ │ └── OutputUnitKey.java │ │ ├── regex │ │ ├── AllowRegularExpressionFactory.java │ │ ├── ECMAScriptRegularExpressionFactory.java │ │ ├── GraalJSContextFactory.java │ │ ├── GraalJSRegularExpression.java │ │ ├── GraalJSRegularExpressionContext.java │ │ ├── GraalJSRegularExpressionFactory.java │ │ ├── JDKRegularExpression.java │ │ ├── JDKRegularExpressionFactory.java │ │ ├── JoniRegularExpression.java │ │ ├── JoniRegularExpressionFactory.java │ │ ├── RegularExpression.java │ │ └── RegularExpressionFactory.java │ │ ├── resource │ │ ├── AllowSchemaLoader.java │ │ ├── ClasspathSchemaLoader.java │ │ ├── DefaultSchemaLoader.java │ │ ├── DisallowSchemaLoader.java │ │ ├── InputStreamSource.java │ │ ├── MapSchemaLoader.java │ │ ├── MapSchemaMapper.java │ │ ├── MetaSchemaMapper.java │ │ ├── PrefixSchemaMapper.java │ │ ├── SchemaLoader.java │ │ ├── SchemaLoaders.java │ │ ├── SchemaMapper.java │ │ ├── SchemaMappers.java │ │ └── UriSchemaLoader.java │ │ ├── result │ │ ├── JsonNodeResult.java │ │ └── JsonNodeResults.java │ │ ├── serialization │ │ ├── DefaultJsonNodeReader.java │ │ ├── JsonMapperFactory.java │ │ ├── JsonNodeReader.java │ │ ├── YamlMapperFactory.java │ │ └── node │ │ │ ├── JsonLocationAware.java │ │ │ ├── JsonLocationAwareArrayNode.java │ │ │ ├── JsonLocationAwareBigIntegerNode.java │ │ │ ├── JsonLocationAwareBinaryNode.java │ │ │ ├── JsonLocationAwareBooleanNode.java │ │ │ ├── JsonLocationAwareDecimalNode.java │ │ │ ├── JsonLocationAwareDoubleNode.java │ │ │ ├── JsonLocationAwareFloatNode.java │ │ │ ├── JsonLocationAwareIntNode.java │ │ │ ├── JsonLocationAwareLongNode.java │ │ │ ├── JsonLocationAwareNullNode.java │ │ │ ├── JsonLocationAwareObjectNode.java │ │ │ ├── JsonLocationAwarePOJONode.java │ │ │ ├── JsonLocationAwareShortNode.java │ │ │ ├── JsonLocationAwareTextNode.java │ │ │ ├── JsonNodeFactoryFactory.java │ │ │ ├── LocationJsonNodeFactory.java │ │ │ └── LocationJsonNodeFactoryFactory.java │ │ ├── utils │ │ ├── AbsoluteIris.java │ │ ├── CachingSupplier.java │ │ ├── Classes.java │ │ ├── JsonNodeUtil.java │ │ ├── JsonNodes.java │ │ ├── JsonSchemaRefs.java │ │ ├── RFC5892.java │ │ ├── SetView.java │ │ ├── StringChecker.java │ │ ├── StringUtils.java │ │ ├── UCDLoader.java │ │ └── UnicodeDatabase.java │ │ └── walk │ │ ├── AbstractWalkListenerRunner.java │ │ ├── DefaultItemWalkListenerRunner.java │ │ ├── DefaultKeywordWalkListenerRunner.java │ │ ├── DefaultPropertyWalkListenerRunner.java │ │ ├── JsonSchemaWalkListener.java │ │ ├── JsonSchemaWalker.java │ │ ├── WalkEvent.java │ │ ├── WalkFlow.java │ │ └── WalkListenerRunner.java └── resources │ ├── META-INF │ └── native-image │ │ └── com.networknt │ │ └── json-schema-validator │ │ ├── native-image.properties │ │ ├── reflect-config.json │ │ └── resource-config.json │ ├── draft-04 │ └── schema │ ├── draft-06 │ └── schema │ ├── draft-07 │ └── schema │ ├── draft │ ├── 2019-09 │ │ ├── meta │ │ │ ├── applicator │ │ │ ├── content │ │ │ ├── core │ │ │ ├── format │ │ │ ├── meta-data │ │ │ └── validation │ │ └── schema │ └── 2020-12 │ │ ├── meta │ │ ├── applicator │ │ ├── content │ │ ├── core │ │ ├── format-annotation │ │ ├── meta-data │ │ ├── unevaluated │ │ └── validation │ │ └── schema │ ├── jsv-messages.properties │ ├── jsv-messages_ar.properties │ ├── jsv-messages_cs.properties │ ├── jsv-messages_da.properties │ ├── jsv-messages_de.properties │ ├── jsv-messages_en.properties │ ├── jsv-messages_fa.properties │ ├── jsv-messages_fi.properties │ ├── jsv-messages_fr.properties │ ├── jsv-messages_he.properties │ ├── jsv-messages_hr.properties │ ├── jsv-messages_hu.properties │ ├── jsv-messages_it.properties │ ├── jsv-messages_ja.properties │ ├── jsv-messages_ko.properties │ ├── jsv-messages_nb.properties │ ├── jsv-messages_nl.properties │ ├── jsv-messages_pl.properties │ ├── jsv-messages_pt.properties │ ├── jsv-messages_ro.properties │ ├── jsv-messages_ru.properties │ ├── jsv-messages_sk.properties │ ├── jsv-messages_sv.properties │ ├── jsv-messages_th.properties │ ├── jsv-messages_tr.properties │ ├── jsv-messages_uk.properties │ ├── jsv-messages_vi.properties │ ├── jsv-messages_zh_CN.properties │ ├── jsv-messages_zh_TW.properties │ └── ucd │ ├── RFC5892-appendix-B.txt │ └── extracted │ └── DerivedJoiningType.txt └── test ├── java └── com │ └── networknt │ └── schema │ ├── AbsoluteIriTest.java │ ├── AbstractJsonSchemaTest.java │ ├── AbstractJsonSchemaTestSuite.java │ ├── AdditionalPropertiesValidatorTest.java │ ├── AllOfValidatorTest.java │ ├── AnyOfValidatorTest.java │ ├── BaseJsonSchemaValidatorTest.java │ ├── CachedSupplierTest.java │ ├── CollectorContextTest.java │ ├── ConstValidatorTest.java │ ├── ContentSchemaValidatorTest.java │ ├── CustomMessageTest.java │ ├── CustomMetaSchemaTest.java │ ├── CustomUriTest.java │ ├── CyclicDependencyTest.java │ ├── DateTimeDSTTest.java │ ├── DefaultJsonSchemaIdValidatorTest.java │ ├── DependentRequiredTest.java │ ├── DisallowUnknownJsonMetaSchemaFactoryTest.java │ ├── DisallowUnknownKeywordFactoryTest.java │ ├── DiscriminatorValidatorTest.java │ ├── DurationFormatValidatorTest.java │ ├── EnumValidatorTest.java │ ├── ExampleTest.java │ ├── ExclusiveMinimumValidatorTest.java │ ├── FormatKeywordFactoryTest.java │ ├── FormatValidatorTest.java │ ├── HTTPServiceSupport.java │ ├── IfValidatorTest.java │ ├── Issue1091Test.java │ ├── Issue255Test.java │ ├── Issue285Test.java │ ├── Issue295Test.java │ ├── Issue313Test.java │ ├── Issue314Test.java │ ├── Issue327Test.java │ ├── Issue342Test.java │ ├── Issue347Test.java │ ├── Issue366FailFastTest.java │ ├── Issue366FailSlowTest.java │ ├── Issue375Test.java │ ├── Issue383Test.java │ ├── Issue396Test.java │ ├── Issue404Test.java │ ├── Issue406Test.java │ ├── Issue426Test.java │ ├── Issue428Test.java │ ├── Issue451Test.java │ ├── Issue456Test.java │ ├── Issue461Test.java │ ├── Issue467Test.java │ ├── Issue471Test.java │ ├── Issue475Test.java │ ├── Issue493Test.java │ ├── Issue518Test.java │ ├── Issue532Test.java │ ├── Issue550Test.java │ ├── Issue575Test.java │ ├── Issue604Test.java │ ├── Issue606Test.java │ ├── Issue619Test.java │ ├── Issue650Test.java │ ├── Issue662Test.java │ ├── Issue664Test.java │ ├── Issue665Test.java │ ├── Issue668Test.java │ ├── Issue686Test.java │ ├── Issue687Test.java │ ├── Issue724Test.java │ ├── Issue769ContainsTest.java │ ├── Issue784Test.java │ ├── Issue792.java │ ├── Issue824Test.java │ ├── Issue832Test.java │ ├── Issue857Test.java │ ├── Issue877Test.java │ ├── Issue898Test.java │ ├── Issue927Test.java │ ├── Issue928Test.java │ ├── Issue935Test.java │ ├── Issue936Test.java │ ├── Issue939Test.java │ ├── Issue940Test.java │ ├── Issue943Test.java │ ├── Issue994Test.java │ ├── ItemsValidator202012Test.java │ ├── ItemsValidatorTest.java │ ├── JsonNodeAnnotationsTest.java │ ├── JsonNodePathTest.java │ ├── JsonSchemaFactoryTest.java │ ├── JsonSchemaFactoryUriCacheTest.java │ ├── JsonSchemaPreloadTest.java │ ├── JsonSchemaTest.java │ ├── JsonSchemaTestSuiteExtrasTest.java │ ├── JsonSchemaTestSuiteTest.java │ ├── JsonWalkApplyDefaultsTest.java │ ├── JsonWalkTest.java │ ├── LocaleTest.java │ ├── MaximumValidatorPerfTest.java │ ├── MaximumValidatorTest.java │ ├── MessageTest.java │ ├── MetaSchemaValidationTest.java │ ├── MinimumValidatorTest.java │ ├── MultipleOfValidatorTest.java │ ├── NotAllowedValidatorTest.java │ ├── NotValidatorTest.java │ ├── OneOfValidatorTest.java │ ├── OpenAPI30JsonSchemaTest.java │ ├── OutputFormatTest.java │ ├── OutputUnitTest.java │ ├── OverrideValidatorTest.java │ ├── OverwritingCustomMessageBugTest.java │ ├── PathTypeTest.java │ ├── PatternPropertiesValidatorTest.java │ ├── PatternValidatorTest.java │ ├── PrefixItemsValidatorTest.java │ ├── PropertiesTest.java │ ├── PropertiesValidatorTest.java │ ├── PropertyNamesValidatorTest.java │ ├── ReadOnlyValidatorTest.java │ ├── RecursiveReferenceValidatorExceptionTest.java │ ├── RefTest.java │ ├── RefValidatorTest.java │ ├── SampleTest.java │ ├── SchemaLocationTest.java │ ├── SchemaValidatorsConfigTest.java │ ├── SelfRefTest.java │ ├── SharedConfigTest.java │ ├── SpecVersionDetectorTest.java │ ├── StringCheckerTest.java │ ├── ThresholdMixinPerfTest.java │ ├── TypeFactoryTest.java │ ├── TypeValidatorTest.java │ ├── UnevaluatedItemsTest.java │ ├── UnevaluatedItemsValidatorTest.java │ ├── UnevaluatedPropertiesTest.java │ ├── UnevaluatedPropertiesValidatorTest.java │ ├── UnknownKeywordFactoryTest.java │ ├── UnknownMetaSchemaTest.java │ ├── UriMappingTest.java │ ├── UrnTest.java │ ├── V4JsonSchemaTest.java │ ├── ValidationMessageHandlerTest.java │ ├── ValidationMessageTest.java │ ├── ValidatorTypeCodeTest.java │ ├── VocabularyTest.java │ ├── format │ ├── IriFormatTest.java │ ├── IriReferenceFormatTest.java │ ├── UriFormatTest.java │ └── UriReferenceFormatTest.java │ ├── i18n │ ├── LocalesTest.java │ └── ResourceBundleMessageSourceTest.java │ ├── oas │ ├── OpenApi30Test.java │ └── OpenApi31Test.java │ ├── output │ └── OutputUnitDataTest.java │ ├── regex │ ├── AllowRegularExpressionFactoryTest.java │ ├── ECMAScriptRegularExpressionFactoryTest.java │ ├── GraalJSRegularExpressionFactoryTest.java │ ├── GraalJSRegularExpressionTest.java │ ├── Issue814Test.java │ ├── JDKRegularExpressionFactoryTest.java │ ├── JDKRegularExpressionTest.java │ ├── JoniRegularExpressionFactoryTest.java │ └── JoniRegularExpressionTest.java │ ├── resource │ ├── AllowSchemaLoaderTest.java │ ├── DisallowSchemaLoaderTest.java │ ├── MapSchemaLoaderTest.java │ ├── MapSchemaMapperTest.java │ ├── MetaSchemaMapperTest.java │ └── UriSchemaLoaderTest.java │ ├── serialization │ └── DefaultJsonNodeReaderTest.java │ ├── suite │ ├── TestCase.java │ ├── TestSource.java │ └── TestSpec.java │ ├── utils │ ├── AbsoluteIrisTest.java │ ├── JsonNodesTest.java │ └── SetViewTest.java │ └── walk │ └── JsonSchemaWalkListenerTest.java ├── resources ├── const-messages-override.properties ├── data │ ├── OverwritingCustomMessageBug.json │ ├── contains │ │ └── issue769 │ │ │ ├── max-contains-v7.json │ │ │ ├── max-contains.json │ │ │ ├── min-contains-v7.json │ │ │ └── min-contains.json │ ├── dstTimes.json │ ├── issue1091.json │ ├── issue255.json │ ├── issue295.json │ ├── issue313.json │ ├── issue327.json │ ├── issue342.json │ ├── issue366.json │ ├── issue375.json │ ├── issue383.json │ ├── issue396.json │ ├── issue404.json │ ├── issue426.json │ ├── issue428.json │ ├── issue451.json │ ├── issue456-T2.json │ ├── issue456-T3.json │ ├── issue461-v7.json │ ├── issue467.json │ ├── issue471.json │ ├── issue493-invalid-1.json │ ├── issue493-invalid-2.json │ ├── issue493-valid-1.json │ ├── issue493-valid-2.json │ ├── issue500_1.json │ ├── issue500_2.json │ ├── issue606.json │ ├── issue627.json │ ├── issue664.json │ ├── issue668.json │ ├── issue832.json │ ├── issue898.json │ ├── notAllowedValidation │ │ └── notAllowedJson.json │ ├── output-format-input.json │ ├── read-only-data.json │ ├── schemaTag.json │ ├── schemaTagMissing.json │ ├── walk-data-default.json │ └── walk-data.json ├── draft2019-09 │ ├── dependencies.json │ ├── invalid-min-max-contains.json │ ├── issue255.json │ ├── issue375.json │ ├── permissive-duration.json │ ├── properties.json │ └── schemaTag.json ├── draft2020-12 │ ├── invalid-min-max-contains.json │ ├── issue495.json │ ├── issue656.json │ ├── issue782.json │ ├── issue798.json │ └── schemaTag.json ├── draft4 │ ├── complex.json │ ├── enumObject.json │ ├── extra │ │ ├── classpath │ │ │ ├── schema.json │ │ │ └── sub-schema.json │ │ ├── cyclic │ │ │ ├── Element.json │ │ │ ├── Extension.json │ │ │ └── Master.json │ │ ├── folder │ │ │ └── folderInteger.json │ │ ├── product │ │ │ ├── product-all-errors-data.json │ │ │ ├── product-no-errors-data.json │ │ │ ├── product-one-error-data.json │ │ │ ├── product-two-errors-data.json │ │ │ └── product.schema.json │ │ ├── property.json │ │ ├── union_type.json │ │ ├── uri_mapping │ │ │ ├── example-schema.json │ │ │ ├── invalid-schema-uri.json │ │ │ ├── schema-with-ref-mapping.json │ │ │ ├── schema-with-ref.json │ │ │ ├── uri-mapping.json │ │ │ └── uri-mapping.schema.json │ │ └── uuid.json │ ├── idRef.json │ ├── integer.json │ ├── issue258 │ │ ├── Element.json │ │ ├── Extension.json │ │ └── Master.json │ ├── issue425.json │ ├── refRemoteSchema.json │ ├── relativeRefRemote.json │ ├── schemaTag.json │ └── subSchemas.json ├── draft6 │ ├── idRef.json │ └── schemaTag.json ├── draft7 │ ├── idRef.json │ ├── issue386.json │ ├── issue470.json │ ├── issue491.json │ ├── issue516.json │ ├── issue590.json │ ├── issue650.json │ ├── issue653.json │ ├── issue678.json │ ├── schemaTag.json │ └── urn │ │ ├── account.schema.json │ │ ├── issue665.json │ │ ├── issue665_external_urn_ref.json │ │ ├── issue665_external_urn_subschema.json │ │ ├── test.json │ │ └── urn.schema.json ├── issue686 │ ├── translations.properties │ ├── translations_de.properties │ └── translations_fr.properties ├── issue784 │ └── schema.json ├── issues │ ├── 662 │ │ ├── emptyObject.json │ │ ├── objectInvalidValue.json │ │ ├── schema.json │ │ └── validObject.json │ └── 1016 │ │ └── schema.json ├── jsv-messages-override.properties ├── logback-test.xml ├── multipleOfScale.json ├── oas │ └── 3.1 │ │ ├── dialect │ │ └── base │ │ ├── meta │ │ └── base │ │ ├── schema-base │ │ └── 2022-10-07 │ │ └── schema │ │ └── 2022-10-07 ├── openapi3 │ └── discriminator.json ├── prefixItemsException │ └── prefixItemsException.json ├── recursiveRefException │ └── invalidRecursiveReference.json ├── remotes │ ├── folder │ │ └── folderInteger.json │ ├── id_schema │ │ ├── property.json │ │ └── schema │ │ │ └── features.json │ └── self_ref │ │ └── selfRef.json ├── schema │ ├── OverwritingCustomMessageBug.json │ ├── common │ │ ├── child.json │ │ └── child2.json │ ├── contains │ │ └── issue769 │ │ │ ├── max-contains-v7.json │ │ │ ├── max-contains.json │ │ │ ├── min-contains-v7.json │ │ │ └── min-contains.json │ ├── customMessageTests │ │ ├── custom-message-disabled-tests.json │ │ └── custom-message-tests.json │ ├── dateTimeArray.json │ ├── example-escaped.yaml │ ├── example-main.json │ ├── example-ref.json │ ├── id-relative.json │ ├── issue1091.json │ ├── issue295-v7.json │ ├── issue313-2019-09.json │ ├── issue313-v7.json │ ├── issue314-v7.json │ ├── issue327-v7.json │ ├── issue342-v7.json │ ├── issue347-v7.json │ ├── issue366_schema.json │ ├── issue383-v7.json │ ├── issue396-v7.json │ ├── issue404-v7.json │ ├── issue426-v7.json │ ├── issue451-v7.json │ ├── issue456-v7.json │ ├── issue467.json │ ├── issue471-2019-09.json │ ├── issue493.json │ ├── issue500_1-v7.json │ ├── issue500_2-v7.json │ ├── issue518-v7.json │ ├── issue575-2019-09.json │ ├── issue606-v7.json │ ├── issue619.json │ ├── issue627-v7.json │ ├── issue664-v7.json │ ├── issue668-sub1.yml │ ├── issue668-sub2.yaml │ ├── issue668-sub3 │ ├── issue668.yml │ ├── issue687.json │ ├── issue832-v7.json │ ├── issue898.json │ ├── issue928-v07.json │ ├── issue928-v2019-09.json │ ├── issue928-v2020-12.json │ ├── issue936.json │ ├── main │ │ └── main.json │ ├── notAllowedValidation │ │ └── notAllowedJson.json │ ├── oas │ │ ├── 3.0 │ │ │ └── petstore.yaml │ │ └── 3.1 │ │ │ ├── petstore.json │ │ │ └── petstore.yaml │ ├── output-format-schema.json │ ├── read-only-schema.json │ ├── ref-main-schema-resource.json │ ├── ref-main.json │ ├── ref-ref.json │ ├── unevaluatedTests │ │ ├── unevaluated-items-tests.json │ │ └── unevaluated-tests.json │ ├── walk-schema-default.json │ └── walk-schema.json ├── selfRef.json ├── test-messages.properties └── test-messages_fr.properties └── suite ├── .editorconfig ├── .github ├── CODEOWNERS └── workflows │ └── ci.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bin └── jsonschema_suite ├── output-test-schema.json ├── output-tests ├── README.md ├── draft-next │ ├── content │ │ ├── general.json │ │ ├── readOnly.json │ │ └── type.json │ └── output-schema.json ├── draft2019-09 │ ├── content │ │ ├── escape.json │ │ ├── general.json │ │ ├── readOnly.json │ │ └── type.json │ └── output-schema.json └── draft2020-12 │ ├── content │ ├── escape.json │ ├── general.json │ ├── readOnly.json │ └── type.json │ └── output-schema.json ├── package.json ├── remotes ├── baseUriChange │ └── folderInteger.json ├── baseUriChangeFolder │ └── folderInteger.json ├── baseUriChangeFolderInSubschema │ └── folderInteger.json ├── different-id-ref-string.json ├── draft-next │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── detached-dynamicref.json │ ├── detached-ref.json │ ├── extendible-dynamic-ref.json │ ├── format-assertion-false.json │ ├── format-assertion-true.json │ ├── id │ │ └── my_identifier.json │ ├── integer.json │ ├── locationIndependentIdentifier.json │ ├── metaschema-no-validation.json │ ├── metaschema-optional-vocabulary.json │ ├── name-defs.json │ ├── nested │ │ ├── foo-ref-string.json │ │ └── string.json │ ├── ref-and-defs.json │ ├── subSchemas-defs.json │ ├── subSchemas.json │ ├── tree.json │ └── unknownKeyword │ │ └── my_identifier.json ├── draft2019-09 │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── dependentRequired.json │ ├── detached-ref.json │ ├── extendible-dynamic-ref.json │ ├── id │ │ └── my_identifier.json │ ├── ignore-prefixItems.json │ ├── integer.json │ ├── locationIndependentIdentifier.json │ ├── metaschema-no-validation.json │ ├── metaschema-optional-vocabulary.json │ ├── name-defs.json │ ├── nested │ │ ├── foo-ref-string.json │ │ └── string.json │ ├── ref-and-defs.json │ ├── subSchemas-defs.json │ ├── subSchemas.json │ ├── tree.json │ └── unknownKeyword │ │ └── my_identifier.json ├── draft2020-12 │ ├── baseUriChange │ │ └── folderInteger.json │ ├── baseUriChangeFolder │ │ └── folderInteger.json │ ├── baseUriChangeFolderInSubschema │ │ └── folderInteger.json │ ├── detached-dynamicref.json │ ├── detached-ref.json │ ├── extendible-dynamic-ref.json │ ├── format-assertion-false.json │ ├── format-assertion-true.json │ ├── id │ │ └── my_identifier.json │ ├── integer.json │ ├── locationIndependentIdentifier.json │ ├── metaschema-no-validation.json │ ├── metaschema-optional-vocabulary.json │ ├── name-defs.json │ ├── nested │ │ ├── foo-ref-string.json │ │ └── string.json │ ├── prefixItems.json │ ├── ref-and-defs.json │ ├── subSchemas-defs.json │ ├── subSchemas.json │ ├── tree.json │ └── unknownKeyword │ │ └── my_identifier.json ├── draft6 │ └── detached-ref.json ├── draft7 │ ├── detached-ref.json │ └── ignore-dependentRequired.json ├── extendible-dynamic-ref.json ├── id │ └── my_identifier.json ├── integer.json ├── locationIndependentIdentifier.json ├── locationIndependentIdentifierDraft4.json ├── locationIndependentIdentifierPre2019.json ├── name-defs.json ├── name.json ├── nested-absolute-ref-to-string.json ├── nested │ ├── foo-ref-string.json │ └── string.json ├── ref-and-definitions.json ├── ref-and-defs.json ├── subSchemas-defs.json ├── subSchemas.json ├── tree.json ├── unknownKeyword │ └── my_identifier.json └── urn-ref-string.json ├── test-schema.json ├── tests ├── draft-next │ ├── additionalProperties.json │ ├── allOf.json │ ├── anchor.json │ ├── anyOf.json │ ├── boolean_schema.json │ ├── const.json │ ├── contains.json │ ├── content.json │ ├── default.json │ ├── defs.json │ ├── dependentRequired.json │ ├── dependentSchemas.json │ ├── dynamicRef.json │ ├── enum.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── format.json │ ├── 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 │ │ ├── anchor.json │ │ ├── bignum.json │ │ ├── dependencies-compatibility.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 │ │ ├── id.json │ │ ├── non-bmp-regex.json │ │ ├── refOfUnknownKeyword.json │ │ └── unknownKeyword.json │ ├── pattern.json │ ├── patternProperties.json │ ├── prefixItems.json │ ├── properties.json │ ├── propertyDependencies.json │ ├── propertyNames.json │ ├── ref.json │ ├── refRemote.json │ ├── required.json │ ├── type.json │ ├── unevaluatedItems.json │ ├── unevaluatedProperties.json │ ├── uniqueItems.json │ └── vocabulary.json ├── draft2019-09 │ ├── additionalItems.json │ ├── additionalProperties.json │ ├── allOf.json │ ├── anchor.json │ ├── anyOf.json │ ├── boolean_schema.json │ ├── const.json │ ├── contains.json │ ├── content.json │ ├── default.json │ ├── defs.json │ ├── dependentRequired.json │ ├── dependentSchemas.json │ ├── enum.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── format.json │ ├── 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 │ │ ├── anchor.json │ │ ├── bignum.json │ │ ├── cross-draft.json │ │ ├── dependencies-compatibility.json │ │ ├── ecmascript-regex.json │ │ ├── float-overflow.json │ │ ├── format │ │ │ ├── date-time.json │ │ │ ├── date.json │ │ │ ├── duration.json │ │ │ ├── email.json │ │ │ ├── hostname.json │ │ │ ├── idn-email.json │ │ │ ├── idn-hostname.json │ │ │ ├── ipv4.json │ │ │ ├── ipv6.json │ │ │ ├── iri-reference.json │ │ │ ├── iri.json │ │ │ ├── json-pointer.json │ │ │ ├── regex.json │ │ │ ├── relative-json-pointer.json │ │ │ ├── time.json │ │ │ ├── unknown.json │ │ │ ├── uri-reference.json │ │ │ ├── uri-template.json │ │ │ ├── uri.json │ │ │ └── uuid.json │ │ ├── id.json │ │ ├── no-schema.json │ │ ├── non-bmp-regex.json │ │ ├── refOfUnknownKeyword.json │ │ └── unknownKeyword.json │ ├── pattern.json │ ├── patternProperties.json │ ├── properties.json │ ├── propertyNames.json │ ├── recursiveRef.json │ ├── ref.json │ ├── refRemote.json │ ├── required.json │ ├── type.json │ ├── unevaluatedItems.json │ ├── unevaluatedProperties.json │ ├── uniqueItems.json │ └── vocabulary.json ├── draft2020-12 │ ├── additionalProperties.json │ ├── allOf.json │ ├── anchor.json │ ├── anyOf.json │ ├── boolean_schema.json │ ├── const.json │ ├── contains.json │ ├── content.json │ ├── default.json │ ├── defs.json │ ├── dependentRequired.json │ ├── dependentSchemas.json │ ├── dynamicRef.json │ ├── enum.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── format.json │ ├── 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 │ │ ├── anchor.json │ │ ├── bignum.json │ │ ├── cross-draft.json │ │ ├── dependencies-compatibility.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 │ │ ├── id.json │ │ ├── no-schema.json │ │ ├── non-bmp-regex.json │ │ ├── refOfUnknownKeyword.json │ │ └── unknownKeyword.json │ ├── pattern.json │ ├── patternProperties.json │ ├── prefixItems.json │ ├── properties.json │ ├── propertyNames.json │ ├── ref.json │ ├── refRemote.json │ ├── required.json │ ├── type.json │ ├── unevaluatedItems.json │ ├── unevaluatedProperties.json │ ├── uniqueItems.json │ └── vocabulary.json ├── draft3 │ ├── additionalItems.json │ ├── additionalProperties.json │ ├── default.json │ ├── dependencies.json │ ├── disallow.json │ ├── divisibleBy.json │ ├── enum.json │ ├── extends.json │ ├── format.json │ ├── infinite-loop-detection.json │ ├── items.json │ ├── maxItems.json │ ├── maxLength.json │ ├── maximum.json │ ├── minItems.json │ ├── minLength.json │ ├── minimum.json │ ├── optional │ │ ├── bignum.json │ │ ├── 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 │ ├── infinite-loop-detection.json │ ├── items.json │ ├── maxItems.json │ ├── maxLength.json │ ├── maxProperties.json │ ├── maximum.json │ ├── minItems.json │ ├── minLength.json │ ├── minProperties.json │ ├── minimum.json │ ├── multipleOf.json │ ├── not.json │ ├── oneOf.json │ ├── optional │ │ ├── bignum.json │ │ ├── ecmascript-regex.json │ │ ├── float-overflow.json │ │ ├── format │ │ │ ├── date-time.json │ │ │ ├── email.json │ │ │ ├── hostname.json │ │ │ ├── ipv4.json │ │ │ ├── ipv6.json │ │ │ ├── unknown.json │ │ │ └── uri.json │ │ ├── id.json │ │ ├── non-bmp-regex.json │ │ └── zeroTerminatedFloats.json │ ├── pattern.json │ ├── patternProperties.json │ ├── properties.json │ ├── ref.json │ ├── refRemote.json │ ├── required.json │ ├── type.json │ └── uniqueItems.json ├── draft6 │ ├── additionalItems.json │ ├── additionalProperties.json │ ├── allOf.json │ ├── anyOf.json │ ├── boolean_schema.json │ ├── const.json │ ├── contains.json │ ├── default.json │ ├── definitions.json │ ├── dependencies.json │ ├── enum.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── format.json │ ├── infinite-loop-detection.json │ ├── items.json │ ├── maxItems.json │ ├── maxLength.json │ ├── maxProperties.json │ ├── maximum.json │ ├── minItems.json │ ├── minLength.json │ ├── minProperties.json │ ├── minimum.json │ ├── multipleOf.json │ ├── not.json │ ├── oneOf.json │ ├── optional │ │ ├── bignum.json │ │ ├── ecmascript-regex.json │ │ ├── float-overflow.json │ │ ├── format │ │ │ ├── date-time.json │ │ │ ├── email.json │ │ │ ├── hostname.json │ │ │ ├── ipv4.json │ │ │ ├── ipv6.json │ │ │ ├── json-pointer.json │ │ │ ├── unknown.json │ │ │ ├── uri-reference.json │ │ │ ├── uri-template.json │ │ │ └── uri.json │ │ ├── id.json │ │ ├── non-bmp-regex.json │ │ └── unknownKeyword.json │ ├── pattern.json │ ├── patternProperties.json │ ├── properties.json │ ├── propertyNames.json │ ├── ref.json │ ├── refRemote.json │ ├── required.json │ ├── type.json │ └── uniqueItems.json └── draft7 │ ├── additionalItems.json │ ├── additionalProperties.json │ ├── allOf.json │ ├── anyOf.json │ ├── boolean_schema.json │ ├── const.json │ ├── contains.json │ ├── default.json │ ├── definitions.json │ ├── dependencies.json │ ├── enum.json │ ├── exclusiveMaximum.json │ ├── exclusiveMinimum.json │ ├── format.json │ ├── if-then-else.json │ ├── infinite-loop-detection.json │ ├── items.json │ ├── maxItems.json │ ├── maxLength.json │ ├── maxProperties.json │ ├── maximum.json │ ├── minItems.json │ ├── minLength.json │ ├── minProperties.json │ ├── minimum.json │ ├── multipleOf.json │ ├── not.json │ ├── oneOf.json │ ├── optional │ ├── bignum.json │ ├── content.json │ ├── cross-draft.json │ ├── ecmascript-regex.json │ ├── float-overflow.json │ ├── format │ │ ├── date-time.json │ │ ├── date.json │ │ ├── email.json │ │ ├── hostname.json │ │ ├── idn-email.json │ │ ├── idn-hostname.json │ │ ├── ipv4.json │ │ ├── ipv6.json │ │ ├── iri-reference.json │ │ ├── iri.json │ │ ├── json-pointer.json │ │ ├── regex.json │ │ ├── relative-json-pointer.json │ │ ├── time.json │ │ ├── unknown.json │ │ ├── uri-reference.json │ │ ├── uri-template.json │ │ └── uri.json │ ├── id.json │ ├── non-bmp-regex.json │ └── unknownKeyword.json │ ├── pattern.json │ ├── patternProperties.json │ ├── properties.json │ ├── propertyNames.json │ ├── ref.json │ ├── refRemote.json │ ├── required.json │ ├── type.json │ └── uniqueItems.json └── tox.ini /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | java: [ 8, 11, 17, 21 ] 17 | name: Java ${{ matrix.java }} 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - name: Setup JDK 22 | uses: actions/setup-java@v4 23 | with: 24 | distribution: 'temurin' 25 | java-version: ${{ matrix.java }} 26 | cache: 'maven' 27 | 28 | - name: Build with Maven 29 | run: mvn --batch-mode --update-snapshots verify -Dstyle.color=always 30 | 31 | - name: Upload coverage to Codecov 32 | if: matrix.java == '8' 33 | uses: codecov/codecov-action@v4 34 | with: 35 | token: ${{ secrets.CODECOV_TOKEN }} 36 | fail_ci_if_error: false 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | bower_components/ 3 | node_modules/ 4 | dist/ 5 | .idea/ 6 | .tmp/ 7 | .project 8 | .classpath 9 | .settings 10 | .metadata/ 11 | *.iml 12 | *.ipr 13 | *.iws 14 | *.log 15 | *.tmp 16 | *.zip 17 | *.bak 18 | 19 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 20 | hs_err_pid* 21 | /.gradle/ 22 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | JSON Schema Validator 2 | Copyright (c) 2016 and onwards Network New Technologies Inc. 3 | 4 | // ------------------------------------------------------------------ 5 | // NOTICE file corresponding to the section 4d of The Apache License, 6 | // Version 2.0, in this case for 7 | // ------------------------------------------------------------------ 8 | 9 | Apache Commons Validator 10 | Copyright 2001-2023 The Apache Software Foundation 11 | 12 | This product includes software developed at 13 | The Apache Software Foundation (http://www.apache.org/). 14 | -------------------------------------------------------------------------------- /doc/metaschema-validation.md: -------------------------------------------------------------------------------- 1 | If you have an use case to validate custom schemas against the one of the JSON schema draft version, here is the code that you can do it. 2 | 3 | ``` 4 | public static final Function> validateAgainstMetaSchema = 5 | schema -> { 6 | JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909); 7 | JsonSchema metaSchema = factory.getSchema(getSchemaUri()); 8 | return metaSchema.validate(schema).stream() 9 | .map((validation) -> new SchemaValidationMessage(validation.getMessage())) 10 | .collect(Collectors.toSet()); 11 | }; 12 | 13 | ``` 14 | 15 | This should now work but does not support all the keywords because the JsonMetaSchema of SpecVersion.VersionFlag.V201909 is lacking these features. 16 | 17 | You can fix the issue by resolving the vocabularies to a local resource file and re-do the JsonMetaSchema for 2019 based on that. 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /doc/walk_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/doc/walk_flow.png -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/AbstractCollector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Network New Technologies Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema; 17 | 18 | /** 19 | * Base collector. 20 | * 21 | * @param the type 22 | */ 23 | public abstract class AbstractCollector implements Collector { 24 | 25 | @Override 26 | public void combine(Object object) { 27 | // Do nothing. This is the default Implementation. 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/CustomErrorMessageType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Network New Technologies Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.networknt.schema; 18 | 19 | public class CustomErrorMessageType implements ErrorMessageType { 20 | private final String errorCode; 21 | 22 | private CustomErrorMessageType(String errorCode) { 23 | this.errorCode = errorCode; 24 | } 25 | 26 | public static ErrorMessageType of(String errorCode) { 27 | return new CustomErrorMessageType(errorCode); 28 | } 29 | 30 | @Override 31 | public String getErrorCode() { 32 | return errorCode; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/InputFormat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema; 17 | 18 | /** 19 | * The input data format. 20 | */ 21 | public enum InputFormat { 22 | /** 23 | * JSON. 24 | */ 25 | JSON, 26 | 27 | /** 28 | * YAML. 29 | */ 30 | YAML 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/JsonSchemaRef.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Network New Technologies Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema; 17 | 18 | import java.util.function.Supplier; 19 | 20 | /** 21 | * Use this object instead a JsonSchema for references. 22 | */ 23 | public class JsonSchemaRef { 24 | 25 | private final Supplier schemaSupplier; 26 | 27 | public JsonSchemaRef(Supplier schema) { 28 | this.schemaSupplier = schema; 29 | } 30 | 31 | public JsonSchema getSchema() { 32 | return this.schemaSupplier.get(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/JsonSchemaVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema; 17 | 18 | /** 19 | * Json schema version. 20 | */ 21 | public interface JsonSchemaVersion { 22 | /** 23 | * Gets the meta-schema. 24 | * 25 | * @return the instance 26 | */ 27 | JsonMetaSchema getInstance(); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/KeywordFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema; 17 | 18 | /** 19 | * Factory for {@link Keyword}. 20 | */ 21 | @FunctionalInterface 22 | public interface KeywordFactory { 23 | /** 24 | * Gets the keyword given the keyword value. 25 | * 26 | * @param value the keyword value 27 | * @param validationContext the validationContext 28 | * @return the keyword 29 | */ 30 | Keyword getKeyword(String value, ValidationContext validationContext); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/ThresholdMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Network New Technologies Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.networknt.schema; 18 | 19 | import com.fasterxml.jackson.databind.JsonNode; 20 | 21 | public interface ThresholdMixin { 22 | boolean crossesThreshold(JsonNode node); 23 | 24 | String thresholdValue(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/VocabularyFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema; 17 | 18 | /** 19 | * Factory for {@link Vocabulary}. 20 | */ 21 | @FunctionalInterface 22 | public interface VocabularyFactory { 23 | /** 24 | * Gets the vocabulary given the vocabulary iri. 25 | * 26 | * @param iri the vocabulary iri 27 | * @return the vocabulary 28 | */ 29 | Vocabulary getVocabulary(String iri); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/DateFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import java.time.LocalDate; 4 | import java.time.format.DateTimeParseException; 5 | 6 | import com.networknt.schema.ExecutionContext; 7 | import com.networknt.schema.Format; 8 | 9 | /** 10 | * Format for date. 11 | */ 12 | public class DateFormat implements Format { 13 | @Override 14 | public boolean matches(ExecutionContext executionContext, String value) { 15 | try { 16 | LocalDate date = LocalDate.parse(value); 17 | int year = date.getYear(); 18 | return 0 <= year && year <= 9999; 19 | } catch (DateTimeParseException e) { 20 | return false; 21 | } 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "date"; 27 | } 28 | 29 | @Override 30 | public String getMessageKey() { 31 | return "format.date"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/IdnEmailFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import com.networknt.org.apache.commons.validator.routines.EmailValidator; 4 | import com.networknt.schema.ExecutionContext; 5 | import com.networknt.schema.Format; 6 | 7 | /** 8 | * Format for idn-email. 9 | */ 10 | public class IdnEmailFormat implements Format { 11 | private final EmailValidator emailValidator; 12 | 13 | public IdnEmailFormat() { 14 | this(new IPv6AwareEmailValidator(true, true)); 15 | } 16 | 17 | public IdnEmailFormat(EmailValidator emailValidator) { 18 | this.emailValidator = emailValidator; 19 | } 20 | 21 | @Override 22 | public boolean matches(ExecutionContext executionContext, String value) { 23 | return this.emailValidator.isValid(value); 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return "idn-email"; 29 | } 30 | 31 | @Override 32 | public String getMessageKey() { 33 | return "format.idn-email"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/IdnHostnameFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import com.networknt.schema.ExecutionContext; 4 | import com.networknt.schema.Format; 5 | import com.networknt.schema.utils.RFC5892; 6 | 7 | /** 8 | * Format for idn-hostname. 9 | */ 10 | public class IdnHostnameFormat implements Format { 11 | @Override 12 | public boolean matches(ExecutionContext executionContext, String value) { 13 | if (null == value || value.isEmpty()) return true; 14 | return RFC5892.isValid(value); 15 | } 16 | 17 | @Override 18 | public String getName() { 19 | return "idn-hostname"; 20 | } 21 | 22 | @Override 23 | public String getMessageKey() { 24 | return "format.idn-hostname"; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/IriFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import java.net.URI; 4 | 5 | /** 6 | * Format for iri. 7 | */ 8 | public class IriFormat extends AbstractRFC3986Format { 9 | @Override 10 | protected boolean validate(URI uri) { 11 | boolean result = uri.isAbsolute(); 12 | if (result) { 13 | String authority = uri.getAuthority(); 14 | if (authority != null) { 15 | if (IPv6Format.PATTERN.matcher(authority).matches() ) { 16 | return false; 17 | } 18 | } 19 | 20 | String query = uri.getRawQuery(); 21 | if (query != null) { 22 | // [ and ] must be percent encoded 23 | if (query.indexOf('[') != -1 || query.indexOf(']') != -1) { 24 | return false; 25 | } 26 | } 27 | } 28 | return result; 29 | } 30 | 31 | @Override 32 | public String getName() { 33 | return "iri"; 34 | } 35 | 36 | @Override 37 | public String getMessageKey() { 38 | return "format.iri"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/IriReferenceFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import java.net.URI; 4 | 5 | /** 6 | * Format for iri-reference. 7 | */ 8 | public class IriReferenceFormat extends AbstractRFC3986Format { 9 | @Override 10 | protected boolean validate(URI uri) { 11 | String authority = uri.getAuthority(); 12 | if (authority != null) { 13 | if (IPv6Format.PATTERN.matcher(authority).matches() ) { 14 | return false; 15 | } 16 | } 17 | String query = uri.getRawQuery(); 18 | if (query != null) { 19 | // [ and ] must be percent encoded 20 | return query.indexOf('[') == -1 && query.indexOf(']') == -1; 21 | } 22 | return true; 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "iri-reference"; 28 | } 29 | 30 | @Override 31 | public String getMessageKey() { 32 | return "format.iri-reference"; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/UriFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import java.net.URI; 4 | 5 | /** 6 | * Format for uri. 7 | */ 8 | public class UriFormat extends AbstractRFC3986Format { 9 | @Override 10 | protected boolean validate(URI uri) { 11 | boolean result = uri.isAbsolute(); 12 | if (result) { 13 | // Java URI accepts non ASCII characters and this is not a valid in RFC3986 14 | result = uri.toString().codePoints().allMatch(ch -> ch < 0x7F); 15 | if (result) { 16 | String query = uri.getRawQuery(); 17 | if (query != null) { 18 | // [ and ] must be percent encoded 19 | if (query.indexOf('[') != -1 || query.indexOf(']') != -1) { 20 | return false; 21 | } 22 | } 23 | } 24 | } 25 | return result; 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return "uri"; 31 | } 32 | 33 | @Override 34 | public String getMessageKey() { 35 | return "format.uri"; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/format/UriReferenceFormat.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.format; 2 | 3 | import java.net.URI; 4 | 5 | /** 6 | * Format for uri-reference. 7 | */ 8 | public class UriReferenceFormat extends AbstractRFC3986Format { 9 | @Override 10 | protected boolean validate(URI uri) { 11 | // Java URI accepts non ASCII characters and this is not a valid in RFC3986 12 | boolean result = uri.toString().codePoints().allMatch(ch -> ch < 0x7F); 13 | if (result) { 14 | String query = uri.getRawQuery(); 15 | if (query != null) { 16 | // [ and ] must be percent encoded 17 | if (query.indexOf('[') != -1 || query.indexOf(']') != -1) { 18 | return false; 19 | } 20 | } 21 | } 22 | return result; 23 | } 24 | 25 | @Override 26 | public String getName() { 27 | return "uri-reference"; 28 | } 29 | 30 | @Override 31 | public String getMessageKey() { 32 | return "format.uri-reference"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/i18n/MessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema.i18n; 17 | 18 | /** 19 | * Formats messages with arguments. 20 | */ 21 | @FunctionalInterface 22 | public interface MessageFormatter { 23 | /** 24 | * Formats a message with arguments. 25 | * 26 | * @param args the arguments 27 | * @return the message 28 | */ 29 | String format(Object... args); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/regex/JDKRegularExpression.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.regex; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | /** 6 | * JDK {@link RegularExpression}. 7 | */ 8 | class JDKRegularExpression implements RegularExpression { 9 | private final Pattern pattern; 10 | 11 | JDKRegularExpression(String regex) { 12 | this.pattern = Pattern.compile(regex); 13 | } 14 | 15 | @Override 16 | public boolean matches(String value) { 17 | /* 18 | * Note that the matches function is not used here as it implicitly adds anchors 19 | */ 20 | return this.pattern.matcher(value).find(); 21 | } 22 | } -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/regex/RegularExpression.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.regex; 2 | 3 | import com.networknt.schema.ValidationContext; 4 | 5 | /** 6 | * Regular expression. 7 | */ 8 | @FunctionalInterface 9 | public interface RegularExpression { 10 | boolean matches(String value); 11 | 12 | static RegularExpression compile(String regex, ValidationContext validationContext) { 13 | if (null == regex) return s -> true; 14 | return validationContext.getConfig().getRegularExpressionFactory().getRegularExpression(regex); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/regex/RegularExpressionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema.regex; 17 | 18 | /** 19 | * Factory for {@link RegularExpression}. 20 | */ 21 | public interface RegularExpressionFactory { 22 | /** 23 | * Gets a {@link RegularExpression}. 24 | * 25 | * @param regex the regular expression text value 26 | * @return the regular expression 27 | */ 28 | RegularExpression getRegularExpression(String regex); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/resource/InputStreamSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema.resource; 17 | 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | 21 | /** 22 | * InputStream source. 23 | */ 24 | @FunctionalInterface 25 | public interface InputStreamSource { 26 | /** 27 | * Opens a new inputstream to the resource. 28 | * 29 | * @return a new inputstream 30 | * @throws IOException if an I/O error occurs 31 | */ 32 | InputStream getInputStream() throws IOException; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/resource/PrefixSchemaMapper.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.resource; 2 | 3 | import com.networknt.schema.AbsoluteIri; 4 | 5 | /** 6 | * Prefix implementation of {@link SchemaMapper}. 7 | */ 8 | public class PrefixSchemaMapper implements SchemaMapper { 9 | private final String source; 10 | private final String replacement; 11 | 12 | public PrefixSchemaMapper(String source, String replacement) { 13 | this.source = source; 14 | this.replacement = replacement; 15 | } 16 | 17 | @Override 18 | public AbsoluteIri map(AbsoluteIri absoluteIRI) { 19 | String absoluteIRIString = absoluteIRI != null ? absoluteIRI.toString() : null; 20 | if (absoluteIRIString != null && absoluteIRIString.startsWith(source)) { 21 | return AbsoluteIri.of(replacement + absoluteIRIString.substring(source.length())); 22 | } 23 | return null; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/resource/SchemaLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema.resource; 17 | 18 | import com.networknt.schema.AbsoluteIri; 19 | 20 | /** 21 | * Schema Loader used to load a schema given the retrieval IRI. 22 | */ 23 | @FunctionalInterface 24 | public interface SchemaLoader { 25 | /** 26 | * Loads a schema given the retrieval IRI. 27 | * 28 | * @param absoluteIri the retrieval IRI 29 | * @return the input stream source 30 | */ 31 | InputStreamSource getSchema(AbsoluteIri absoluteIri); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/serialization/node/JsonLocationAware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.networknt.schema.serialization.node; 17 | 18 | import com.fasterxml.jackson.core.JsonLocation; 19 | 20 | /** 21 | * JsonNodes that are aware of the token location will implement this interface. 22 | */ 23 | public interface JsonLocationAware { 24 | /** 25 | * Gets the token location. 26 | * 27 | * @return the token location 28 | */ 29 | JsonLocation tokenLocation(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Network New Technologies Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.networknt.schema.utils; 18 | 19 | public final class StringUtils { 20 | 21 | private StringUtils() { 22 | } 23 | 24 | public static boolean isBlank(String s) { 25 | return null == s || s.trim().isEmpty(); 26 | } 27 | 28 | public static boolean isNotBlank(String s) { 29 | return null != s && !s.trim().isEmpty(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/walk/JsonSchemaWalkListener.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.walk; 2 | 3 | import com.networknt.schema.ValidationMessage; 4 | 5 | import java.util.Set; 6 | 7 | /** 8 | * 9 | * Listener class that captures walkStart and walkEnd events. 10 | * 11 | */ 12 | public interface JsonSchemaWalkListener { 13 | 14 | WalkFlow onWalkStart(WalkEvent walkEvent); 15 | 16 | void onWalkEnd(WalkEvent walkEvent, Set validationMessages); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/walk/WalkFlow.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.walk; 2 | 3 | public enum WalkFlow { 4 | 5 | SKIP("SkipWalk", "Skip only the walk method, but continue invoking the other listeners"), 6 | 7 | ABORT("Abort", "Aborts all the walk listeners and walk method itself"), 8 | 9 | CONTINUE("ContinueToWalk", "continue to invoke the walk method and other listeners"); 10 | 11 | private final String name; 12 | 13 | private final String description; 14 | 15 | WalkFlow(String name, String description) { 16 | this.name = name; 17 | this.description = description; 18 | } 19 | 20 | public String getName() { 21 | return this.name; 22 | } 23 | 24 | public String getDescription() { 25 | return this.description; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/networknt/schema/walk/WalkListenerRunner.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema.walk; 2 | 3 | import com.fasterxml.jackson.databind.JsonNode; 4 | import com.networknt.schema.ExecutionContext; 5 | import com.networknt.schema.JsonNodePath; 6 | import com.networknt.schema.JsonSchema; 7 | import com.networknt.schema.JsonValidator; 8 | import com.networknt.schema.ValidationMessage; 9 | 10 | import java.util.Set; 11 | 12 | public interface WalkListenerRunner { 13 | 14 | boolean runPreWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, 15 | JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator); 16 | 17 | void runPostWalkListeners(ExecutionContext executionContext, String keyword, JsonNode instanceNode, 18 | JsonNode rootNode, JsonNodePath instanceLocation, JsonSchema schema, JsonValidator validator, Set validationMessages); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/native-image/com.networknt/json-schema-validator/native-image.properties: -------------------------------------------------------------------------------- 1 | Args = -H:ReflectionConfigurationResources=${.}/reflect-config.json \ 2 | -H:ResourceConfigurationResources=${.}/resource-config.json 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/native-image/com.networknt/json-schema-validator/reflect-config.json: -------------------------------------------------------------------------------- 1 | [ 2 | ] 3 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/native-image/com.networknt/json-schema-validator/resource-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resources": { 3 | "includes": [ 4 | { 5 | "pattern": "draft/.*" 6 | }, 7 | { 8 | "pattern": "draft-04/.*" 9 | }, 10 | { 11 | "pattern": "draft-06/.*" 12 | }, 13 | { 14 | "pattern": "draft-07/.*" 15 | }, 16 | { 17 | "pattern": "ucd/.*" 18 | }, 19 | { 20 | "pattern": "jsv-messages.*properties" 21 | } 22 | ] 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/draft/2019-09/meta/content: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/meta/content", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/content": true 6 | }, 7 | "$recursiveAnchor": true, 8 | 9 | "title": "Content vocabulary meta-schema", 10 | 11 | "type": ["object", "boolean"], 12 | "properties": { 13 | "contentMediaType": { "type": "string" }, 14 | "contentEncoding": { "type": "string" }, 15 | "contentSchema": { "$recursiveRef": "#" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/draft/2019-09/meta/format: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/meta/format", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/format": true 6 | }, 7 | "$recursiveAnchor": true, 8 | 9 | "title": "Format vocabulary meta-schema", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "format": { "type": "string" } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/resources/draft/2019-09/meta/meta-data: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/meta/meta-data", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/meta-data": true 6 | }, 7 | "$recursiveAnchor": true, 8 | 9 | "title": "Meta-data vocabulary meta-schema", 10 | 11 | "type": ["object", "boolean"], 12 | "properties": { 13 | "title": { 14 | "type": "string" 15 | }, 16 | "description": { 17 | "type": "string" 18 | }, 19 | "default": true, 20 | "deprecated": { 21 | "type": "boolean", 22 | "default": false 23 | }, 24 | "readOnly": { 25 | "type": "boolean", 26 | "default": false 27 | }, 28 | "writeOnly": { 29 | "type": "boolean", 30 | "default": false 31 | }, 32 | "examples": { 33 | "type": "array", 34 | "items": true 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/draft/2020-12/meta/content: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/content", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/content": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Content vocabulary meta-schema", 10 | 11 | "type": ["object", "boolean"], 12 | "properties": { 13 | "contentEncoding": { "type": "string" }, 14 | "contentMediaType": { "type": "string" }, 15 | "contentSchema": { "$dynamicRef": "#meta" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/resources/draft/2020-12/meta/format-annotation: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/format-annotation": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Format vocabulary meta-schema for annotation results", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "format": { "type": "string" } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/resources/draft/2020-12/meta/meta-data: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/meta-data", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/meta-data": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Meta-data vocabulary meta-schema", 10 | 11 | "type": ["object", "boolean"], 12 | "properties": { 13 | "title": { 14 | "type": "string" 15 | }, 16 | "description": { 17 | "type": "string" 18 | }, 19 | "default": true, 20 | "deprecated": { 21 | "type": "boolean", 22 | "default": false 23 | }, 24 | "readOnly": { 25 | "type": "boolean", 26 | "default": false 27 | }, 28 | "writeOnly": { 29 | "type": "boolean", 30 | "default": false 31 | }, 32 | "examples": { 33 | "type": "array", 34 | "items": true 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/draft/2020-12/meta/unevaluated: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/unevaluated": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Unevaluated applicator vocabulary meta-schema", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "unevaluatedItems": { "$dynamicRef": "#meta" }, 13 | "unevaluatedProperties": { "$dynamicRef": "#meta" } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_cs.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_cs.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_da.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_da.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_de.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_en.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_en.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_fi.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_fi.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_fr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_fr.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_hu.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_hu.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_it.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_it.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_nb.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_nb.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_nl.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_nl.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_pl.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_pl.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_pt.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_pt.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_ro.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_ro.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_ru.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_ru.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_sk.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_sk.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_sv.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_sv.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_tr.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_tr.properties -------------------------------------------------------------------------------- /src/main/resources/jsv-messages_vi.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/networknt/json-schema-validator/a3c0dacf03ffd6390ca1a8003e0d52932836af05/src/main/resources/jsv-messages_vi.properties -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/CustomMessageTest.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import com.networknt.schema.SpecVersion.VersionFlag; 4 | 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.DynamicNode; 7 | import org.junit.jupiter.api.TestFactory; 8 | 9 | import java.util.stream.Stream; 10 | 11 | @DisplayName("Custom Messages") 12 | class CustomMessageTest extends AbstractJsonSchemaTestSuite { 13 | 14 | @TestFactory 15 | @DisplayName("Draft 2019-09 - Custom Messages Enabled") 16 | Stream draft201909__customMessagesEnabled() { 17 | return createTests(VersionFlag.V201909, "src/test/resources/schema/customMessageTests/custom-message-tests.json"); 18 | } 19 | 20 | @TestFactory 21 | @DisplayName("Draft 2019-09 - Custom Messages Disabled") 22 | Stream draft201909__customMessagesDisabled() { 23 | return createTests(VersionFlag.V201909, "src/test/resources/schema/customMessageTests/custom-message-disabled-tests.json"); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/Issue314Test.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import java.io.InputStream; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class Issue314Test { 8 | private static final JsonSchemaFactory FACTORY = 9 | JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) 10 | .metaSchema( 11 | JsonMetaSchema.builder( 12 | "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", 13 | JsonMetaSchema.getV7()) 14 | .build()) 15 | .build(); 16 | 17 | @Test 18 | void testNormalizeHttpOnly() { 19 | String schemaPath = "/schema/issue314-v7.json"; 20 | InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); 21 | JsonSchema schema = FACTORY.getSchema(schemaInputStream); 22 | 23 | Assertions.assertNotNull(schema); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/Issue347Test.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import static org.hamcrest.CoreMatchers.instanceOf; 4 | import static org.hamcrest.MatcherAssert.assertThat; 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | import static org.junit.jupiter.api.Assertions.assertThrows; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | class Issue347Test { 11 | 12 | @Test 13 | void failure() { 14 | JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); 15 | assertThrows(JsonSchemaException.class, () -> factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json"))); 16 | try { 17 | factory.getSchema(Thread.currentThread().getContextClassLoader().getResourceAsStream("schema/issue347-v7.json")); 18 | } catch (Throwable e) { 19 | assertThat(e, instanceOf(JsonSchemaException.class)); 20 | assertEquals("/$id: 'test' is not a valid $id", e.getMessage()); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/Issue518Test.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import java.io.InputStream; 7 | 8 | class Issue518Test { 9 | private static final JsonMetaSchema igluMetaSchema = 10 | JsonMetaSchema 11 | .builder("http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", JsonMetaSchema.getV7()) 12 | .build(); 13 | 14 | private static final JsonSchemaFactory FACTORY = 15 | JsonSchemaFactory 16 | .builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)) 17 | .metaSchema(igluMetaSchema) 18 | .build(); 19 | 20 | @Test 21 | void testPreservingEmptyFragmentSuffix() { 22 | String schemaPath = "/schema/issue518-v7.json"; 23 | InputStream schemaInputStream = getClass().getResourceAsStream(schemaPath); 24 | JsonSchema schema = FACTORY.getSchema(schemaInputStream); 25 | 26 | Assertions.assertNotNull(schema); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/Issue532Test.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import static org.junit.jupiter.api.Assertions.assertEquals; 5 | import static org.junit.jupiter.api.Assertions.assertThrows; 6 | 7 | class Issue532Test { 8 | @Test 9 | void failure() { 10 | JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); 11 | JsonSchemaException ex = assertThrows(JsonSchemaException.class, () -> { 12 | factory.getSchema("{ \"$schema\": true }"); 13 | }); 14 | assertEquals("Unknown MetaSchema: true", ex.getMessage()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/Issue604Test.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 7 | 8 | class Issue604Test { 9 | @Test 10 | void failure() { 11 | SchemaValidatorsConfig config = SchemaValidatorsConfig.builder() 12 | .applyDefaultsStrategy(new ApplyDefaultsStrategy(true, false, false)) 13 | .build(); 14 | JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7); 15 | JsonSchema schema = factory.getSchema("{ \"type\": \"object\", \"properties\": { \"foo\": { \"type\": \"object\", \"properties\": { \"bar\": { \"type\": \"boolean\", \"default\": false } } } } }", config); 16 | ObjectMapper objectMapper = new ObjectMapper(); 17 | assertDoesNotThrow(() -> { 18 | schema.walk(objectMapper.readTree("{}"), false); 19 | }); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/NotAllowedValidatorTest.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | 6 | /** 7 | * This class test {@link NotAllowedValidator}, 8 | * above-mentioned validator check that schema defined json should not be there in JSON object 9 | */ 10 | class NotAllowedValidatorTest extends AbstractJsonSchemaTest { 11 | 12 | @Override 13 | protected String getDataTestFolder() { 14 | return "/data/notAllowedValidation/"; 15 | } 16 | 17 | 18 | /** 19 | * This test case checks that NotAllowedValidator is working with latest code and able to identify field. 20 | */ 21 | @Test 22 | void testNotAllowedValidatorWorks() { 23 | assertValidatorType("notAllowedJson.json", ValidatorTypeCode.NOT_ALLOWED); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/PropertiesTest.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import com.networknt.schema.SpecVersion.VersionFlag; 4 | 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.DynamicNode; 7 | import org.junit.jupiter.api.TestFactory; 8 | 9 | import java.util.stream.Stream; 10 | 11 | @DisplayName("Properties") 12 | class PropertiesTest extends AbstractJsonSchemaTestSuite { 13 | 14 | @TestFactory 15 | @DisplayName("Draft 2019-09") 16 | Stream draft201909() { 17 | return createTests(VersionFlag.V201909, "src/test/resources/draft2019-09/properties.json"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/UnevaluatedItemsTest.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import com.networknt.schema.SpecVersion.VersionFlag; 4 | import org.junit.jupiter.api.DisplayName; 5 | import org.junit.jupiter.api.DynamicNode; 6 | import org.junit.jupiter.api.TestFactory; 7 | 8 | import java.util.stream.Stream; 9 | 10 | @DisplayName("Unevaluated Items") 11 | class UnevaluatedItemsTest extends AbstractJsonSchemaTestSuite { 12 | 13 | @TestFactory 14 | @DisplayName("Draft 2019-09") 15 | Stream draft201909() { 16 | return createTests(VersionFlag.V201909, "src/test/resources/schema/unevaluatedTests/unevaluated-items-tests.json"); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/com/networknt/schema/UnevaluatedPropertiesTest.java: -------------------------------------------------------------------------------- 1 | package com.networknt.schema; 2 | 3 | import com.networknt.schema.SpecVersion.VersionFlag; 4 | 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.DynamicNode; 7 | import org.junit.jupiter.api.TestFactory; 8 | 9 | import java.util.stream.Stream; 10 | 11 | @DisplayName("Unevaluated Properties") 12 | class UnevaluatedPropertiesTest extends AbstractJsonSchemaTestSuite { 13 | 14 | @TestFactory 15 | @DisplayName("Draft 2019-09") 16 | Stream draft201909() { 17 | return createTests(VersionFlag.V201909, "src/test/resources/schema/unevaluatedTests/unevaluated-tests.json"); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/const-messages-override.properties: -------------------------------------------------------------------------------- 1 | const = {0}: must be the constant value ''{1}'' but is ''{2}'' -------------------------------------------------------------------------------- /src/test/resources/data/OverwritingCustomMessageBug.json: -------------------------------------------------------------------------------- 1 | { 2 | "toplevel": [ 3 | { 4 | "foos": "foo", 5 | "Nope": "a", 6 | "bars": "bar" 7 | }, 8 | { 9 | "foos": "fee", 10 | "Nope": "b", 11 | "bars": "baz" 12 | }, 13 | { 14 | "foos": "foo", 15 | "Nope": "c", 16 | "bars": "bar" 17 | } 18 | ] 19 | } -------------------------------------------------------------------------------- /src/test/resources/data/contains/issue769/max-contains-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "/schema/contains/issue769/max-contains-v7.json", 3 | "myArray": [ 4 | {"itemType": "type A"}, 5 | {"itemType": "type A"} 6 | ] 7 | } -------------------------------------------------------------------------------- /src/test/resources/data/contains/issue769/max-contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "/schema/contains/issue769/max-contains.json", 3 | "myArray": [ 4 | {"itemType": "type A"}, 5 | {"itemType": "type A"} 6 | ] 7 | } -------------------------------------------------------------------------------- /src/test/resources/data/contains/issue769/min-contains-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "/schema/contains/issue769/min-contains-v7.json", 3 | "myArray": [{"itemType": "type A"}] 4 | } -------------------------------------------------------------------------------- /src/test/resources/data/contains/issue769/min-contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "/schema/contains/issue769/min-contains.json", 3 | "myArray": [{"itemType": "type A"}] 4 | } -------------------------------------------------------------------------------- /src/test/resources/data/dstTimes.json: -------------------------------------------------------------------------------- 1 | [ 2 | "2020-03-29T02:00:00Z", 3 | "2020-09-27T02:00:00Z", 4 | "2020-03-15T02:00:00Z", 5 | "2020-03-08T02:00:00Z", 6 | "2020-03-27T02:00:00Z", 7 | "2020-08-04T02:00:00Z" 8 | ] 9 | -------------------------------------------------------------------------------- /src/test/resources/data/issue255.json: -------------------------------------------------------------------------------- 1 | { 2 | "cars": [ 3 | { 4 | } 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/data/issue295.json: -------------------------------------------------------------------------------- 1 | { "other": "stuff" } 2 | -------------------------------------------------------------------------------- /src/test/resources/data/issue313.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "field1": { 4 | "type": "invalid-type", 5 | "description": "string" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/resources/data/issue327.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "John", 3 | "lastName": "Doe", 4 | "age": 21 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/data/issue342.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "ok", 3 | "z": "nope" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/data/issue366.json: -------------------------------------------------------------------------------- 1 | { 2 | "tests": [ 3 | { 4 | "description": "first oneOf valid", 5 | "data": 1, 6 | "valid": true 7 | }, 8 | { 9 | "description": "second oneOf valid", 10 | "data": 2.5, 11 | "valid": true 12 | }, 13 | { 14 | "description": "both oneOf valid", 15 | "data": 3, 16 | "valid": false 17 | }, 18 | { 19 | "description": "neither oneOf valid", 20 | "data": 1.5, 21 | "valid": false 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue375.json: -------------------------------------------------------------------------------- 1 | { 2 | "fields": { 3 | "longName123": { 4 | "action": "doStuff" 5 | }, 6 | "a": { 7 | "action": "doMagic" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue383.json: -------------------------------------------------------------------------------- 1 | { 2 | "validation": { 3 | "all": [ 4 | { 5 | "notEmpty": { 6 | "field": "test" 7 | } 8 | } 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/data/issue396.json: -------------------------------------------------------------------------------- 1 | { 2 | "veryveryverylongallowedname": true, 3 | "a": true, 4 | "x": true, 5 | "z": false, 6 | "abc": false, 7 | "w": false, 8 | "ww": false, 9 | "WW": true 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/data/issue404.json: -------------------------------------------------------------------------------- 1 | { 2 | "bar": 1 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/data/issue426.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": {}, 3 | "foo": [ 4 | 1, 5 | 2, 6 | 3, 7 | 4 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/data/issue451.json: -------------------------------------------------------------------------------- 1 | { 2 | "allOfAttr" : { 3 | "a": "foo", 4 | "x": 1, 5 | "y": "xx" 6 | }, 7 | "anyOfAttr" : { 8 | "a": "bar", 9 | "x": 1 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue456-T2.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "abc", 3 | "details": { 4 | "__typename": "T2", 5 | "name": "Bob" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/data/issue456-T3.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "def", 3 | "details": { 4 | "__typename": "T3", 5 | "description": "Something" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/resources/data/issue461-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "properties": { 5 | "firstName": { 6 | "type": "string" 7 | }, 8 | "lastName": { 9 | "type": "string" 10 | }, 11 | "address": { 12 | "type": "object", 13 | "properties": { 14 | "street": { 15 | "type": "string" 16 | }, 17 | "city": { 18 | "type": "string" 19 | } 20 | }, 21 | "required": [ 22 | "street", 23 | "city" 24 | ] 25 | } 26 | }, 27 | "required": [ 28 | "firstName", 29 | "lastName", 30 | "address" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/test/resources/data/issue467.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": [ 3 | { 4 | "category": "book" 5 | }, 6 | { 7 | "value": "2", 8 | "category": "book" 9 | }, 10 | { 11 | "value": "3", 12 | "category": "book" 13 | }, 14 | { 15 | "value": "4", 16 | "category": "book" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/data/issue471.json: -------------------------------------------------------------------------------- 1 | { 2 | "pictures": ["url1", "url2", "url3"], 3 | "title": "this is a long title" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/data/issue493-invalid-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "parameters": [ 3 | { 4 | "name": "param-required", 5 | "value": "wrongtype" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue493-invalid-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "parameters": [ 3 | { 4 | "name": "param-required", 5 | "value": 123 6 | }, 7 | { 8 | "name": "param-optional", 9 | "value": "wrongtype" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue493-valid-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "parameters": [ 3 | { 4 | "name": "param-required", 5 | "value": 123 6 | }, 7 | { 8 | "name": "param-optional", 9 | "value": "{{test}}" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue493-valid-2.json: -------------------------------------------------------------------------------- 1 | { 2 | "parameters": [ 3 | { 4 | "name": "param-required", 5 | "value": 123 6 | }, 7 | { 8 | "name": "param-optional", 9 | "value": "{{test}}" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue500_1.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "John", 3 | "lastName": "Doe", 4 | "age": -21 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/data/issue500_2.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "John", 3 | "lastName": "Doe", 4 | "age": 15 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/data/issue606.json: -------------------------------------------------------------------------------- 1 | { 2 | "V": [ 3 | { 4 | "A": "foo", 5 | "B": "bar" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue627.json: -------------------------------------------------------------------------------- 1 | { 2 | "dateTime": "2022-07-33", 3 | "email": "inValidEmail", 4 | "uuid": "inValidUUID" 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/data/issue664.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "country": "United Kingdom", 4 | "postal_code": "UB87LL" 5 | }, 6 | { 7 | "country": "United States of America", 8 | "postal_code": "1234" 9 | } 10 | ] -------------------------------------------------------------------------------- /src/test/resources/data/issue668.json: -------------------------------------------------------------------------------- 1 | { 2 | "sub1": {}, 3 | "sub2": {}, 4 | "sub3": {} 5 | } -------------------------------------------------------------------------------- /src/test/resources/data/issue832.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "does not match", 3 | "contact": "not an email address" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/data/issue898.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": "foo3", 3 | "bar": "baz" 4 | } -------------------------------------------------------------------------------- /src/test/resources/data/notAllowedValidation/notAllowedJson.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "/schema/notAllowedValidation/notAllowedJson.json", 3 | "field1": "value1", 4 | "field2": "value2", 5 | "field3": "value3" 6 | } -------------------------------------------------------------------------------- /src/test/resources/data/output-format-input.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "x": 2.5, 4 | "y": 1.3 5 | }, 6 | { 7 | "x": 1, 8 | "z": 6.7 9 | } 10 | ] -------------------------------------------------------------------------------- /src/test/resources/data/read-only-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "George", 3 | "lastName": "Harrison" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/data/schemaTag.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-03/schema#" 3 | } -------------------------------------------------------------------------------- /src/test/resources/data/schemaTagMissing.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Test" 3 | } -------------------------------------------------------------------------------- /src/test/resources/data/walk-data-default.json: -------------------------------------------------------------------------------- 1 | { 2 | "outer": { 3 | "mixedObject": { 4 | "intValue_present": 8, 5 | "intValue_null": null 6 | }, 7 | "goodArray": ["hello", null], 8 | "badArray": ["hello", null], 9 | "reference": { 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/test/resources/data/walk-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "property1": "sample1", 3 | "property2": "sample2", 4 | "property3": { 5 | "street_address": "test-address", 6 | "phone_number": { 7 | "country-code": "091", 8 | "number": "123456789" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /src/test/resources/draft2019-09/issue375.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "title": "test", 4 | "description": "asdasdint", 5 | "type": "object", 6 | "properties": { 7 | "fields": { 8 | "type": "object", 9 | "propertyNames": { 10 | "pattern": "^[a-zA-Z]+$", 11 | "maxLength": 5, 12 | "minLength": 3 13 | }, 14 | "additionalProperties": { 15 | "type": "object", 16 | "properties": { 17 | "action": { 18 | "type": "string" 19 | } 20 | }, 21 | "additionalProperties": false, 22 | "required": [ 23 | "action" 24 | ] 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/test/resources/draft2019-09/permissive-duration.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of duration strings", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "format": "duration" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "weeks can be combined with other units", 11 | "data": "P1Y2W", 12 | "valid": true, 13 | "strictness": { 14 | "duration": false 15 | } 16 | } 17 | ] 18 | } 19 | ] 20 | -------------------------------------------------------------------------------- /src/test/resources/draft2019-09/properties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "object properties validation with required", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "properties": { 7 | "foo": {"type": "integer"}, 8 | "bar": {"type": "string"}, 9 | "hello": {"type": "string"}, 10 | "world": {"type": "string"} 11 | }, 12 | "required": [ "bar", "hello", "world" ] 13 | }, 14 | "tests": [ 15 | { 16 | "description": "required hello and world is not present", 17 | "data": {"foo": 1, "bar": "baz"}, 18 | "valid": false 19 | }, 20 | { 21 | "description": "one property invalid is invalid", 22 | "data": {"foo": 1, "bar": {}, "hello": "v", "world": "b"}, 23 | "valid": false 24 | }, 25 | { 26 | "description": "all valid", 27 | "data": {"foo": 1, "bar": "b", "hello": "c", "world": "d"}, 28 | "valid": true 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /src/test/resources/draft2019-09/schemaTag.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft2020-12/schemaTag.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/classpath/schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "Sub schema in classpath", 4 | "schema": { 5 | "id": "classpath:/draft4/extra/classpath/sub-schema.json", 6 | "type": "object", 7 | "properties": { 8 | "features": { 9 | "$ref": "#/features" 10 | } 11 | }, 12 | "additionalProperties": false 13 | }, 14 | "tests": [ 15 | { 16 | "description": "an integer is an integer", 17 | "data": { 18 | "features": 4 19 | }, 20 | "valid": true 21 | }, 22 | { 23 | "description": "a number is not an integer", 24 | "data": { 25 | "features": 4.0 26 | }, 27 | "valid": false 28 | } 29 | ] 30 | } 31 | ] -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/classpath/sub-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "features", 4 | "features": { 5 | "title": "integer feature", 6 | "type": "integer", 7 | "minimum": 1, 8 | "maximum": 99999 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/cyclic/Element.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "Element.json", 3 | "type": "object", 4 | "datatype": true, 5 | "category": "fhir", 6 | "properties": { 7 | "id": { 8 | "type": "string", 9 | "pattern": "[A-Za-z0-9\\-\\.]{1,64}" 10 | }, 11 | "extension": { 12 | "type": "array", 13 | "items": { 14 | "$ref": "Extension.json" 15 | } 16 | } 17 | }, 18 | "additionalProperties": false 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/cyclic/Extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "Extension.json", 3 | "type": "object", 4 | "datatype": true, 5 | "category": "fhir", 6 | "properties": { 7 | "url": { 8 | "type": "string", 9 | "format": "url" 10 | }, 11 | "valueElement": { 12 | "$ref": "Element.json" 13 | } 14 | }, 15 | "additionalProperties": false, 16 | "required": [ 17 | "url" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/cyclic/Master.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "Master.json", 3 | "type": "object", 4 | "datatype": true, 5 | "category": "fhir", 6 | "properties": { 7 | "element": { 8 | "$ref": "Element.json" 9 | }, 10 | "extension": { 11 | "type": "array", 12 | "items": { 13 | "$ref": "Extension.json" 14 | } 15 | } 16 | }, 17 | "additionalProperties": false 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/folder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/product/product-all-errors-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "it must be integer", 3 | "name": "too short", 4 | "price": "it should be number" 5 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/product/product-no-errors-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 1, 3 | "name": "A valid product name", 4 | "price": 99.99 5 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/product/product-one-error-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 786, 3 | "name": "too short", 4 | "price": 99.99 5 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/product/product-two-errors-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": 99.99, 3 | "name": "A valid product name", 4 | "price": 99.99 5 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/product/product.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$schema": "http://json-schema.org/draft-04/schema#", 4 | "description": "A product from Acme's catalog", 5 | "title": "Product", 6 | "properties": { 7 | "id": { 8 | "type": "integer", 9 | "description": "The unique identifier for a product" 10 | }, 11 | "name": { 12 | "type": "string", 13 | "maxLength": 200, 14 | "minLength": 10, 15 | "description": "Name of the product" 16 | }, 17 | "price": { 18 | "type": "number", 19 | "minimum": 0, 20 | "exclusiveMinimum": true 21 | } 22 | }, 23 | "required": [ 24 | "id", 25 | "name", 26 | "price" 27 | ] 28 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/property.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "id as schema", 4 | "schema": { 5 | "id": "http://localhost:1234/id_schema/schema/features.json", 6 | "title": "property object", 7 | "type": "object", 8 | "properties": { 9 | "featuresInteger": { 10 | "$ref": "#/featuresInteger" 11 | }, 12 | "featuresBoolean": { 13 | "$ref": "#/featuresBoolean" 14 | } 15 | }, 16 | "additionalProperties": false 17 | }, 18 | "tests": [ 19 | { 20 | "description": "an integer is an integer", 21 | "data": { 22 | "featuresInteger": 4, 23 | "featuresBoolean": true 24 | }, 25 | "valid": true 26 | }, 27 | { 28 | "description": "a number is not an integer", 29 | "data": { 30 | "featuresInteger": 4.0, 31 | "featuresBoolean": true 32 | }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uri_mapping/example-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uri_mapping/invalid-schema-uri.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "publicURL": "http://json-schema.org/draft-04/schema#", 4 | "localURL": "resource:/draftv4.schema.json" 5 | }, 6 | { 7 | "publicURL": "http://example.com/invalid/schema/url", 8 | "localURL": "resource:/draft4/extra/uri_mapping/example-schema.json" 9 | }, 10 | { 11 | "publicURL": "https://example.com/invalid/schema/url", 12 | "localURL": "resource:/draft4/extra/uri_mapping/example-schema.json" 13 | } 14 | 15 | ] 16 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uri_mapping/schema-with-ref-mapping.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "publicURL": "http://json-schema.org/draft-04/schema#", 4 | "localURL": "resource:/draftv4.schema.json" 5 | }, 6 | { 7 | "publicURL": "http://example.com/invalid/schema/url", 8 | "localURL": "resource:/draft4/extra/uri_mapping/example-schema.json" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uri_mapping/schema-with-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "json-object-with-schema", 4 | "type": "array", 5 | "properties": { 6 | "schema": { 7 | "$ref": "http://example.com/invalid/schema/url" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uri_mapping/uri-mapping.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "publicURL": "http://json-schema.org/draft-04/schema#", 4 | "localURL": "resource:/draftv4.schema.json" 5 | }, 6 | { 7 | "publicURL": "https://raw.githubusercontent.com/networknt/json-schema-validator/master/src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json", 8 | "localURL": "resource:/draft4/extra/uri_mapping/uri-mapping.schema.json" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uri_mapping/uri-mapping.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "json-schema-validator-uri-mapping", 4 | "type": "array", 5 | "description": "Data portion of message from JMRI to client for type \"node\"", 6 | "items": { 7 | "type": "object", 8 | "uniqueItems": true, 9 | "properties": { 10 | "publicURL": { 11 | "type": "string", 12 | "description": "Public, presumably internet-accessible, URL for schema" 13 | }, 14 | "localURL": { 15 | "type": "string", 16 | "description": "Local URL for schema that will be used when a schema references the public URL" 17 | } 18 | }, 19 | "additionalProperties": false, 20 | "required": [ 21 | "publicURL", 22 | "localURL" 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/test/resources/draft4/extra/uuid.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "uuid format validation", 4 | "schema": { 5 | "format": "uuid" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "invalid uuid", 10 | "data": "df984f5c-59bd-48e3sac87-b03d574b37e9", 11 | "valid": false 12 | }, 13 | { 14 | "description": "valid uuid string", 15 | "data": "df984f5c-59bd-48e3-ac87-b03d574b37e9", 16 | "valid": true 17 | }, 18 | { 19 | "description": "too short, it is invalid", 20 | "data": "5fc03087d-d265-11e7-b8c6-83e29cd24f", 21 | "valid": false 22 | }, 23 | { 24 | "description": "two long, length is greater than 36", 25 | "data": "5fc03087d-d265-11e7-b8c6-83e29cd24f42333", 26 | "valid": false 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /src/test/resources/draft4/idRef.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refer to subschema by a unique name ($id)", 4 | "schema": { 5 | "type": "object", 6 | "properties": { 7 | "cars": { 8 | "type": "array", 9 | "items": { 10 | "$ref": "#car" 11 | } 12 | } 13 | }, 14 | "definitions": { 15 | "car": { 16 | "id": "#car", 17 | "type": "object", 18 | "properties": { 19 | "model": { 20 | "type": "string" 21 | } 22 | }, 23 | "required": [ 24 | "model" 25 | ] 26 | } 27 | } 28 | }, 29 | "tests": [ 30 | { 31 | "description": "invalid when element referenced by id is invalid", 32 | "data": { 33 | "cars": [ 34 | { 35 | } 36 | ] 37 | }, 38 | "valid": false 39 | }, 40 | { 41 | "description": "valid when element referenced by id is valid", 42 | "data": { 43 | "cars": [ 44 | { 45 | "model": "BMW" 46 | } 47 | ] 48 | }, 49 | "valid": true 50 | } 51 | ] 52 | } 53 | ] -------------------------------------------------------------------------------- /src/test/resources/draft4/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/issue258/Element.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "Element.json", 3 | "type": "object", 4 | "datatype": true, 5 | "category": "fhir", 6 | "properties": { 7 | "id": { 8 | "type": "string", 9 | "pattern": "[A-Za-z0-9\\-\\.]{1,64}" 10 | }, 11 | "extension": { 12 | "type": "array", 13 | "items": { 14 | "$ref": "Extension.json" 15 | } 16 | } 17 | }, 18 | "additionalProperties": false 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/draft4/issue258/Extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "Extension.json", 3 | "type": "object", 4 | "datatype": true, 5 | "category": "fhir", 6 | "properties": { 7 | "url": { 8 | "type": "string", 9 | "format": "url" 10 | }, 11 | "valueElement": { 12 | "$ref": "Element.json" 13 | } 14 | }, 15 | "additionalProperties": false, 16 | "required": [ 17 | "url" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/draft4/issue258/Master.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "Master.json", 3 | "type": "object", 4 | "datatype": true, 5 | "category": "fhir", 6 | "properties": { 7 | "element": { 8 | "$ref": "Element.json" 9 | }, 10 | "extension": { 11 | "type": "array", 12 | "items": { 13 | "$ref": "Extension.json" 14 | } 15 | } 16 | }, 17 | "additionalProperties": false 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/draft4/refRemoteSchema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "subSchemas.json#/integer" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/schemaTag.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft4/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "integer": { 3 | "type": "integer" 4 | }, 5 | "refToInteger": { 6 | "$ref": "#/integer" 7 | }, 8 | "definitions": { 9 | "a": { 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/resources/draft6/idRef.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refer to subschema by a unique name ($id)", 4 | "schema": { 5 | "type": "object", 6 | "properties": { 7 | "cars": { 8 | "type": "array", 9 | "items": { 10 | "$ref": "#car" 11 | } 12 | } 13 | }, 14 | "definitions": { 15 | "car": { 16 | "$id": "#car", 17 | "type": "object", 18 | "properties": { 19 | "model": { 20 | "type": "string" 21 | } 22 | }, 23 | "required": [ 24 | "model" 25 | ] 26 | } 27 | } 28 | }, 29 | "tests": [ 30 | { 31 | "description": "invalid when element referenced by id is invalid", 32 | "data": { 33 | "cars": [ 34 | { 35 | } 36 | ] 37 | }, 38 | "valid": false 39 | }, 40 | { 41 | "description": "valid when element referenced by id is valid", 42 | "data": { 43 | "cars": [ 44 | { 45 | "model": "BMW" 46 | } 47 | ] 48 | }, 49 | "valid": true 50 | } 51 | ] 52 | } 53 | ] -------------------------------------------------------------------------------- /src/test/resources/draft6/schemaTag.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft7/idRef.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refer to subschema by a unique name ($id)", 4 | "schema": { 5 | "type": "object", 6 | "properties": { 7 | "cars": { 8 | "type": "array", 9 | "items": { 10 | "$ref": "#car" 11 | } 12 | } 13 | }, 14 | "definitions": { 15 | "car": { 16 | "$id": "#car", 17 | "type": "object", 18 | "properties": { 19 | "model": { 20 | "type": "string" 21 | } 22 | }, 23 | "required": [ 24 | "model" 25 | ] 26 | } 27 | } 28 | }, 29 | "tests": [ 30 | { 31 | "description": "invalid when element referenced by id is invalid", 32 | "data": { 33 | "cars": [ 34 | { 35 | } 36 | ] 37 | }, 38 | "valid": false 39 | }, 40 | { 41 | "description": "valid when element referenced by id is valid", 42 | "data": { 43 | "cars": [ 44 | { 45 | "model": "BMW" 46 | } 47 | ] 48 | }, 49 | "valid": true 50 | } 51 | ] 52 | } 53 | ] -------------------------------------------------------------------------------- /src/test/resources/draft7/issue650.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "required": [ 5 | "data" 6 | ], 7 | "properties": { 8 | "data": { 9 | "$id": "#/properties/data", 10 | "type": "string" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/resources/draft7/schemaTag.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#" 3 | } -------------------------------------------------------------------------------- /src/test/resources/draft7/urn/account.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "account", 4 | "type": "object", 5 | "properties": { 6 | "first-name": { 7 | "type": "string" 8 | }, 9 | "age": { 10 | "type": "integer" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/draft7/urn/issue665.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "required": [ 5 | "myData" 6 | ], 7 | "properties": { 8 | "myData": { 9 | "$ref": "urn:data" 10 | } 11 | }, 12 | "definitions": { 13 | "data": { 14 | "$id": "urn:data", 15 | "type": "object", 16 | "required": [ 17 | "value" 18 | ], 19 | "properties": { 20 | "value": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/draft7/urn/issue665_external_urn_ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "required": [ 5 | "myData" 6 | ], 7 | "properties": { 8 | "myData": { 9 | "$ref": "urn:data" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/draft7/urn/issue665_external_urn_subschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "urn:data", 4 | "type": "object", 5 | "required": [ 6 | "value" 7 | ], 8 | "properties": { 9 | "value": { 10 | "type": "string" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/draft7/urn/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "account": { 3 | "first-name": "Test", 4 | "age": 18 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/test/resources/draft7/urn/urn.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "schema-with-urn-ref", 4 | "type": "object", 5 | "properties": { 6 | "account": { 7 | "$ref": "account" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/test/resources/issue686/translations.properties: -------------------------------------------------------------------------------- 1 | type = {0}: {1} found, {2} expected (TEST) 2 | -------------------------------------------------------------------------------- /src/test/resources/issue686/translations_de.properties: -------------------------------------------------------------------------------- 1 | type = {0}: {1} found, {2} expected (TEST) (DE) 2 | -------------------------------------------------------------------------------- /src/test/resources/issue686/translations_fr.properties: -------------------------------------------------------------------------------- 1 | type = {0}: {1} found, {2} expected (TEST) (FR) 2 | -------------------------------------------------------------------------------- /src/test/resources/issue784/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "my-date-time": { 5 | "type": "string", 6 | "format": "date-time" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/issues/662/emptyObject.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /src/test/resources/issues/662/objectInvalidValue.json: -------------------------------------------------------------------------------- 1 | { 2 | "optionalObject": { 3 | "value": "invalid" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/issues/662/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "properties": { 4 | "optionalObject": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "type": "object", 11 | "properties": { 12 | "value": { 13 | "enum": [ 14 | "one", 15 | "two" 16 | ] 17 | } 18 | }, 19 | "required": [ 20 | "value" 21 | ] 22 | } 23 | ] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/issues/662/validObject.json: -------------------------------------------------------------------------------- 1 | { 2 | "optionalObject": { 3 | "value": "one" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/test/resources/jsv-messages-override.properties: -------------------------------------------------------------------------------- 1 | allOf = {0}: overridden message {1} 2 | -------------------------------------------------------------------------------- /src/test/resources/multipleOfScale.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "by deep scale", 4 | "schema": { 5 | "multipleOf": 0.25 6 | }, 7 | "tests": [ 8 | { 9 | "description": "8.75 is multiple of 0.25", 10 | "data": 8.75, 11 | "valid": true 12 | }, 13 | { 14 | "description": "8.750000000001 is not multiple of 0.25", 15 | "data": 8.750000000001, 16 | "valid": false 17 | }, 18 | { 19 | "description": "8.7500000000001 is not multiple of 0.25", 20 | "data": 8.7500000000001, 21 | "valid": false 22 | }, 23 | { 24 | "description": "8.75000000000001 is not multiple of 0.25", 25 | "data": 8.75000000000001, 26 | "valid": false 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /src/test/resources/oas/3.1/dialect/base: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://spec.openapis.org/oas/3.1/dialect/base", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | 5 | "title": "OpenAPI 3.1 Schema Object Dialect", 6 | "description": "A JSON Schema dialect describing schemas found in OpenAPI documents", 7 | 8 | "$vocabulary": { 9 | "https://json-schema.org/draft/2020-12/vocab/core": true, 10 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 11 | "https://json-schema.org/draft/2020-12/vocab/unevaluated": true, 12 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 13 | "https://json-schema.org/draft/2020-12/vocab/meta-data": true, 14 | "https://json-schema.org/draft/2020-12/vocab/format-annotation": true, 15 | "https://json-schema.org/draft/2020-12/vocab/content": true, 16 | "https://spec.openapis.org/oas/3.1/vocab/base": false 17 | }, 18 | 19 | "$dynamicAnchor": "meta", 20 | 21 | "allOf": [ 22 | { "$ref": "https://json-schema.org/draft/2020-12/schema" }, 23 | { "$ref": "https://spec.openapis.org/oas/3.1/meta/base" } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/test/resources/oas/3.1/schema-base/2022-10-07: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://spec.openapis.org/oas/3.1/schema-base/2022-10-07", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | 5 | "description": "The description of OpenAPI v3.1.x documents using the OpenAPI JSON Schema dialect, as defined by https://spec.openapis.org/oas/v3.1.0", 6 | 7 | "$ref": "https://spec.openapis.org/oas/3.1/schema/2022-10-07", 8 | "properties": { 9 | "jsonSchemaDialect": { "$ref": "#/$defs/dialect" } 10 | }, 11 | 12 | "$defs": { 13 | "dialect": { "const": "https://spec.openapis.org/oas/3.1/dialect/base" }, 14 | 15 | "schema": { 16 | "$dynamicAnchor": "meta", 17 | "$ref": "https://spec.openapis.org/oas/3.1/dialect/base", 18 | "properties": { 19 | "$schema": { "$ref": "#/$defs/dialect" } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/prefixItemsException/prefixItemsException.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "no prefix items, exception testing", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "prefixItems": [] 7 | }, 8 | "tests": [ 9 | { 10 | "description": "zero elements", 11 | "data": [], 12 | "valid": true 13 | } 14 | ] 15 | } 16 | ] -------------------------------------------------------------------------------- /src/test/resources/remotes/folder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/resources/remotes/id_schema/property.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "id as schema", 4 | "schema": { 5 | "id": "http://localhost:1234/id_schema/schema/features.json", 6 | "title": "property object", 7 | "type": "object", 8 | "properties": { 9 | "featuresInteger": { 10 | "$ref": "#/featuresInteger" 11 | }, 12 | "featuresBoolean": { 13 | "$ref": "#/featuresBoolean" 14 | } 15 | }, 16 | "additionalProperties": false 17 | }, 18 | "tests": [ 19 | { 20 | "data": { 21 | "featuresInteger": 4, 22 | "featuresBoolean": true 23 | }, 24 | "valid": true 25 | }, 26 | { 27 | "data": { 28 | "featuresInteger": 4.0, 29 | "featuresBoolean": true 30 | }, 31 | "valid": false 32 | } 33 | ] 34 | } 35 | ] -------------------------------------------------------------------------------- /src/test/resources/remotes/id_schema/schema/features.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "features fields", 4 | "featuresBoolean": { 5 | "title": "boolean feature", 6 | "type": "boolean" 7 | }, 8 | "featuresInteger": { 9 | "title": "integer feature", 10 | "type": "integer", 11 | "minimum": 1, 12 | "maximum": 99999 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/resources/remotes/self_ref/selfRef.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://localhost:1234/self_ref/selfRef.json", 3 | "description": "Schema with ID set to its own URL" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/schema/OverwritingCustomMessageBug.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "toplevel": { 5 | "type": "array", 6 | "items": { 7 | "type": "object", 8 | "properties": { 9 | "foos": { 10 | "type": "string", 11 | "pattern": "(foo)+", 12 | "message": { 13 | "pattern": "{0}: Must be a string with the a shape foofoofoofoo... with at least one foo" 14 | } 15 | }, 16 | "Nope": { 17 | "type": "string" 18 | }, 19 | "bars": { 20 | "type": "string", 21 | "pattern": "(bar)+", 22 | "message": { 23 | "pattern": "{0}: Must be a string with the a shape barbarbar... with at least one bar" 24 | } 25 | } 26 | } 27 | }, 28 | "minItems": 1 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/test/resources/schema/common/child.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "child schema", 3 | "type": "object", 4 | "properties": { 5 | "value": { 6 | "$ref": "./child2.json" 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /src/test/resources/schema/common/child2.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "child2 schema", 3 | "type": "object", 4 | "properties": { 5 | "value": { 6 | "type": "string", 7 | "$comment": "child value." 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/test/resources/schema/contains/issue769/max-contains-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "properties": { 4 | "myArray": { 5 | "type": "array", 6 | "maxContains": 1, 7 | "contains": {"properties": {"itemType": {"const": "type A"}} 8 | }, 9 | "items": {"properties": {"itemType": {"type": "string"}}} 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/test/resources/schema/contains/issue769/max-contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "properties": { 4 | "myArray": { 5 | "type": "array", 6 | "maxContains": 1, 7 | "contains": {"properties": {"itemType": {"const": "type A"}} 8 | }, 9 | "items": {"properties": {"itemType": {"type": "string"}}} 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/test/resources/schema/contains/issue769/min-contains-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "properties": { 4 | "myArray": { 5 | "type": "array", 6 | "minContains": 2, 7 | "contains": {"properties": {"itemType": {"const": "type A"}} 8 | }, 9 | "items": {"properties": {"itemType": {"type": "string"}}} 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/test/resources/schema/contains/issue769/min-contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "properties": { 4 | "myArray": { 5 | "type": "array", 6 | "minContains": 2, 7 | "contains": {"properties": {"itemType": {"const": "type A"}} 8 | }, 9 | "items": {"properties": {"itemType": {"type": "string"}}} 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/test/resources/schema/dateTimeArray.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/dateTimeTest.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "type": "array", 5 | "items": { 6 | "type": "string", 7 | "format": "date-time" 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/test/resources/schema/example-escaped.yaml: -------------------------------------------------------------------------------- 1 | paths: 2 | /users: 3 | post: 4 | requestBody: 5 | application/json: 6 | schema: 7 | anyOf: 8 | - type: object 9 | - type: string -------------------------------------------------------------------------------- /src/test/resources/schema/example-main.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "required" : ["DriverProperties"], 5 | "properties": { 6 | "DriverProperties": { 7 | "type": "object", 8 | "properties": { 9 | "CommonProperties": { 10 | "$ref": "example-ref.json#/definitions/DriverProperties" 11 | } 12 | }, 13 | "required": ["CommonProperties"], 14 | "additionalProperties": false 15 | } 16 | }, 17 | "additionalProperties": false 18 | } -------------------------------------------------------------------------------- /src/test/resources/schema/example-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "object", 4 | "additionalProperties": false, 5 | "definitions": { 6 | "DriverProperties": { 7 | "type": "object", 8 | "properties": { 9 | "field1": { 10 | "type": "string", 11 | "minLength": 1, 12 | "maxLength": 512 13 | }, 14 | "field2": { 15 | "type": "string", 16 | "minLength": 1, 17 | "maxLength": 512 18 | } 19 | }, 20 | "required": ["field1"], 21 | "additionalProperties": false 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/test/resources/schema/id-relative.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "0", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema" 4 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue295-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/properties.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "oneOf": [ 5 | { 6 | "required": [ 7 | "requiredprop" 8 | ], 9 | "properties": { 10 | "requiredprop": { 11 | "type": "string" 12 | } 13 | } 14 | }, 15 | { 16 | "properties": { 17 | "forbiddenprop": { 18 | "type": "null" 19 | } 20 | } 21 | } 22 | ] 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue314-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", 3 | "type": "object" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue327-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "Person", 5 | "type": "object", 6 | "properties": { 7 | "firstName": { 8 | "type": "string", 9 | "description": "The person's first name." 10 | }, 11 | "lastName": { 12 | "type": "string", 13 | "description": "The person's last name." 14 | }, 15 | "age": { 16 | "description": "Age in years which must be equal to or greater than zero.", 17 | "type": "integer", 18 | "minimum": 0 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue342-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "propertyNames": { 5 | "enum": [ 6 | "a", 7 | "b", 8 | "c" 9 | ] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue347-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "test", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "description": "Test description", 5 | "properties": { 6 | "test": { 7 | "description": "Sample property", 8 | "examples": [ 9 | "hello", 10 | "world" 11 | ], 12 | "type": "string" 13 | } 14 | }, 15 | "required": [ 16 | "test" 17 | ], 18 | "type": "object" 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue366_schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | { 4 | "type": "integer" 5 | }, 6 | { 7 | "minimum": 2 8 | } 9 | ] 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue396-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "propertyNames": { 4 | "anyOf": [ 5 | { 6 | "minLength": 10 7 | }, 8 | { 9 | "$ref": "#/definitions/props" 10 | }, 11 | { 12 | "oneOf": [ 13 | { 14 | "enum": [ 15 | "z", 16 | "a", 17 | "b" 18 | ] 19 | }, 20 | { 21 | "$ref": "#/definitions/xyz" 22 | } 23 | ] 24 | } 25 | ] 26 | }, 27 | "definitions": { 28 | "props": { 29 | "minLength": 2, 30 | "pattern": "[A-Z]{2,}" 31 | }, 32 | "xyz": { 33 | "enum": [ 34 | "x", 35 | "y", 36 | "z" 37 | ] 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue404-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/address.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "type": "object", 5 | "properties": { 6 | "foo": { 7 | "type": "object", 8 | "enum": [1, 2, 3] 9 | }, 10 | "bar": { 11 | "$ref": "#/properties/foo" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue426-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "Person", 5 | "type": "object", 6 | "properties": { 7 | "firstName": { 8 | "type": "string", 9 | "description": "The person's first name." 10 | }, 11 | "foo": { 12 | "type": "array", 13 | "maxItems": 3 14 | } 15 | }, 16 | "message": { 17 | "maxItems" : "MaxItem must be 3 only", 18 | "type" : "Invalid type" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue451-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "https://example.com/issue-451.json", 4 | "title": "AllOf structuring payload", 5 | "description": "Test description", 6 | "type": "object", 7 | "properties": { 8 | "allOfAttr" : { 9 | "allOf" : [ 10 | {"$ref": "#/definitions/definition1"}, 11 | {"$ref": "#/definitions/definition2"} 12 | ] 13 | }, 14 | "anyOfAttr" : { 15 | "anyOf" : [ 16 | {"$ref": "#/definitions/definition1"}, 17 | {"$ref": "#/definitions/definition2"} 18 | ] 19 | } 20 | }, 21 | "additionalProperties": false, 22 | "definitions": { 23 | "definition1" : { 24 | "type": "object", 25 | "properties": { 26 | "a" : {"type": "string"}, 27 | "c" : {"type": "integer"} 28 | }, 29 | "additionalProperties": false 30 | }, 31 | "definition2" : { 32 | "type": "object", 33 | "properties": { 34 | "x" : {"type": "number"}, 35 | "y" : {"type": "number"} 36 | }, 37 | "required": ["x", "y"], 38 | "additionalProperties": false 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue456-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "https://example.com/issue-456.json", 4 | "title": "OneOf validates first child only", 5 | "description": "Test description", 6 | "type": "object", 7 | "properties": { 8 | "id": "string", 9 | "details": { 10 | "oneOf": [ 11 | { 12 | "type": "object", 13 | "properties": { 14 | "name": { 15 | "type": "string" 16 | }, 17 | "__typename": { 18 | "const": "T2" 19 | } 20 | }, 21 | "required": [ 22 | "name", 23 | "__typename" 24 | ] 25 | }, 26 | { 27 | "type": "object", 28 | "properties": { 29 | "description": { 30 | "type": "string" 31 | }, 32 | "__typename": { 33 | "const": "T3" 34 | } 35 | }, 36 | "required": [ 37 | "description", 38 | "__typename" 39 | ] 40 | } 41 | ] 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue467.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "title": "default_schema", 5 | "description": "Default Description", 6 | "properties": { 7 | "tags": { 8 | "type": "array", 9 | "items": [ 10 | { 11 | "type": "object", 12 | "properties": { 13 | "value" : { 14 | "type": "string" 15 | }, 16 | "category" : { 17 | "type": "string" 18 | } 19 | }, 20 | "required": [ "value" ] 21 | } 22 | ] 23 | } 24 | }, 25 | "required": [ "tags" ] 26 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue471-2019-09.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/schema", 4 | "type": "object", 5 | "properties": { 6 | "pictures":{ 7 | "type":"array", 8 | "maxItems":2, 9 | "items":{ 10 | "type":"string" 11 | } 12 | }, 13 | "title": { 14 | "type": "string", 15 | "maxLength": 10 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue500_1-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "Person", 5 | "type": "object", 6 | "properties": { 7 | "firstName": { 8 | "type": "string" 9 | }, 10 | "lastName": { 11 | "type": "string" 12 | }, 13 | "age": { 14 | "type": "integer", 15 | "minimum": 0 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue500_2-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "title": "Person", 5 | "type": "object", 6 | "properties": { 7 | "firstName": { 8 | "type": "string" 9 | }, 10 | "lastName": { 11 | "type": "string" 12 | }, 13 | "age": { 14 | "type": "integer", 15 | "minimum": 0 16 | } 17 | }, 18 | "oneOf": [ 19 | { 20 | "properties": { 21 | "firstName": { 22 | "const": "John" 23 | } 24 | } 25 | }, 26 | { 27 | "properties": { 28 | "lastName": { 29 | "const": "Doe" 30 | } 31 | } 32 | } 33 | ] 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue518-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", 3 | "type": "object" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue575-2019-09.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "https://json-schema.org/draft/2019-09/schema", 3 | "title": "Test Time Zone Schema (for testing time zones with negative offsets)", 4 | "type": "object", 5 | "properties": { 6 | "testDateTime": { 7 | "description": "A date-time value.", 8 | "type" : "string", 9 | "minLength" : 1, 10 | "maxLength" : 32, 11 | "format" : "date-time" 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue619.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "id": "resource:schema/issue619.json", 4 | "oneOf": [ 5 | { 6 | "$ref": "#/definitions/one" 7 | }, 8 | { 9 | "$ref": "#/definitions/two" 10 | } 11 | ], 12 | "definitions": { 13 | "one": { 14 | "type": "integer", 15 | "enum": [1] 16 | }, 17 | "two": { 18 | "type": "integer", 19 | "enum": [2] 20 | }, 21 | "refToOne": { 22 | "$ref": "#/definitions/one" 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue627-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "properties": { 5 | "dateTime": { 6 | "type": "string", 7 | "format": "date", 8 | "message": { 9 | "format": "Keep date format yyyy-mm-dd" 10 | } 11 | }, 12 | "uuid": { 13 | "type": "string", 14 | "format": "uuid", 15 | "message": { 16 | "format": "Input should be uuid" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue668-sub1.yml: -------------------------------------------------------------------------------- 1 | type: object -------------------------------------------------------------------------------- /src/test/resources/schema/issue668-sub2.yaml: -------------------------------------------------------------------------------- 1 | type: object -------------------------------------------------------------------------------- /src/test/resources/schema/issue668-sub3: -------------------------------------------------------------------------------- 1 | {"type": "object"} -------------------------------------------------------------------------------- /src/test/resources/schema/issue668.yml: -------------------------------------------------------------------------------- 1 | $id: resource:/schema/issue668 2 | type: object 3 | properties: 4 | sub1: 5 | $ref: issue668-sub1.yml 6 | sub2: 7 | $ref: issue668-sub2.yaml 8 | sub3: 9 | $ref: issue668-sub3 -------------------------------------------------------------------------------- /src/test/resources/schema/issue687.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/schema", 4 | "type": "object", 5 | "properties": { 6 | "foo": { "type": "string" }, 7 | "b.ar": { "type": "string" }, 8 | "children" : { 9 | "type": "array", 10 | "items": { 11 | "type": "object", 12 | "properties": { 13 | "childFoo": { "type": "string" }, 14 | "c/hildBar": { "type": "string" } 15 | } 16 | } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue832-v7.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "additionalProperties": false, 4 | "properties": { 5 | "foo": { 6 | "type": "string", 7 | "format": "no_match" 8 | }, 9 | "contact": { 10 | "type": "string", 11 | "format": "email" 12 | } 13 | }, 14 | "required": ["foo", "contact"], 15 | "type": "object" 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue898.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": { 6 | "type": "string", 7 | "enum": [ 8 | "foo1", 9 | "foo2" 10 | ] 11 | }, 12 | "bar": { 13 | "type": "string", 14 | "pattern": "(bar)+" 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/test/resources/schema/issue928-v07.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "https://json-schema.org/draft-07/schema#", 4 | "type": "object", 5 | "definitions": { 6 | "example": { 7 | "$id": "#example", 8 | "type": "string", 9 | "enum": [ 10 | "A", "B" 11 | ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue928-v2019-09.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema#", 4 | "type": "object", 5 | "definitions": { 6 | "example": { 7 | "$anchor": "example", 8 | "type": "string", 9 | "enum": [ 10 | "A", "B" 11 | ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue928-v2020-12.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/person.schema.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema#", 4 | "type": "object", 5 | "definitions": { 6 | "example": { 7 | "$anchor": "example", 8 | "type": "string", 9 | "enum": [ 10 | "A", "B" 11 | ] 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/schema/issue936.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "0", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema" 4 | } -------------------------------------------------------------------------------- /src/test/resources/schema/main/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "title": "main schema", 4 | "type": "object", 5 | "properties": { 6 | "fields": { 7 | "type": "object", 8 | "properties": { 9 | "ids": { 10 | "$ref": "../common/child.json" 11 | } 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/test/resources/schema/notAllowedValidation/notAllowedJson.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "object", 4 | "properties": { 5 | "field1": {}, 6 | "field2": {} 7 | }, 8 | "additionalProperties": false, 9 | "notAllowed": ["field3"] 10 | } -------------------------------------------------------------------------------- /src/test/resources/schema/output-format-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "https://example.com/polygon", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "point": { 6 | "type": "object", 7 | "properties": { 8 | "x": { "type": "number" }, 9 | "y": { "type": "number" } 10 | }, 11 | "additionalProperties": false, 12 | "required": [ "x", "y" ] 13 | } 14 | }, 15 | "type": "array", 16 | "items": { "$ref": "#/$defs/point" }, 17 | "minItems": 3 18 | } -------------------------------------------------------------------------------- /src/test/resources/schema/read-only-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "title": "Read Only Schema", 4 | "description": "Testing Read Only Schema Validation", 5 | "type": "object", 6 | "properties": { 7 | "firstName": { 8 | "type": "string", 9 | "readOnly": true 10 | }, 11 | "lastName": { 12 | "type": "string" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/test/resources/schema/ref-main.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "required" : ["DriverProperties"], 5 | "properties": { 6 | "DriverProperties": { 7 | "type": "object", 8 | "properties": { 9 | "CommonProperties": { 10 | "$ref": "ref-ref.json#/definitions/DriverProperties" 11 | } 12 | }, 13 | "required": ["CommonProperties"], 14 | "additionalProperties": false 15 | } 16 | }, 17 | "additionalProperties": false 18 | } -------------------------------------------------------------------------------- /src/test/resources/schema/ref-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "additionalProperties": false, 5 | "definitions": { 6 | "DriverProperties": { 7 | "type": "object", 8 | "properties": { 9 | "field1": { 10 | "type": "string", 11 | "minLength": 1, 12 | "maxLength": 512 13 | }, 14 | "field2": { 15 | "type": "string", 16 | "minLength": 1, 17 | "maxLength": 512 18 | } 19 | }, 20 | "required": ["field1"], 21 | "additionalProperties": false 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/test/resources/schema/unevaluatedTests/unevaluated-items-tests.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "unevaluatedItems should not affect sub-schemas", 4 | "schema": { 5 | "unevaluatedItems": { 6 | "type": "object" 7 | } 8 | }, 9 | "tests": [ 10 | { 11 | "description": "unevaluated item bar is in sub-schema", 12 | "data": [ 13 | { 14 | "foo": ["bar"] 15 | } 16 | ], 17 | "valid": true 18 | } 19 | ] 20 | } 21 | ] -------------------------------------------------------------------------------- /src/test/resources/selfRef.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "name": { 5 | "type": "string" 6 | }, 7 | "tree": { 8 | "$ref": "#/definitions/tree" 9 | } 10 | }, 11 | "definitions": { 12 | "tree": { 13 | "type": "object", 14 | "properties": { 15 | "value": { 16 | "type": "string" 17 | }, 18 | "branches": { 19 | "type": "array", 20 | "items": { 21 | "$ref": "#/definitions/tree" 22 | }, 23 | "minItems": 1 24 | } 25 | }, 26 | "required": [ 27 | "value" 28 | ] 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/test/resources/test-messages.properties: -------------------------------------------------------------------------------- 1 | atmostOne = english 2 | -------------------------------------------------------------------------------- /src/test/resources/test-messages_fr.properties: -------------------------------------------------------------------------------- 1 | atmostOne = french 2 | -------------------------------------------------------------------------------- /src/test/suite/.editorconfig: -------------------------------------------------------------------------------- 1 | insert_final_newline = true 2 | -------------------------------------------------------------------------------- /src/test/suite/.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Ping the entire test suite team by default. 2 | * @json-schema-org/test-suite-team 3 | -------------------------------------------------------------------------------- /src/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, arbitrarily as a time that's possibly non-busy 10 | - cron: '42 6 * * *' 11 | 12 | jobs: 13 | ci: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Set up Python 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: '3.x' 22 | - name: Install tox 23 | run: python -m pip install tox 24 | - name: Run the sanity checks 25 | run: python -m tox 26 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | "repository": "github:json-schema-org/JSON-Schema-Test-Suite", 6 | "keywords": [ 7 | "json-schema", 8 | "tests" 9 | ], 10 | "author": "http://json-schema.org", 11 | "license": "MIT" 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/suite/remotes/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/suite/remotes/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/suite/remotes/different-id-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/real-id-ref-string.json", 3 | "$defs": {"bar": {"type": "string"}}, 4 | "$ref": "#/$defs/bar" 5 | } 6 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft-next/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/next/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "description": "extendible array", 4 | "$id": "http://localhost:1234/draft-next/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/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/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/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/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/next/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/id/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "string" 4 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/applicator": true, 6 | "https://json-schema.org/draft/next/vocab/core": true 7 | }, 8 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/next/meta/applicator" }, 10 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/next/vocab/validation": true, 6 | "https://json-schema.org/draft/next/vocab/core": true, 7 | "http://localhost:1234/draft/next/vocab/custom": false 8 | }, 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/next/meta/validation" }, 11 | { "$ref": "https://json-schema.org/draft/next/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$id": "http://localhost:1234/draft-next/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/subSchemas-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "description": "tree schema, extensible", 4 | "$id": "http://localhost:1234/draft-next/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft-next/unknownKeyword/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/next/schema", 3 | "type": "string" 4 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/dependentRequired.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/dependentRequired.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "dependentRequired": { 5 | "foo": ["bar"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$id": "http://localhost:1234/draft2019-09/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/id/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "string" 4 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/ignore-prefixItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2019-09/ignore-prefixItems.json", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "prefixItems": [ 5 | {"type": "string"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/applicator": true, 6 | "https://json-schema.org/draft/2019-09/vocab/core": true 7 | }, 8 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/2019-09/meta/applicator" }, 10 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/validation": true, 6 | "https://json-schema.org/draft/2019-09/vocab/core": true, 7 | "http://localhost:1234/draft/2019-09/vocab/custom": false 8 | }, 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2019-09/meta/validation" }, 11 | { "$ref": "https://json-schema.org/draft/2019-09/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "http://localhost:1234/draft2019-09/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/subSchemas-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$schema": "https://json-schema.org/draft/2019-09/schema", 4 | "$id": "http://localhost:1234/draft2019-09/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2019-09/unknownKeyword/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "type": "string" 4 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/baseUriChange/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/baseUriChangeFolder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/baseUriChangeFolderInSubschema/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/detached-dynamicref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/detached-dynamicref.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "foo": { 6 | "$dynamicRef": "#detached" 7 | }, 8 | "detached": { 9 | "$dynamicAnchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/detached-ref.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$defs": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$anchor": "detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/extendible-dynamic-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "extendible array", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$id": "http://localhost:1234/draft2020-12/extendible-dynamic-ref.json", 5 | "type": "object", 6 | "properties": { 7 | "elements": { 8 | "type": "array", 9 | "items": { 10 | "$dynamicRef": "#elements" 11 | } 12 | } 13 | }, 14 | "required": ["elements"], 15 | "additionalProperties": false, 16 | "$defs": { 17 | "elements": { 18 | "$dynamicAnchor": "elements" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/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/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/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/meta/core" }, 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/id/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "string" 4 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "integer" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "refToInteger": { 5 | "$ref": "#foo" 6 | }, 7 | "A": { 8 | "$anchor": "foo", 9 | "type": "integer" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/metaschema-no-validation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/metaschema-no-validation.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/applicator": true, 6 | "https://json-schema.org/draft/2020-12/vocab/core": true 7 | }, 8 | "allOf": [ 9 | { "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" }, 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/metaschema-optional-vocabulary.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/validation": true, 6 | "https://json-schema.org/draft/2020-12/vocab/core": true, 7 | "http://localhost:1234/draft/2020-12/vocab/custom": false 8 | }, 9 | "allOf": [ 10 | { "$ref": "https://json-schema.org/draft/2020-12/meta/validation" }, 11 | { "$ref": "https://json-schema.org/draft/2020-12/meta/core" } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/name-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "orNull": { 5 | "anyOf": [ 6 | { 7 | "type": "null" 8 | }, 9 | { 10 | "$ref": "#" 11 | } 12 | ] 13 | } 14 | }, 15 | "type": "string" 16 | } 17 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "object", 4 | "properties": { 5 | "foo": {"$ref": "string.json"} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "string" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/prefixItems.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft2020-12/prefixItems.json", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "prefixItems": [ 5 | {"type": "string"} 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/ref-and-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "http://localhost:1234/draft2020-12/ref-and-defs.json", 4 | "$defs": { 5 | "inner": { 6 | "properties": { 7 | "bar": { "type": "string" } 8 | } 9 | } 10 | }, 11 | "$ref": "#/$defs/inner" 12 | } 13 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/subSchemas-defs.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$defs": { 4 | "integer": { 5 | "type": "integer" 6 | }, 7 | "refToInteger": { 8 | "$ref": "#/$defs/integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/tree.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "tree schema, extensible", 3 | "$schema": "https://json-schema.org/draft/2020-12/schema", 4 | "$id": "http://localhost:1234/draft2020-12/tree.json", 5 | "$dynamicAnchor": "node", 6 | 7 | "type": "object", 8 | "properties": { 9 | "data": true, 10 | "children": { 11 | "type": "array", 12 | "items": { 13 | "$dynamicRef": "#node" 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/suite/remotes/draft2020-12/unknownKeyword/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "type": "string" 4 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft6/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft6/detached-ref.json", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "definitions": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$id": "#detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft7/detached-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/detached-ref.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "definitions": { 5 | "foo": { 6 | "$ref": "#detached" 7 | }, 8 | "detached": { 9 | "$id": "#detached", 10 | "type": "integer" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/draft7/ignore-dependentRequired.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "http://localhost:1234/draft7/integer.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "dependentRequired": { 5 | "foo": ["bar"] 6 | } 7 | } -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/test/suite/remotes/id/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /src/test/suite/remotes/locationIndependentIdentifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$anchor": "foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/locationIndependentIdentifierDraft4.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/test/suite/remotes/locationIndependentIdentifierPre2019.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "refToInteger": { 4 | "$ref": "#foo" 5 | }, 6 | "A": { 7 | "$id": "#foo", 8 | "type": "integer" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/test/suite/remotes/nested-absolute-ref-to-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$defs": { 3 | "bar": { 4 | "$id": "http://localhost:1234/the-nested-id.json", 5 | "type": "string" 6 | } 7 | }, 8 | "$ref": "http://localhost:1234/the-nested-id.json" 9 | } 10 | -------------------------------------------------------------------------------- /src/test/suite/remotes/nested/foo-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "foo": {"$ref": "string.json"} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/test/suite/remotes/nested/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } 4 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/test/suite/remotes/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "integer": { 4 | "type": "integer" 5 | }, 6 | "refToInteger": { 7 | "$ref": "#/definitions/integer" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/test/suite/remotes/unknownKeyword/my_identifier.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string" 3 | } -------------------------------------------------------------------------------- /src/test/suite/remotes/urn-ref-string.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "urn:uuid:feebdaed-ffff-0000-ffff-0000deadbeef", 3 | "$defs": {"bar": {"type": "string"}}, 4 | "$ref": "#/$defs/bar" 5 | } 6 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft-next/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$ref": "https://json-schema.org/draft/next/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft-next/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft-next/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/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 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /src/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": { 5 | "$schema": "https://json-schema.org/draft/next/schema", 6 | "type": "integer", 7 | "multipleOf": 0.5 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid if optional overflow handling is implemented", 12 | "data": 1e308, 13 | "valid": true 14 | } 15 | ] 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2019-09/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$ref": "https://json-schema.org/draft/2019-09/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2019-09/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2019-09/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/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 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /src/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": { 5 | "$schema": "https://json-schema.org/draft/2019-09/schema", 6 | "type": "integer", "multipleOf": 0.5 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid if optional overflow handling is implemented", 11 | "data": 1e308, 12 | "valid": true 13 | } 14 | ] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2019-09/optional/no-schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation without $schema", 4 | "comment": "minLength is the same across all drafts", 5 | "schema": { 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a 3-character string is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a 1-character string is not valid", 16 | "data": "a", 17 | "valid": false 18 | }, 19 | { 20 | "description": "a non-string is valid", 21 | "data": 5, 22 | "valid": true 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2020-12/defs.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validate definition against metaschema", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$ref": "https://json-schema.org/draft/2020-12/schema" 7 | }, 8 | "tests": [ 9 | { 10 | "description": "valid definition schema", 11 | "data": {"$defs": {"foo": {"type": "integer"}}}, 12 | "valid": true 13 | }, 14 | { 15 | "description": "invalid definition schema", 16 | "data": {"$defs": {"foo": {"type": 1}}}, 17 | "valid": false 18 | } 19 | ] 20 | } 21 | ] 22 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2020-12/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "exclusiveMaximum": 3.0 7 | }, 8 | "tests": [ 9 | { 10 | "description": "below the exclusiveMaximum is valid", 11 | "data": 2.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 3.0, 17 | "valid": false 18 | }, 19 | { 20 | "description": "above the exclusiveMaximum is invalid", 21 | "data": 3.5, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2020-12/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "exclusiveMinimum": 1.1 7 | }, 8 | "tests": [ 9 | { 10 | "description": "above the exclusiveMinimum is valid", 11 | "data": 1.2, 12 | "valid": true 13 | }, 14 | { 15 | "description": "boundary point is invalid", 16 | "data": 1.1, 17 | "valid": false 18 | }, 19 | { 20 | "description": "below the exclusiveMinimum is invalid", 21 | "data": 0.6, 22 | "valid": false 23 | }, 24 | { 25 | "description": "ignores non-numbers", 26 | "data": "x", 27 | "valid": true 28 | } 29 | ] 30 | } 31 | ] 32 | -------------------------------------------------------------------------------- /src/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 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "$defs": { 7 | "int": { "type": "integer" } 8 | }, 9 | "allOf": [ 10 | { 11 | "properties": { 12 | "foo": { 13 | "$ref": "#/$defs/int" 14 | } 15 | } 16 | }, 17 | { 18 | "additionalProperties": { 19 | "$ref": "#/$defs/int" 20 | } 21 | } 22 | ] 23 | }, 24 | "tests": [ 25 | { 26 | "description": "passing case", 27 | "data": { "foo": 1 }, 28 | "valid": true 29 | }, 30 | { 31 | "description": "failing case", 32 | "data": { "foo": "a string" }, 33 | "valid": false 34 | } 35 | ] 36 | } 37 | ] 38 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2020-12/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to historic drafts are processed as historic drafts", 4 | "schema": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "type": "array", 7 | "$ref": "http://localhost:1234/draft2019-09/ignore-prefixItems.json" 8 | }, 9 | "tests": [ 10 | { 11 | "description": "first item not a string is valid", 12 | "comment": "if the implementation is not processing the $ref as a 2019-09 schema, this test will fail", 13 | "data": [1, 2, 3], 14 | "valid": true 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /src/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": { 5 | "$schema": "https://json-schema.org/draft/2020-12/schema", 6 | "type": "integer", 7 | "multipleOf": 0.5 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid if optional overflow handling is implemented", 12 | "data": 1e308, 13 | "valid": true 14 | } 15 | ] 16 | } 17 | ] 18 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft2020-12/optional/no-schema.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation without $schema", 4 | "comment": "minLength is the same across all drafts", 5 | "schema": { 6 | "minLength": 2 7 | }, 8 | "tests": [ 9 | { 10 | "description": "a 3-character string is valid", 11 | "data": "foo", 12 | "valid": true 13 | }, 14 | { 15 | "description": "a 1-character string is not valid", 16 | "data": "a", 17 | "valid": false 18 | }, 19 | { 20 | "description": "a non-string is valid", 21 | "data": 5, 22 | "valid": true 23 | } 24 | ] 25 | } 26 | ] 27 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 graphemes is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 grapheme is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/test/suite/tests/draft7/optional/cross-draft.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "refs to future drafts are processed as future drafts", 4 | "schema": { 5 | "type": "object", 6 | "allOf": [ 7 | { "properties": { "foo": true } }, 8 | { "$ref": "http://localhost:1234/draft2019-09/dependentRequired.json" } 9 | ] 10 | }, 11 | "tests": [ 12 | { 13 | "description": "missing bar is invalid", 14 | "comment": "if the implementation is not processing the $ref as a 2019-09 schema, this test will fail", 15 | "data": {"foo": "any value"}, 16 | "valid": false 17 | }, 18 | { 19 | "description": "present bar is valid", 20 | "data": {"foo": "any value", "bar": "also any value"}, 21 | "valid": true 22 | } 23 | ] 24 | } 25 | ] 26 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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==4.18.0a4 9 | commands = {envpython} bin/jsonschema_suite check 10 | --------------------------------------------------------------------------------