├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── core ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── everit │ │ └── json │ │ └── schema │ │ ├── ArraySchema.java │ │ ├── ArraySchemaValidatingVisitor.java │ │ ├── BooleanSchema.java │ │ ├── CollectingFailureReporter.java │ │ ├── CombinedSchema.java │ │ ├── ConditionalSchema.java │ │ ├── ConditionalSchemaValidatingVisitor.java │ │ ├── ConstSchema.java │ │ ├── EarlyFailingFailureReporter.java │ │ ├── EmptySchema.java │ │ ├── EnumSchema.java │ │ ├── FalseSchema.java │ │ ├── FormatValidator.java │ │ ├── InternalValidationException.java │ │ ├── JSONPointer.java │ │ ├── JSONPointerException.java │ │ ├── NotSchema.java │ │ ├── NullSchema.java │ │ ├── NumberComparator.java │ │ ├── NumberSchema.java │ │ ├── NumberSchemaValidatingVisitor.java │ │ ├── ObjectComparator.java │ │ ├── ObjectSchema.java │ │ ├── ObjectSchemaValidatingVisitor.java │ │ ├── PrimitiveValidationStrategy.java │ │ ├── ReadWriteContext.java │ │ ├── ReadWriteValidator.java │ │ ├── ReferenceSchema.java │ │ ├── Schema.java │ │ ├── SchemaException.java │ │ ├── SchemaLocation.java │ │ ├── StringSchema.java │ │ ├── StringSchemaValidatingVisitor.java │ │ ├── StringToValueConverter.java │ │ ├── ToStringVisitor.java │ │ ├── TrueSchema.java │ │ ├── TypeChecker.java │ │ ├── ValidatingVisitor.java │ │ ├── ValidationException.java │ │ ├── ValidationFailureReporter.java │ │ ├── Validator.java │ │ ├── Visitor.java │ │ ├── event │ │ ├── CombinedSchemaMatchEvent.java │ │ ├── CombinedSchemaMismatchEvent.java │ │ ├── CombinedSchemaValidationEvent.java │ │ ├── ConditionalSchemaMatchEvent.java │ │ ├── ConditionalSchemaMismatchEvent.java │ │ ├── ConditionalSchemaValidationEvent.java │ │ ├── MismatchEvent.java │ │ ├── SchemaReferencedEvent.java │ │ ├── ValidationEvent.java │ │ └── ValidationListener.java │ │ ├── internal │ │ ├── DateFormatValidator.java │ │ ├── DateTimeFormatValidator.java │ │ ├── EmailFormatValidator.java │ │ ├── HostnameFormatValidator.java │ │ ├── IPAddressValidator.java │ │ ├── IPV4Validator.java │ │ ├── IPV6Validator.java │ │ ├── JSONPrinter.java │ │ ├── JSONWriter.java │ │ ├── JsonPointerFormatValidator.java │ │ ├── RegexFormatValidator.java │ │ ├── RelativeJsonPointerFormatValidator.java │ │ ├── TemporalFormatValidator.java │ │ ├── TimeFormatValidator.java │ │ ├── URIFormatValidator.java │ │ ├── URIReferenceFormatValidator.java │ │ ├── URITemplateFormatValidator.java │ │ └── URIV4FormatValidator.java │ │ ├── loader │ │ ├── AdjacentSchemaExtractionState.java │ │ ├── ArraySchemaLoader.java │ │ ├── ClassPathAwareSchemaClient.java │ │ ├── CombinedSchemaLoader.java │ │ ├── ExclusiveLimitHandler.java │ │ ├── JsonArray.java │ │ ├── JsonArrayIterator.java │ │ ├── JsonObject.java │ │ ├── JsonObjectIterator.java │ │ ├── JsonPointerEvaluator.java │ │ ├── JsonValue.java │ │ ├── LoaderConfig.java │ │ ├── LoadingState.java │ │ ├── ObjectSchemaLoader.java │ │ ├── OrgJsonUtil.java │ │ ├── ProjectedJsonObject.java │ │ ├── ReferenceLookup.java │ │ ├── SchemaClient.java │ │ ├── SchemaExtractor.java │ │ ├── SchemaLoader.java │ │ ├── SpecificationVersion.java │ │ ├── StringSchemaLoader.java │ │ ├── SubschemaRegistry.java │ │ ├── Uri.java │ │ └── internal │ │ │ ├── DefaultSchemaClient.java │ │ │ ├── JSONPointer.java │ │ │ ├── ReferenceResolver.java │ │ │ ├── ResolutionScopeChangeListener.java │ │ │ ├── TypeBasedMultiplexer.java │ │ │ └── WrappingFormatValidator.java │ │ └── regexp │ │ ├── JavaUtilRegexpFactory.java │ │ ├── RE2JRegexpFactory.java │ │ ├── Regexp.java │ │ ├── RegexpFactory.java │ │ └── RegexpMatchingFailure.java │ └── test │ ├── java │ └── org │ │ └── everit │ │ └── json │ │ └── schema │ │ ├── ArraySchemaTest.java │ │ ├── BooleanSchemaTest.java │ │ ├── CollectingFailureReporterTest.java │ │ ├── CombinedSchemaTest.java │ │ ├── ConditionalSchemaEventsTest.java │ │ ├── ConditionalSchemaTest.java │ │ ├── ConstSchemaTest.java │ │ ├── DefaultAndRequiredTest.java │ │ ├── DefaultInOneOfTest.java │ │ ├── DynamicReferenceSchemaExample.java │ │ ├── EarlyFailingFailureReporterTest.java │ │ ├── EmptySchemaTest.java │ │ ├── EnumSchemaTest.java │ │ ├── FalseSchemaTest.java │ │ ├── FormatValidatorTest.java │ │ ├── InternalValidationExceptionTest.java │ │ ├── JSONMatcher.java │ │ ├── JSONPointerTest.java │ │ ├── NotSchemaTest.java │ │ ├── NullSchemaTest.java │ │ ├── NullableValidationTest.java │ │ ├── NumberComparatorTest.java │ │ ├── NumberSchemaTest.java │ │ ├── ObjectComparatorTest.java │ │ ├── ObjectSchemaTest.java │ │ ├── PointerBubblingTest.java │ │ ├── ReferenceSchemaTest.java │ │ ├── ResourceLoader.java │ │ ├── SchemaExceptionTest.java │ │ ├── SchemaLocationTest.java │ │ ├── StringSchemaTest.java │ │ ├── TestSupport.java │ │ ├── ToStringTest.java │ │ ├── TrueSchemaTest.java │ │ ├── ValidatingVisitorTest.java │ │ ├── ValidationExceptionTest.java │ │ ├── ValidatorTest.java │ │ ├── event │ │ ├── CombinedSchemaMatchEventTest.java │ │ ├── CombinedSchemaMismatchEventTest.java │ │ ├── ConditionalSchemaMatchEventTest.java │ │ ├── ConditionalSchemaMismatchEventTest.java │ │ ├── EventToStringTest.java │ │ └── SchemaReferencedEventTest.java │ │ ├── internal │ │ ├── DefaultFormatValidatorTest.java │ │ ├── JSONPrinterTest.java │ │ ├── JSONWriterTest.java │ │ ├── JsonPointerFormatValidatorTest.java │ │ ├── RelativeJsonPointerFormatValidatorTest.java │ │ ├── URIReferenceFormatValidatorTest.java │ │ ├── URITemplateFormatTest.java │ │ ├── URIV4FormatValidatorTest.java │ │ └── ValidatorTestSupport.java │ │ ├── loader │ │ ├── AdjacentSchemaExtractionStateTest.java │ │ ├── ArraySchemaLoaderTest.java │ │ ├── ClassPathAwareSchemaClientTest.java │ │ ├── CombinedSchemaLoaderTest.java │ │ ├── ConfigurationPropagationTest.java │ │ ├── CustomFormatValidatorTest.java │ │ ├── DefinesPropertyTest.java │ │ ├── ExtendTest.java │ │ ├── JsonArrayTest.java │ │ ├── JsonObjectTest.java │ │ ├── JsonPointerEvaluatorTest.java │ │ ├── JsonValueTest.java │ │ ├── LoadingStateTest.java │ │ ├── NumberSchemaLoadingTest.java │ │ ├── ObjectSchemaLoaderTest.java │ │ ├── ProjectedJsonObjectTest.java │ │ ├── ReadWriteContextLoadingTest.java │ │ ├── ReferenceLookupTest.java │ │ ├── RegisteredURIResolutionTest.java │ │ ├── ResolutionScopeTest.java │ │ ├── SchemaLoaderTest.java │ │ ├── SpecVersionDeductionTest.java │ │ ├── SpecificationVersionTest.java │ │ ├── SubschemaRegistryTest.java │ │ └── internal │ │ │ ├── ReferenceResolverTest.java │ │ │ └── TypeBasedMultiplexerTest.java │ │ └── regexp │ │ ├── JavaUtilRegexpTest.java │ │ └── RE2JRegexpTest.java │ └── resources │ ├── jsonpointer-testdoc.json │ └── org │ └── everit │ └── jsonvalidator │ ├── arraytestcases.json │ ├── arraytestschemas.json │ ├── combinedtestschemas.json │ ├── config-propagation │ ├── expected-exception.json │ ├── instance.json │ ├── remote.json │ ├── schema-by-urn.json │ └── schema.json │ ├── constobject.json │ ├── customformat-data.json │ ├── customformat-schema.json │ ├── default-and-required-schema.json │ ├── default-and-required.json │ ├── default-in-first-oneof-schema.json │ ├── default-in-last-oneof-schema.json │ ├── default-in-oneof.json │ ├── event │ ├── combined-schema-match.json │ ├── combined-schema-mismatch.json │ ├── conditional-match-if.json │ ├── conditional-match-then-boolean.json │ ├── conditional-mismatch-if.json │ ├── reference-event-with-instance.json │ ├── reference-event-with-schema.json │ └── reference-event.json │ ├── exception-to-json-with-causes.json │ ├── exception-to-json-with-schema-location.json │ ├── exception-to-json.json │ ├── https-schema-uri.json │ ├── issue345.json │ ├── merge-testcases.json │ ├── multi-pointer.json │ ├── numberschemas.json │ ├── objecttestcases.json │ ├── objecttestschemas.json │ ├── pointer-eval-non-uri-failure.json │ ├── read-write-context.json │ ├── ref-lookup-tests.json │ ├── registered-uris │ ├── ref-example-org.json │ ├── ref-urn-fragment.json │ ├── ref-urn.json │ └── schema-by-urn.json │ ├── testschemas.json │ ├── tostring │ ├── arrayschema-contains.json │ ├── arrayschema-list.json │ ├── arrayschema-tuple.json │ ├── boolean-schema.json │ ├── conditionalschema.json │ ├── custom-schema.json │ ├── draft6-schema-id.json │ ├── nonstring-schema-keyword.json │ ├── null-schema.json │ ├── numberschema.json │ ├── objectschema-default.json │ ├── objectschema-propertynames.json │ ├── objectschema-schemadep.json │ ├── objectschema-unprocessed.json │ ├── objectschema.json │ ├── ref.json │ ├── stringschema-readonly-true-writeonly-false.json │ ├── stringschema.json │ └── unrecognized-schema-keyword.json │ └── v4-referred-subschema.json ├── donate.jpg ├── pom.xml └── tests ├── android └── pom.xml ├── pom.xml ├── slim ├── pom.xml └── src │ └── test │ └── java │ └── org │ └── everit │ └── json │ └── schema │ ├── V4TestSuiteTest.java │ ├── V6TestSuiteTest.java │ └── V7TestSuiteTest.java └── vanilla ├── pom.xml └── src └── main ├── java └── org │ └── everit │ └── json │ └── schema │ ├── CustomDateTimeFormatValidator.java │ ├── EmptyObjectTest.java │ ├── EvenCharNumValidator.java │ ├── InvalidObjectInArrayTest.java │ ├── IssueServlet.java │ ├── IssueTest.java │ ├── JettyWrapper.java │ ├── MetaSchemaTest.java │ ├── RelativeURITest.java │ ├── TestCase.java │ ├── V4TestSuiteTest.java │ ├── V6TestSuiteTest.java │ └── V7TestSuiteTest.java └── resources └── org └── everit └── json └── schema ├── draft4 ├── additionalItems.json ├── additionalProperties.json ├── allOf.json ├── anyOf.json ├── default.json ├── definitions.json ├── dependencies.json ├── email.json ├── enum.json ├── format.json ├── hostname.json ├── ipv4.json ├── ipv6.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 │ ├── format.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 ├── email.json ├── enum.json ├── exclusiveMaximum.json ├── exclusiveMinimum.json ├── format.json ├── hostname.json ├── ipv4.json ├── ipv6.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 │ └── zeroTerminatedFloats.json ├── pattern.json ├── patternProperties.json ├── properties.json ├── propertyNames.json ├── ref.json ├── refRemote.json ├── required.json ├── type.json ├── uniqueItems.json └── uri-template.json ├── draft7 ├── additionalItems.json ├── additionalProperties.json ├── allOf.json ├── anyOf.json ├── boolean_schema.json ├── const.json ├── contains.json ├── date-time.json ├── date.json ├── default.json ├── definitions.json ├── dependencies.json ├── email.json ├── enum.json ├── exclusiveMaximum.json ├── exclusiveMinimum.json ├── hostname.json ├── if-then-else.json ├── ipv4.json ├── ipv6.json ├── items.json ├── json-pointer.json ├── maxItems.json ├── maxLength.json ├── maxProperties.json ├── maximum.json ├── minItems.json ├── minLength.json ├── minProperties.json ├── minimum.json ├── multipleOf.json ├── not.json ├── oneOf.json ├── optional │ ├── bignum.json │ ├── content.json │ ├── ecmascript-regex.json │ ├── idn-email.json │ ├── idn-hostname.json │ ├── iri-reference.json │ ├── iri.json │ └── zeroTerminatedFloats.json ├── pattern.json ├── patternProperties.json ├── properties.json ├── propertyNames.json ├── ref.json ├── refRemote.json ├── regex.json ├── relative-json-pointer.json ├── required.json ├── time.json ├── type.json ├── uniqueItems.json ├── uri-reference.json ├── uri-template.json └── uri.json ├── invalidobjectinarray ├── schema.json └── subject.json ├── issues ├── 78 │ ├── expected-exception.json │ ├── schema.json │ └── subject-invalid.json ├── issue125 │ ├── schema.json │ ├── subject-invalid.json │ └── validator-config.json ├── issue126 │ ├── schema.json │ └── subject-valid.json ├── issue147 │ ├── schema.json │ ├── subject-valid.json │ └── validator-config.json ├── issue152 │ ├── remotes │ │ └── customformat-schema.json │ ├── schema.json │ ├── subject-invalid.json │ └── validator-config.json ├── issue160 │ ├── schema.json │ └── subject-invalid.json ├── issue164 │ ├── remotes │ │ └── v4-schema.json │ ├── schema.json │ └── subject-valid.json ├── issue17 │ ├── remotes │ │ └── yaala │ │ │ └── _schemas │ │ │ └── parent │ ├── schema.json │ ├── subject-invalid.json │ └── subject-valid.json ├── issue174 │ ├── expected-exception.json │ ├── schema.json │ └── subject-invalid.json ├── issue182 │ ├── remotes │ │ ├── schemaA.json │ │ ├── schemaB.json │ │ └── schemaC.json │ ├── schema.json │ └── subject-valid.json ├── issue205 │ ├── schema.json │ └── subject-valid.json ├── issue206 │ ├── remotes │ │ └── references │ │ │ └── example.json │ ├── schema.json │ ├── subject-valid.json │ └── validator-config.json ├── issue217 │ ├── schema.json │ ├── subject-valid.json │ └── validator-config.json ├── issue22 │ ├── schema.json │ └── subject-invalid.json ├── issue225 │ ├── schema.json │ └── subject-invalid.json ├── issue233 │ ├── expected-exception.json │ ├── remotes │ │ └── definitions.json │ ├── schema.json │ ├── subject-invalid.json │ └── validator-config.json ├── issue245 │ ├── definitions.json │ ├── schema.json │ ├── subject-invalid.json │ └── validator-config.json ├── issue246 │ ├── expected-exception.json │ ├── schema.json │ └── subject-invalid.json ├── issue25 │ ├── schema.json │ └── subject-valid.json ├── issue258 │ ├── schema.json │ └── subject-invalid.json ├── issue260 │ ├── remotes │ │ └── example │ │ │ └── definitions │ │ │ ├── buildings.json │ │ │ └── stuff.json │ ├── schema.json │ ├── subject-invalid.json │ └── validator-config.json ├── issue270 │ ├── schema.json │ ├── subject-valid.json │ └── validator-config.json ├── issue271 │ ├── remotes │ │ └── dummy-schema.json │ ├── schema.json │ └── subject-valid.json ├── issue308 │ ├── schema.json │ ├── subject-invalid.json │ ├── subject-valid.json │ └── validator-config.json ├── issue31 │ ├── schema.json │ └── subject-valid.json ├── issue321 │ ├── remotes │ │ └── schema.json │ ├── schema.json │ └── subject-valid.json ├── issue33-2 │ ├── expected-exception.json │ ├── schema.json │ └── subject-invalid.json ├── issue33 │ ├── expected-exception.json │ ├── schema.json │ └── subject-invalid.json ├── issue35 │ ├── schema.json │ └── subject-valid.json ├── issue36 │ ├── expected-exception.json │ ├── remotes │ │ └── geo │ ├── schema.json │ └── subject-invalid.json ├── issue380 │ ├── schema.json │ └── subject-valid.json ├── issue386 │ ├── schema.json │ └── subject-valid.json ├── issue399 │ ├── schema.json │ └── subject-valid.json ├── issue400 │ ├── schema.json │ └── subject-invalid.json ├── issue41 │ ├── schema.json │ └── subject-invalid.json ├── issue428 │ ├── schema.json │ ├── subject-valid.json │ └── validator-config.json ├── issue480 │ ├── expected-exception.json │ ├── schema.json │ └── subject-invalid.json ├── issue487 │ ├── schema.json │ └── subject-invalid.json ├── issue56 │ ├── schema.json │ └── subject-valid.json ├── issue57 │ ├── schema.json │ └── subject-valid.json ├── issue62 │ ├── schema.json │ └── subject-invalid.json ├── issue65 │ ├── schema.json │ └── subject-invalid.json ├── schema.json ├── subject-valid.json ├── xissue120 │ ├── schema.json │ └── subject-invalid.json ├── xissue21 │ ├── schema.json │ └── subject-invalid.json └── xissue38 │ ├── schema.json │ └── subject-invalid.json ├── json-schema-draft-04.json ├── relative-uri └── schema │ ├── directory │ └── subschemas.json │ ├── main.json │ └── props.json └── remotes ├── folder └── folderInteger.json ├── integer.json ├── name.json └── subSchemas.json /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .classpath 4 | target 5 | .checkstyle 6 | .fbExcludeFilterFile 7 | .pmd 8 | .pmdruleset.xml 9 | .idea 10 | *.iml 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk8 4 | script: mvn verify 5 | after_success: 6 | - mvn -f core/pom.xml jacoco:report coveralls:report 7 | install: true 8 | sudo: false 9 | cache: 10 | directories: 11 | - $HOME/.m2 12 | 13 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011 Everit Kft. (http://www.everit.org) 2 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/ConstSchema.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import static org.everit.json.schema.EnumSchema.toJavaValue; 4 | 5 | public class ConstSchema extends Schema { 6 | 7 | public static class ConstSchemaBuilder extends Schema.Builder { 8 | 9 | private Object permittedValue; 10 | 11 | public ConstSchemaBuilder permittedValue(Object permittedValue) { 12 | this.permittedValue = permittedValue; 13 | return this; 14 | } 15 | 16 | @Override public ConstSchema build() { 17 | return new ConstSchema(this); 18 | } 19 | } 20 | 21 | public static ConstSchemaBuilder builder() { 22 | return new ConstSchemaBuilder(); 23 | } 24 | 25 | private final Object permittedValue; 26 | 27 | protected ConstSchema(ConstSchemaBuilder builder) { 28 | super(builder); 29 | this.permittedValue = toJavaValue(builder.permittedValue); 30 | } 31 | 32 | @Override void accept(Visitor visitor) { 33 | visitor.visitConstSchema(this); 34 | } 35 | 36 | public Object getPermittedValue() { 37 | return permittedValue; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/EarlyFailingFailureReporter.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | class EarlyFailingFailureReporter extends ValidationFailureReporter { 4 | 5 | public EarlyFailingFailureReporter(Schema schema) { 6 | super(schema); 7 | } 8 | 9 | @Override public void failure(ValidationException exc) { 10 | throw exc; 11 | } 12 | 13 | @Override public void validationFinished() { 14 | 15 | } 16 | 17 | @Override ValidationException inContextOfSchema(Schema schema, Runnable task) { 18 | try { 19 | return super.inContextOfSchema(schema, task); 20 | } catch (ValidationException e) { 21 | return e; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/FalseSchema.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | /** 4 | * @author erosb 5 | */ 6 | public class FalseSchema extends Schema { 7 | 8 | public static class Builder extends Schema.Builder { 9 | 10 | @Override public FalseSchema build() { 11 | return new FalseSchema(this); 12 | } 13 | } 14 | 15 | public static Builder builder() { 16 | return new Builder(); 17 | } 18 | 19 | public static final FalseSchema INSTANCE = FalseSchema.builder().build(); 20 | 21 | /** 22 | * Constructor. 23 | * 24 | * @param builder 25 | * the builder containing the optional title, description and id attributes of the schema 26 | */ 27 | public FalseSchema(Builder builder) { 28 | super(builder); 29 | } 30 | 31 | @Override 32 | void accept(Visitor visitor) { 33 | visitor.visitFalseSchema(this); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "false"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/InternalValidationException.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.util.List; 4 | 5 | class InternalValidationException extends ValidationException { 6 | 7 | InternalValidationException(Schema violatedSchema, Class expectedType, Object actualValue) { 8 | super(violatedSchema, expectedType, actualValue); 9 | } 10 | 11 | InternalValidationException(Schema violatedSchema, Class expectedType, Object actualValue, String keyword, 12 | String schemaLocation) { 13 | super(violatedSchema, expectedType, actualValue, keyword, schemaLocation); 14 | } 15 | 16 | InternalValidationException(Schema violatedSchema, String message, String keyword, String schemaLocation) { 17 | super(violatedSchema, message, keyword, schemaLocation); 18 | } 19 | 20 | InternalValidationException(Schema violatedSchema, StringBuilder pointerToViolation, String message, 21 | List causingExceptions, String keyword, String schemaLocation) { 22 | super(violatedSchema, pointerToViolation, message, causingExceptions, keyword, schemaLocation); 23 | } 24 | 25 | @Override 26 | public synchronized Throwable fillInStackTrace() { 27 | return this; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/NumberComparator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.math.BigDecimal; 4 | import java.math.BigInteger; 5 | import java.util.Objects; 6 | 7 | 8 | public class NumberComparator { 9 | 10 | static BigDecimal getAsBigDecimal(Object number) { 11 | if (number instanceof BigDecimal) { 12 | return (BigDecimal) number; 13 | } else if (number instanceof BigInteger) { 14 | return new BigDecimal((BigInteger) number); 15 | } else if (number instanceof Integer || number instanceof Long) { 16 | return new BigDecimal(((Number) number).longValue()); 17 | } else { 18 | double d = ((Number) number).doubleValue(); 19 | return BigDecimal.valueOf(d); 20 | } 21 | } 22 | 23 | static boolean deepEquals(Number num1, Number num2) { 24 | if (num1.getClass() != num2.getClass()) { 25 | return compare(num1, num2) == 0; 26 | } 27 | return Objects.equals(num1, num2); 28 | } 29 | 30 | static int compare(Number num1, Number num2) { 31 | return getAsBigDecimal(num1).compareTo(getAsBigDecimal(num2)); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/PrimitiveValidationStrategy.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | public enum PrimitiveValidationStrategy { 4 | STRICT, LENIENT 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/ReadWriteContext.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | public enum ReadWriteContext { 4 | READ, WRITE 5 | } 6 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/TrueSchema.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.everit.json.schema.internal.JSONPrinter; 4 | 5 | /** 6 | * @author erosb 7 | */ 8 | public class TrueSchema extends EmptySchema { 9 | 10 | public static class Builder extends EmptySchema.Builder { 11 | 12 | @Override public TrueSchema build() { 13 | return new TrueSchema(this); 14 | } 15 | } 16 | 17 | public static Builder builder() { 18 | return new Builder(); 19 | } 20 | 21 | public TrueSchema(Builder builder) { 22 | super(builder); 23 | } 24 | 25 | @Override 26 | public void describeTo(JSONPrinter writer) { 27 | writer.value(true); 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "true"; 33 | } 34 | 35 | @Override public boolean equals(Object o) { 36 | return o instanceof TrueSchema && super.equals(o); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/TypeChecker.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.math.BigInteger; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.concurrent.atomic.AtomicInteger; 7 | import java.util.concurrent.atomic.AtomicLong; 8 | 9 | 10 | class TypeChecker { 11 | private static final List> INTEGRAL_TYPES = Arrays.asList(Integer.class, Long.class, BigInteger.class, 12 | AtomicInteger.class, AtomicLong.class); 13 | 14 | static boolean isAssignableFrom(Class class1, Class class2) { 15 | if (class1.equals(Integer.class)) { 16 | return INTEGRAL_TYPES.contains(class2); 17 | } 18 | return class1.isAssignableFrom(class2); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/event/CombinedSchemaMatchEvent.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.everit.json.schema.CombinedSchema; 4 | import org.everit.json.schema.Schema; 5 | import org.json.JSONObject; 6 | 7 | public class CombinedSchemaMatchEvent extends CombinedSchemaValidationEvent { 8 | 9 | public CombinedSchemaMatchEvent(CombinedSchema schema, Schema subSchema, 10 | Object instance) { 11 | super(schema, subSchema, instance); 12 | } 13 | 14 | @Override void describeTo(JSONObject obj) { 15 | obj.put("type", "match"); 16 | obj.put("keyword", schema.getCriterion().toString()); 17 | } 18 | 19 | @Override public boolean equals(Object o) { 20 | return o instanceof CombinedSchemaMatchEvent && super.equals(o); 21 | } 22 | 23 | @Override boolean canEqual(Object o) { 24 | return o instanceof CombinedSchemaMatchEvent; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/event/CombinedSchemaValidationEvent.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import java.util.Objects; 4 | 5 | import org.everit.json.schema.CombinedSchema; 6 | import org.everit.json.schema.Schema; 7 | 8 | public abstract class CombinedSchemaValidationEvent extends ValidationEvent { 9 | 10 | final Schema subSchema; 11 | 12 | public CombinedSchemaValidationEvent(CombinedSchema schema, Schema subSchema, Object instance) { 13 | super(schema, instance); 14 | this.subSchema = subSchema; 15 | } 16 | 17 | @Override public boolean equals(Object o) { 18 | if (this == o) 19 | return true; 20 | if (!(o instanceof CombinedSchemaValidationEvent)) 21 | return false; 22 | if (!super.equals(o)) 23 | return false; 24 | CombinedSchemaValidationEvent that = (CombinedSchemaValidationEvent) o; 25 | return subSchema.equals(that.subSchema); 26 | } 27 | 28 | @Override public int hashCode() { 29 | return Objects.hash(super.hashCode(), subSchema); 30 | } 31 | 32 | public Schema getSubSchema() { 33 | return subSchema; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/event/ConditionalSchemaMatchEvent.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.everit.json.schema.ConditionalSchema; 4 | import org.json.JSONObject; 5 | 6 | public class ConditionalSchemaMatchEvent extends ConditionalSchemaValidationEvent { 7 | 8 | public ConditionalSchemaMatchEvent(ConditionalSchema schema, Object instance, Keyword keyword) { 9 | super(schema, instance, keyword); 10 | } 11 | 12 | @Override void describeTo(JSONObject obj) { 13 | obj.put("type", "match"); 14 | obj.put("keyword", keyword.toString()); 15 | } 16 | 17 | @Override public boolean equals(Object o) { 18 | return canEqual(o) && super.equals(o); 19 | } 20 | 21 | @Override boolean canEqual(Object o) { 22 | return o instanceof ConditionalSchemaMatchEvent; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/event/MismatchEvent.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.everit.json.schema.ValidationException; 4 | 5 | public interface MismatchEvent { 6 | 7 | ValidationException getFailure(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/event/SchemaReferencedEvent.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import java.util.Objects; 4 | 5 | import org.everit.json.schema.ReferenceSchema; 6 | import org.everit.json.schema.Schema; 7 | import org.json.JSONObject; 8 | 9 | public class SchemaReferencedEvent extends ValidationEvent { 10 | 11 | private final Schema referredSchema; 12 | 13 | public SchemaReferencedEvent(ReferenceSchema schema, Object instance, Schema referredSchema) { 14 | super(schema, instance); 15 | this.referredSchema = referredSchema; 16 | } 17 | 18 | @Override 19 | void describeTo(JSONObject obj) { 20 | obj.put("type", "ref"); 21 | } 22 | 23 | public Schema getReferredSchema() { 24 | return referredSchema; 25 | } 26 | 27 | @Override public boolean equals(Object o) { 28 | if (this == o) 29 | return true; 30 | if (!canEqual(o)) { 31 | return false; 32 | } 33 | if (!super.equals(o)) 34 | return false; 35 | SchemaReferencedEvent that = (SchemaReferencedEvent) o; 36 | return referredSchema.equals(that.referredSchema); 37 | } 38 | 39 | @Override public int hashCode() { 40 | return Objects.hash(super.hashCode(), referredSchema); 41 | } 42 | 43 | @Override boolean canEqual(Object o) { 44 | return o instanceof SchemaReferencedEvent; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/DateFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import java.time.format.DateTimeFormatter; 4 | import java.util.Collections; 5 | 6 | /** 7 | * Implementation of the "date" format value. 8 | */ 9 | public class DateFormatValidator extends TemporalFormatValidator { 10 | 11 | public DateFormatValidator() { 12 | super(DateTimeFormatter.ISO_LOCAL_DATE, Collections.singletonList("yyyy-MM-dd").toString()); 13 | } 14 | 15 | @Override 16 | public String formatName() { 17 | return "date"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/EmailFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import java.util.Optional; 4 | 5 | import org.apache.commons.validator.routines.EmailValidator; 6 | import org.everit.json.schema.FormatValidator; 7 | 8 | /** 9 | * Implementation of the "email" format value. 10 | */ 11 | public class EmailFormatValidator implements FormatValidator { 12 | 13 | @Override 14 | public Optional validate(final String subject) { 15 | if (EmailValidator.getInstance(false, true).isValid(subject)) { 16 | return Optional.empty(); 17 | } 18 | return Optional.of(String.format("[%s] is not a valid email address", subject)); 19 | } 20 | 21 | @Override 22 | public String formatName() { 23 | return "email"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/HostnameFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import org.apache.commons.validator.routines.DomainValidator; 4 | import org.everit.json.schema.FormatValidator; 5 | 6 | import java.util.Optional; 7 | 8 | /** 9 | * Implementation of the "hostname" format value. 10 | */ 11 | public class HostnameFormatValidator implements FormatValidator { 12 | 13 | @Override 14 | public Optional validate(final String subject) { 15 | return DomainValidator.getInstance(true).isValid(subject) && !subject.contains("_") ? 16 | Optional.empty() : 17 | Optional.of(String.format("[%s] is not a valid hostname", subject)); 18 | } 19 | 20 | @Override 21 | public String formatName() { 22 | return "hostname"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/IPV4Validator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import org.apache.commons.validator.routines.InetAddressValidator; 4 | import org.everit.json.schema.FormatValidator; 5 | 6 | import java.util.Optional; 7 | 8 | /** 9 | * Implementation of the "ipv4" format value. 10 | */ 11 | public class IPV4Validator extends IPAddressValidator implements FormatValidator { 12 | 13 | @Override 14 | public Optional validate(final String subject) { 15 | return InetAddressValidator.getInstance().isValidInet4Address(subject) ? 16 | Optional.empty() : 17 | Optional.of(String.format("[%s] is not a valid ipv4 address", subject)); 18 | } 19 | 20 | @Override 21 | public String formatName() { 22 | return "ipv4"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/IPV6Validator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import org.apache.commons.validator.routines.InetAddressValidator; 4 | import org.everit.json.schema.FormatValidator; 5 | 6 | import java.util.Optional; 7 | 8 | /** 9 | * Implementation of the "ipv6" format value. 10 | */ 11 | public class IPV6Validator extends IPAddressValidator implements FormatValidator { 12 | 13 | @Override 14 | public Optional validate(final String subject) { 15 | return (subject != null) && InetAddressValidator.getInstance().isValidInet6Address(subject) ? 16 | Optional.empty() : 17 | Optional.of(String.format("[%s] is not a valid ipv6 address", subject)); 18 | } 19 | 20 | @Override 21 | public String formatName() { 22 | return "ipv6"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/RegexFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import java.util.Optional; 4 | import java.util.regex.Pattern; 5 | import java.util.regex.PatternSyntaxException; 6 | 7 | import org.everit.json.schema.FormatValidator; 8 | 9 | public class RegexFormatValidator implements FormatValidator { 10 | 11 | @Override public Optional validate(String subject) { 12 | try { 13 | Pattern.compile(subject); 14 | } catch (PatternSyntaxException e) { 15 | return Optional.of(String.format("[%s] is not a valid regular expression", subject)); 16 | } 17 | return Optional.empty(); 18 | } 19 | 20 | @Override public String formatName() { 21 | return "regex"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/TimeFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import java.time.format.DateTimeFormatter; 4 | import java.time.format.DateTimeFormatterBuilder; 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | /** 9 | * Implementation of the "time" format value. 10 | */ 11 | public class TimeFormatValidator extends TemporalFormatValidator { 12 | private static final String FORMATS_ACCEPTED = Arrays.asList( 13 | "HH:mm:ssZ", 14 | "HH:mm:ss.[0-9]{1,9}Z", 15 | "HH:mm:ss[+-]HH:mm", 16 | "HH:mm:ss.[0-9]{1,9}[+-]HH:mm" 17 | ).toString(); 18 | 19 | private static final String PARTIAL_TIME_PATTERN = "HH:mm:ss"; 20 | 21 | private static final DateTimeFormatter FORMATTER; 22 | 23 | static { 24 | final DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder() 25 | .appendPattern(PARTIAL_TIME_PATTERN) 26 | .appendOptional(SECONDS_FRACTION_FORMATTER) 27 | .appendPattern(ZONE_OFFSET_PATTERN); 28 | 29 | FORMATTER = builder.toFormatter(); 30 | } 31 | 32 | public TimeFormatValidator() { 33 | super(FORMATTER, FORMATS_ACCEPTED); 34 | } 35 | 36 | @Override 37 | public String formatName() { 38 | return "time"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/URIReferenceFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import static java.lang.String.format; 4 | 5 | import java.net.URI; 6 | import java.net.URISyntaxException; 7 | import java.util.Optional; 8 | 9 | import org.everit.json.schema.FormatValidator; 10 | 11 | public class URIReferenceFormatValidator implements FormatValidator { 12 | 13 | @Override public Optional validate(String subject) { 14 | try { 15 | new URI(subject); 16 | return Optional.empty(); 17 | } catch (URISyntaxException e) { 18 | return failure(subject); 19 | } 20 | } 21 | 22 | protected Optional failure(String subject) { 23 | return Optional.of(format("[%s] is not a valid URI reference", subject)); 24 | } 25 | 26 | @Override public String formatName() { 27 | return "uri-reference"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/internal/URIV4FormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import java.net.URI; 4 | import java.net.URISyntaxException; 5 | import java.util.Optional; 6 | import org.everit.json.schema.FormatValidator; 7 | 8 | public class URIV4FormatValidator implements FormatValidator { 9 | 10 | @Override 11 | public Optional validate(final String subject) { 12 | try { 13 | new URI(subject); 14 | return Optional.empty(); 15 | } catch (URISyntaxException | NullPointerException e) { 16 | return failure(subject); 17 | } 18 | } 19 | 20 | protected Optional failure(String subject) { 21 | return Optional.of(String.format("[%s] is not a valid URI", subject)); 22 | } 23 | 24 | @Override public String formatName() { 25 | return "uri"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/JsonArray.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.function.Function; 8 | 9 | /** 10 | * @author erosb 11 | */ 12 | final class JsonArray extends JsonValue { 13 | 14 | private List storage; 15 | 16 | JsonArray(List storage) { 17 | super(storage); 18 | this.storage = requireNonNull(storage, "storage cannot be null"); 19 | } 20 | 21 | public void forEach(JsonArrayIterator iterator) { 22 | for (int i = 0; i < storage.size(); ++i) { 23 | JsonValue childValue = at(i); 24 | iterator.apply(i, childValue); 25 | } 26 | } 27 | 28 | protected JsonValue at(int i) { 29 | return ls.childFor(i); 30 | } 31 | 32 | public int length() { 33 | return storage.size(); 34 | } 35 | 36 | @Override public R requireArray(Function mapper) { 37 | return mapper.apply(this); 38 | } 39 | 40 | @Override 41 | protected Class typeOfValue() { 42 | return JsonArray.class; 43 | } 44 | 45 | @Override protected Object value() { 46 | return this; 47 | } 48 | 49 | protected Object unwrap() { 50 | return new ArrayList<>(storage); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/JsonArrayIterator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | /** 4 | * @author erosb 5 | */ 6 | @FunctionalInterface 7 | interface JsonArrayIterator { 8 | 9 | void apply(int index, JsonValue value); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/JsonObjectIterator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | /** 4 | * @author erosb 5 | */ 6 | @FunctionalInterface 7 | interface JsonObjectIterator { 8 | 9 | void apply(String key, JsonValue value); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/SchemaClient.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | import java.io.InputStream; 4 | import java.util.function.Function; 5 | 6 | import org.everit.json.schema.loader.internal.DefaultSchemaClient; 7 | 8 | /** 9 | * This interface is used by {@link SchemaLoader} to fetch the contents denoted by remote JSON 10 | * pointer. 11 | *

12 | * Implementations are expected to support the HTTP/1.1 protocol, the support of other protocols is 13 | * optional. 14 | */ 15 | @FunctionalInterface 16 | public interface SchemaClient extends Function { 17 | 18 | static SchemaClient classPathAwareClient() { 19 | return new ClassPathAwareSchemaClient(new DefaultSchemaClient()); 20 | } 21 | 22 | @Override 23 | default InputStream apply(final String url) { 24 | return get(url); 25 | } 26 | 27 | /** 28 | * Returns a stream to be used for reading the remote content (response body) of the URL. In the 29 | * case of a HTTP URL, implementations are expected send HTTP GET requests and the response is 30 | * expected to be represented in UTF-8 character set. 31 | * 32 | * @param url 33 | * the URL of the remote resource 34 | * @return the input stream of the response 35 | * @throws java.io.UncheckedIOException 36 | * if an IO error occurs. 37 | */ 38 | InputStream get(String url); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/SubschemaRegistry.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | class SubschemaRegistry { 7 | 8 | final Map storage = new HashMap<>(); 9 | 10 | 11 | SubschemaRegistry(JsonValue rootJson) { 12 | collectObjectsWithId(rootJson); 13 | } 14 | 15 | void collectObjectsWithId(JsonValue val) { 16 | String idKeyword = val.ls.specVersion().idKeyword(); 17 | if (val instanceof JsonObject) { 18 | JsonObject obj = (JsonObject) val; 19 | if (obj.containsKey(idKeyword) 20 | && obj.require(idKeyword).typeOfValue() == String.class) { 21 | storage.put(obj.require(idKeyword).requireString(), obj); 22 | } 23 | for (String key : obj.keySet()) { 24 | collectObjectsWithId(obj.require(key)); 25 | } 26 | } else if (val instanceof JsonArray) { 27 | JsonArray arr = (JsonArray) val; 28 | for (int i = 0; i < arr.length(); ++i) { 29 | collectObjectsWithId(arr.at(i)); 30 | } 31 | } 32 | } 33 | 34 | JsonObject getById(String id) { 35 | return storage.get(id); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/Uri.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.net.URI; 6 | import java.net.URISyntaxException; 7 | 8 | class Uri { 9 | 10 | static Uri parse(String str) throws URISyntaxException { 11 | URI rawUri = new URI(str); 12 | int poundIdx = str.indexOf('#'); 13 | String fragment; 14 | URI toBeQueried; 15 | if (poundIdx == -1) { 16 | toBeQueried = rawUri; 17 | fragment = ""; 18 | } else { 19 | fragment = str.substring(poundIdx); 20 | toBeQueried = new URI(str.substring(0, poundIdx)); 21 | } 22 | return new Uri(toBeQueried, fragment); 23 | } 24 | 25 | URI toBeQueried; 26 | 27 | String fragment; 28 | 29 | private Uri(URI toBeQueried, String fragment) { 30 | this.toBeQueried = requireNonNull(toBeQueried, "toBeQueried cannot be null"); 31 | this.fragment = requireNonNull(fragment, "fragment cannot be null"); 32 | } 33 | 34 | URI asJavaURI() { 35 | try { 36 | return new URI(toBeQueried + fragment); 37 | } catch (URISyntaxException e) { 38 | throw new RuntimeException(e); 39 | } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/internal/DefaultSchemaClient.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader.internal; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.UncheckedIOException; 6 | import java.net.URL; 7 | import java.net.URLConnection; 8 | 9 | import org.everit.json.schema.loader.SchemaClient; 10 | 11 | /** 12 | * A {@link SchemaClient} implementation which uses {@link URL} for reading the remote content. 13 | */ 14 | public class DefaultSchemaClient implements SchemaClient { 15 | 16 | @Override 17 | public InputStream get(final String url) { 18 | try { 19 | URL u = new URL(url); 20 | URLConnection conn = u.openConnection(); 21 | String location = conn.getHeaderField("Location"); 22 | if (location != null) { 23 | return get(location); 24 | } 25 | return (InputStream) conn.getContent(); 26 | } catch (IOException e) { 27 | throw new UncheckedIOException(e); 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/internal/ResolutionScopeChangeListener.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader.internal; 2 | 3 | import java.net.URI; 4 | import java.util.function.Consumer; 5 | 6 | /** 7 | * Event handler interface used by {@link TypeBasedMultiplexer} to notify client(s) (which is 8 | * currently a schema loader instance) about resolution scope changes. 9 | */ 10 | @FunctionalInterface 11 | public interface ResolutionScopeChangeListener extends Consumer { 12 | 13 | @Override 14 | default void accept(final URI t) { 15 | resolutionScopeChanged(t); 16 | } 17 | 18 | void resolutionScopeChanged(URI newResolutionScope); 19 | } 20 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/loader/internal/WrappingFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader.internal; 2 | 3 | import org.everit.json.schema.FormatValidator; 4 | 5 | import java.util.Optional; 6 | 7 | import static java.util.Objects.requireNonNull; 8 | 9 | public class WrappingFormatValidator implements FormatValidator { 10 | 11 | private final String formatName; 12 | private final FormatValidator formatValidator; 13 | 14 | public WrappingFormatValidator(String formatName, FormatValidator wrappedValidator) { 15 | this.formatName = requireNonNull(formatName, "formatName cannot be null"); 16 | this.formatValidator = requireNonNull(wrappedValidator, "wrappedValidator cannot be null"); 17 | } 18 | 19 | 20 | 21 | @Override 22 | public Optional validate(String subject) { 23 | return formatValidator.validate(subject); 24 | } 25 | 26 | @Override 27 | public String formatName() { 28 | return formatName; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/regexp/JavaUtilRegexpFactory.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.regexp; 2 | 3 | import java.util.Objects; 4 | import java.util.Optional; 5 | import java.util.regex.Pattern; 6 | 7 | class JavaUtilRegexp extends AbstractRegexp { 8 | 9 | private final Pattern pattern; 10 | 11 | JavaUtilRegexp(String pattern) { 12 | super(pattern); 13 | this.pattern = Pattern.compile(pattern); 14 | } 15 | 16 | @Override public Optional patternMatchingFailure(String input) { 17 | if (pattern.matcher(input).find()) { 18 | return Optional.empty(); 19 | } else { 20 | return Optional.of(new RegexpMatchingFailure()); 21 | } 22 | } 23 | 24 | @Override public boolean equals(Object o) { 25 | if (this == o) 26 | return true; 27 | if (!(o instanceof JavaUtilRegexp)) 28 | return false; 29 | JavaUtilRegexp that = (JavaUtilRegexp) o; 30 | return Objects.equals(pattern.pattern(), that.pattern.pattern()); 31 | } 32 | 33 | @Override public int hashCode() { 34 | return Objects.hash(pattern); 35 | } 36 | } 37 | 38 | public class JavaUtilRegexpFactory implements RegexpFactory { 39 | @Override public Regexp createHandler(String regexp) { 40 | return new JavaUtilRegexp(regexp); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/regexp/RE2JRegexpFactory.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.regexp; 2 | 3 | import java.util.Objects; 4 | import java.util.Optional; 5 | 6 | import com.google.re2j.Pattern; 7 | 8 | class RE2JRegexp extends AbstractRegexp { 9 | 10 | private final Pattern pattern; 11 | 12 | RE2JRegexp(String pattern) { 13 | super(pattern); 14 | this.pattern = Pattern.compile(pattern); 15 | } 16 | 17 | @Override public Optional patternMatchingFailure(String input) { 18 | if (pattern.matcher(input).find()) { 19 | return Optional.empty(); 20 | } else { 21 | return Optional.of(new RegexpMatchingFailure()); 22 | } 23 | } 24 | 25 | @Override public boolean equals(Object o) { 26 | if (this == o) 27 | return true; 28 | if (!(o instanceof RE2JRegexp)) 29 | return false; 30 | RE2JRegexp that = (RE2JRegexp) o; 31 | return Objects.equals(pattern, that.pattern); 32 | } 33 | 34 | @Override public int hashCode() { 35 | return Objects.hash(pattern); 36 | } 37 | } 38 | 39 | public class RE2JRegexpFactory implements RegexpFactory { 40 | @Override public Regexp createHandler(String input) { 41 | return new RE2JRegexp(input); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/regexp/Regexp.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.regexp; 2 | 3 | import static java.util.Objects.requireNonNull; 4 | 5 | import java.util.Optional; 6 | 7 | public interface Regexp { 8 | 9 | Optional patternMatchingFailure(String input); 10 | 11 | } 12 | 13 | abstract class AbstractRegexp implements Regexp { 14 | 15 | private final String asString; 16 | 17 | AbstractRegexp(String asString) { 18 | this.asString = requireNonNull(asString, "asString cannot be null"); 19 | } 20 | 21 | @Override public String toString() { 22 | return asString; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/regexp/RegexpFactory.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.regexp; 2 | 3 | public interface RegexpFactory { 4 | 5 | Regexp createHandler(String input); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/main/java/org/everit/json/schema/regexp/RegexpMatchingFailure.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.regexp; 2 | 3 | public class RegexpMatchingFailure { 4 | 5 | RegexpMatchingFailure() { 6 | } 7 | 8 | @Override public boolean equals(Object obj) { 9 | return obj instanceof RegexpMatchingFailure; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/DynamicReferenceSchemaExample.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.json.JSONObject; 7 | 8 | public class DynamicReferenceSchemaExample { 9 | 10 | public static void main(String[] args) { 11 | ObjectSchema.Builder rootSchema = ObjectSchema.builder(); 12 | ReferenceSchema referenceSchema = ReferenceSchema.builder() 13 | .refValue("#/definitions/MySubschema") 14 | .build(); 15 | rootSchema.addPropertySchema("myProperty", referenceSchema); 16 | 17 | Map unprocessed = new HashMap<>(); 18 | JSONObject defs = new JSONObject(); 19 | StringSchema referredSchema = StringSchema.builder() 20 | .minLength(2).maxLength(5) 21 | .build(); 22 | referenceSchema.setReferredSchema(referredSchema); 23 | defs.put("MySubschema", new JSONObject(referredSchema.toString())); 24 | unprocessed.put("definitions", defs); 25 | 26 | 27 | rootSchema.unprocessedProperties(unprocessed); 28 | 29 | System.out.println(rootSchema.build().toString()); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/EarlyFailingFailureReporterTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertSame; 6 | import static org.junit.jupiter.api.Assertions.fail; 7 | 8 | public class EarlyFailingFailureReporterTest { 9 | 10 | private EarlyFailingFailureReporter createSubject() { 11 | return new EarlyFailingFailureReporter(NullSchema.INSTANCE); 12 | } 13 | 14 | @Test 15 | public void testFailure() { 16 | EarlyFailingFailureReporter subject = createSubject(); 17 | ValidationException input = new ValidationException(BooleanSchema.INSTANCE, Boolean.class, "string"); 18 | try { 19 | subject.failure(input); 20 | fail(); 21 | } catch (ValidationException e) { 22 | assertSame(input, e); 23 | } 24 | } 25 | 26 | @Test 27 | public void testValidationFinished() { 28 | // should be no-op 29 | createSubject().validationFinished(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/FalseSchemaTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | /** 8 | * @author erosb 9 | */ 10 | public class FalseSchemaTest { 11 | 12 | @Test public void alwaysFails() { 13 | TestSupport.failureOf(FalseSchema.builder()) 14 | .input("whatever") 15 | .expectedKeyword("false") 16 | .expect(); 17 | } 18 | 19 | @Test 20 | public void toStringTest() { 21 | assertEquals("false", FalseSchema.builder().build().toString()); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/FormatValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Everit Kft. (http://www.everit.org) 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 org.everit.json.schema; 17 | 18 | import org.junit.jupiter.api.Test; 19 | import org.junit.jupiter.params.ParameterizedTest; 20 | import org.junit.jupiter.params.provider.ValueSource; 21 | 22 | import static org.junit.jupiter.api.Assertions.assertThrows; 23 | 24 | public class FormatValidatorTest { 25 | 26 | @ParameterizedTest 27 | @ValueSource(strings = {"date-time", "email", "hostname", "ipv6", "ipv4", "uri"}) 28 | public void check(String formatName) { 29 | FormatValidator.forFormat(formatName); 30 | } 31 | 32 | @Test 33 | public void nullFormat() { 34 | assertThrows(NullPointerException.class, () -> { 35 | FormatValidator.forFormat(null); 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/InternalValidationExceptionTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class InternalValidationExceptionTest { 9 | 10 | @Test 11 | public void stackTraceShouldBeEmpty() { 12 | try { 13 | throw new InternalValidationException(BooleanSchema.INSTANCE, "message", "keyword", "#"); 14 | } catch (ValidationException e) { 15 | assertEquals(0, e.getStackTrace().length); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/JSONMatcher.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.hamcrest.Description; 4 | import org.hamcrest.TypeSafeMatcher; 5 | import org.json.JSONObject; 6 | 7 | public class JSONMatcher extends TypeSafeMatcher { 8 | 9 | public static JSONMatcher sameJsonAs(JSONObject expected) { 10 | return new JSONMatcher(expected); 11 | } 12 | 13 | private final JSONObject expected; 14 | 15 | private JSONMatcher(JSONObject expected) { 16 | this.expected = expected; 17 | } 18 | 19 | @Override protected boolean matchesSafely(JSONObject item) { 20 | return ObjectComparator.deepEquals(expected, item); 21 | } 22 | 23 | @Override public void describeTo(Description description) { 24 | description.appendText(expected.toString(2)); 25 | } 26 | 27 | @Override protected void describeMismatchSafely(JSONObject item, Description description) { 28 | description.appendText("was ").appendText(item.toString(2)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/NullableValidationTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.json.JSONObject; 4 | import org.junit.jupiter.api.Test; 5 | 6 | public class NullableValidationTest { 7 | 8 | @Test 9 | public void testNullableFalse_JSONNull() { 10 | TestSupport.failureOf(StringSchema.builder().requiresString(false).nullable(false)) 11 | .input(JSONObject.NULL) 12 | .expectedKeyword("nullable") 13 | .expectedMessageFragment("value cannot be null") 14 | .expect(); 15 | } 16 | 17 | @Test 18 | public void testNullableFalse_nullReference() { 19 | TestSupport.failureOf(StringSchema.builder().requiresString(false).nullable(false)) 20 | .input(null) 21 | .expectedKeyword("nullable") 22 | .expectedMessageFragment("value cannot be null") 23 | .expect(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/ResourceLoader.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import static java.lang.String.format; 4 | import static java.util.Objects.requireNonNull; 5 | 6 | import java.io.InputStream; 7 | 8 | import org.json.JSONObject; 9 | import org.json.JSONTokener; 10 | 11 | public class ResourceLoader { 12 | 13 | public static final ResourceLoader DEFAULT = new ResourceLoader("/org/everit/jsonvalidator/"); 14 | 15 | private final String rootPath; 16 | 17 | public ResourceLoader(String rootPath) { 18 | this.rootPath = requireNonNull(rootPath, "rootPath cannot be null"); 19 | } 20 | 21 | public JSONObject readObj(String relPath) { 22 | InputStream stream = getStream(relPath); 23 | return new JSONObject(new JSONTokener(stream)); 24 | } 25 | 26 | public InputStream getStream(String relPath) { 27 | String absPath = rootPath + relPath; 28 | InputStream rval = getClass().getResourceAsStream(absPath); 29 | if (rval == null) { 30 | throw new IllegalArgumentException( 31 | format("failed to load resource by relPath [%s].\n" 32 | + "InputStream by path [%s] is null", relPath, absPath)); 33 | } 34 | return rval; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/TrueSchemaTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | /** 8 | * @author erosb 9 | */ 10 | public class TrueSchemaTest { 11 | 12 | @Test 13 | public void testToString() { 14 | assertEquals("true", TrueSchema.builder().build().toString()); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/event/CombinedSchemaMatchEventTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import nl.jqno.equalsverifier.EqualsVerifier; 6 | import nl.jqno.equalsverifier.Warning; 7 | 8 | public class CombinedSchemaMatchEventTest { 9 | 10 | @Test 11 | public void equalsVerifier() { 12 | EqualsVerifier.forClass(CombinedSchemaMatchEvent.class) 13 | .withNonnullFields("subSchema", "schema", "instance") 14 | .withRedefinedSuperclass() 15 | .suppress(Warning.STRICT_INHERITANCE) 16 | .verify(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/event/CombinedSchemaMismatchEventTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.everit.json.schema.FalseSchema; 4 | import org.everit.json.schema.TrueSchema; 5 | import org.everit.json.schema.ValidationException; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import nl.jqno.equalsverifier.EqualsVerifier; 9 | import nl.jqno.equalsverifier.Warning; 10 | 11 | public class CombinedSchemaMismatchEventTest { 12 | 13 | @Test 14 | public void equalsVerifier() { 15 | ValidationException exc1 = new ValidationException(TrueSchema.INSTANCE, "message", "keyword", "#/location"); 16 | ValidationException exc2 = new ValidationException(FalseSchema.INSTANCE, "message", "keyword", "#/loca/tion"); 17 | EqualsVerifier.forClass(CombinedSchemaMismatchEvent.class) 18 | .withNonnullFields("subSchema", "schema", "instance", "failure") 19 | .withRedefinedSuperclass() 20 | .withPrefabValues(ValidationException.class, exc1, exc2) 21 | .suppress(Warning.STRICT_INHERITANCE) 22 | .verify(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/event/ConditionalSchemaMatchEventTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import nl.jqno.equalsverifier.EqualsVerifier; 6 | import nl.jqno.equalsverifier.Warning; 7 | 8 | public class ConditionalSchemaMatchEventTest { 9 | 10 | @Test 11 | public void equalsVerifier() { 12 | EqualsVerifier.forClass(ConditionalSchemaMatchEvent.class) 13 | .withNonnullFields("keyword", "schema", "instance") 14 | .withRedefinedSuperclass() 15 | .suppress(Warning.STRICT_INHERITANCE) 16 | .verify(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/event/ConditionalSchemaMismatchEventTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.everit.json.schema.FalseSchema; 4 | import org.everit.json.schema.TrueSchema; 5 | import org.everit.json.schema.ValidationException; 6 | import org.junit.jupiter.api.Test; 7 | 8 | import nl.jqno.equalsverifier.EqualsVerifier; 9 | import nl.jqno.equalsverifier.Warning; 10 | 11 | public class ConditionalSchemaMismatchEventTest { 12 | 13 | @Test 14 | public void equalsVerifier() { 15 | ValidationException exc1 = new ValidationException(TrueSchema.INSTANCE, "message", "keyword", "#/location"); 16 | ValidationException exc2 = new ValidationException(FalseSchema.INSTANCE, "message", "keyword", "#/loca/tion"); 17 | EqualsVerifier.forClass(ConditionalSchemaMismatchEvent.class) 18 | .withNonnullFields("keyword", "schema", "instance", "failure") 19 | .withRedefinedSuperclass() 20 | .withPrefabValues(ValidationException.class, exc1, exc2) 21 | .suppress(Warning.STRICT_INHERITANCE) 22 | .verify(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/event/SchemaReferencedEventTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.event; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import nl.jqno.equalsverifier.EqualsVerifier; 6 | import nl.jqno.equalsverifier.Warning; 7 | 8 | public class SchemaReferencedEventTest { 9 | 10 | @Test 11 | public void equalsVerifier() { 12 | EqualsVerifier.forClass(SchemaReferencedEvent.class) 13 | .withNonnullFields("referredSchema", "schema", "instance") 14 | .withRedefinedSuperclass() 15 | .suppress(Warning.STRICT_INHERITANCE) 16 | .verify(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/internal/JSONWriterTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertFalse; 4 | import static org.junit.jupiter.api.Assertions.assertTrue; 5 | 6 | import org.json.JSONString; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class JSONWriterTest { 10 | 11 | public static class Ancestor implements JSONString { 12 | 13 | @Override public String toJSONString() { 14 | return null; 15 | } 16 | 17 | } 18 | 19 | public static class Descendant extends Ancestor { 20 | 21 | } 22 | 23 | @Test 24 | public void classImplementsJSONString() { 25 | assertTrue(JSONWriter.implementsJSONString(new Ancestor())); 26 | } 27 | 28 | @Test 29 | public void subclassImplementsJSONString() { 30 | assertTrue(JSONWriter.implementsJSONString(new Descendant())); 31 | } 32 | 33 | @Test 34 | public void nullDoesNotImplementJSONString() { 35 | assertFalse(JSONWriter.implementsJSONString(null)); 36 | } 37 | 38 | @Test 39 | public void objectDoesNotImplementJSONString() { 40 | assertFalse(JSONWriter.implementsJSONString(new Object())); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/internal/URIReferenceFormatValidatorTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import static org.everit.json.schema.internal.ValidatorTestSupport.assertFailure; 4 | import static org.everit.json.schema.internal.ValidatorTestSupport.assertSuccess; 5 | 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class URIReferenceFormatValidatorTest { 9 | 10 | private final URIReferenceFormatValidator subject = new URIReferenceFormatValidator(); 11 | 12 | @Test 13 | public void success() { 14 | assertSuccess("http://foo.bar/?baz=qux#quux", subject); 15 | } 16 | 17 | @Test 18 | public void protocolRelativeRef() { 19 | assertSuccess("//foo.bar/?baz=qux#quux", subject); 20 | } 21 | 22 | @Test 23 | public void pathSuccess() { 24 | assertSuccess("/abc", subject); 25 | } 26 | 27 | @Test 28 | public void illegalCharFailure() { 29 | assertFailure("\\\\WINDOWS\\fileshare", subject, "[\\\\WINDOWS\\fileshare] is not a valid URI reference"); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/internal/URITemplateFormatTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import static org.everit.json.schema.internal.ValidatorTestSupport.assertFailure; 4 | import static org.everit.json.schema.internal.ValidatorTestSupport.assertSuccess; 5 | 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class URITemplateFormatTest { 9 | 10 | private final URITemplateFormatValidator subject = new URITemplateFormatValidator(); 11 | 12 | @Test 13 | public void success() { 14 | assertSuccess("http://example.com/dictionary/{term:1}/{term}", subject); 15 | } 16 | 17 | @Test 18 | public void unclosedBracket() { 19 | assertFailure("http://example.com/dictionary/{term:1}/{term", subject, 20 | "[http://example.com/dictionary/{term:1}/{term] is not a valid URI template"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/internal/URIV4FormatValidatorTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertFalse; 4 | import static org.junit.jupiter.api.Assertions.assertTrue; 5 | 6 | import org.junit.jupiter.api.Test; 7 | 8 | public class URIV4FormatValidatorTest { 9 | 10 | @Test 11 | public void relativeURI() { 12 | assertFalse(new URIV4FormatValidator().validate("abc").isPresent()); 13 | } 14 | 15 | @Test 16 | public void absoluteURI() { 17 | assertFalse(new URIV4FormatValidator().validate("http://a.b.c").isPresent()); 18 | } 19 | 20 | @Test 21 | public void notURI() { 22 | assertTrue(new URIV4FormatValidator().validate("\\\\\\\\WINDOWS\\\\fileshare").isPresent()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/internal/ValidatorTestSupport.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.internal; 2 | 3 | import java.util.Optional; 4 | 5 | import org.everit.json.schema.FormatValidator; 6 | 7 | import static org.junit.jupiter.api.Assertions.*; 8 | 9 | public final class ValidatorTestSupport { 10 | 11 | static void assertSuccess(String subject, FormatValidator format) { 12 | Optional opt = format.validate(subject); 13 | assertNotNull(opt, "the optional is not null"); 14 | assertFalse(opt.isPresent(), "failure not exist"); 15 | } 16 | 17 | static void assertFailure(String subject, FormatValidator format, String expectedFailure) { 18 | Optional opt = format.validate(subject); 19 | assertNotNull(opt, "the optional is not null"); 20 | assertTrue(opt.isPresent(), "failure exists"); 21 | assertEquals(expectedFailure, opt.get()); 22 | } 23 | 24 | private ValidatorTestSupport() { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/loader/AdjacentSchemaExtractionStateTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | import static java.util.Arrays.asList; 4 | import static java.util.Collections.singleton; 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | import org.everit.json.schema.ConstSchema; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import com.google.common.collect.ImmutableMap; 11 | 12 | public class AdjacentSchemaExtractionStateTest { 13 | 14 | @Test 15 | public void testReduce() { 16 | AdjacentSchemaExtractionState original = new AdjacentSchemaExtractionState(JsonValue.of(ImmutableMap.builder() 17 | .put("const", "2") 18 | .put("minimum", 1) 19 | .build() 20 | ).requireObject()); 21 | ConstSchema.ConstSchemaBuilder schemaBuilder = ConstSchema.builder().permittedValue("2"); 22 | 23 | AdjacentSchemaExtractionState actual = original.reduce(new ExtractionResult("const", asList(schemaBuilder))); 24 | 25 | assertEquals(singleton(schemaBuilder), actual.extractedSchemaBuilders()); 26 | assertEquals(singleton("minimum"), actual.projectedSchemaJson().keySet()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/java/org/everit/json/schema/loader/JsonArrayTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema.loader; 2 | 3 | import static java.util.Arrays.asList; 4 | import static org.everit.json.schema.loader.JsonValueTest.withLs; 5 | import static org.mockito.Mockito.mock; 6 | import static org.mockito.Mockito.verify; 7 | 8 | import org.json.JSONObject; 9 | import org.junit.jupiter.api.Test; 10 | 11 | /** 12 | * @author erosb 13 | */ 14 | public class JsonArrayTest { 15 | 16 | @Test 17 | public void testForEach() { 18 | JSONObject rawObj = new JSONObject(); 19 | JsonArray subject = withLs(new JsonArray(asList(true, rawObj))).requireArray(); 20 | JsonArrayIterator iterator = mock(JsonArrayIterator.class); 21 | subject.forEach(iterator); 22 | verify(iterator).apply(0, JsonValue.of(true)); 23 | verify(iterator).apply(1, JsonValue.of(rawObj)); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /core/src/test/resources/jsonpointer-testdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "foo": [ 3 | "bar", 4 | "baz" 5 | ], 6 | "": 0, 7 | "a/b": 1, 8 | "c%d": 2, 9 | "e^f": 3, 10 | "g|h": 4, 11 | "i\\j": 5, 12 | "k\"l": 6, 13 | " ": 7, 14 | "m~n": 8, 15 | "obj": { 16 | "key": "value", 17 | "other~key": { 18 | "another/key": [ 19 | "val" 20 | ] 21 | }, 22 | "": { 23 | "": "empty key of an object with an empty key", 24 | "subKey": "Some other value" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/arraytestcases.json: -------------------------------------------------------------------------------- 1 | { 2 | "noItemSchema": [ 3 | "a", 4 | 2, 5 | 3 6 | ], 7 | "onlyOneItem": [ 8 | 0 9 | ], 10 | "nonUniqueItems": [ 11 | 0, 12 | 0, 13 | 1 14 | ], 15 | "nonUniqueObjects": [ 16 | { 17 | "a": 0 18 | }, 19 | { 20 | "b": 0 21 | }, 22 | { 23 | "a": 0 24 | } 25 | ], 26 | "uniqueObjectValues": [ 27 | { 28 | "a": 0 29 | }, 30 | { 31 | "a": 1 32 | }, 33 | { 34 | "a": 2 35 | } 36 | ], 37 | "boolArrFailure": [ 38 | true, 39 | false, 40 | "true" 41 | ], 42 | "tupleWithOneItem": [ 43 | "true" 44 | ], 45 | "subjectHasLessElemsThanTupleEntries": [ 46 | null 47 | ], 48 | "twoItemTupleWithAdditional": [ 49 | false, 50 | null, 51 | "a" 52 | ], 53 | "doesNotRequireExplicitArray": { 54 | "a": "b" 55 | }, 56 | "additionalItemsSchema": [ 57 | true, 58 | null, 59 | null 60 | ], 61 | "additionalItemsSchemaFailure": [ 62 | true, 63 | null, 64 | false 65 | ], 66 | "nonUniqueArrayOfArrays": [ 67 | [ 68 | "foo" 69 | ], 70 | [ 71 | "foo" 72 | ] 73 | ], 74 | "uniqueItemsWithSameToString": [ 75 | { 76 | "a": "b" 77 | }, 78 | "{\"a\":\"b\"}" 79 | ], 80 | "emptyArray": [] 81 | } 82 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/arraytestschemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "invalidItemsArraySchema": { 3 | "type": "array", 4 | "items": null 5 | }, 6 | "invalidArrayItemSchema": { 7 | "type": "array", 8 | "items": [ 9 | "invalid" 10 | ] 11 | }, 12 | "invalidAdditionalItems": { 13 | "additionalItems": "invalid" 14 | }, 15 | "arrayByAdditionalItems": { 16 | "additionalItems": false 17 | }, 18 | "arrayByItems": { 19 | "items": [] 20 | }, 21 | "arraySchema": { 22 | "type": "array", 23 | "minItems": 2, 24 | "maxItems": 3, 25 | "uniqueItems": true, 26 | "items": { 27 | "type": "null" 28 | } 29 | }, 30 | "additionalItemSchema": { 31 | "type": "array", 32 | "additionalItems": { 33 | "type": "boolean" 34 | } 35 | }, 36 | "arrayWithContains": { 37 | "type": "array", 38 | "contains": { 39 | "type": "boolean" 40 | } 41 | }, 42 | "itemsAsBoolean": { 43 | "items": true 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/combinedtestschemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "combinedSchema": { 3 | "anyOf": [ 4 | { 5 | "type": "integer" 6 | }, 7 | { 8 | "type": "null" 9 | } 10 | ] 11 | }, 12 | "combinedSchemaWithBaseSchema": { 13 | "type": "string", 14 | "maxLength": 30, 15 | "anyOf": [ 16 | { 17 | "minLength": 20 18 | }, 19 | { 20 | "pattern": "a.*" 21 | } 22 | ] 23 | }, 24 | "combinedSchemaWithExplicitBaseSchema": { 25 | "type": "string", 26 | "anyOf": [ 27 | { 28 | "pattern": "a.*" 29 | }, 30 | { 31 | "minLength": 50 32 | } 33 | ] 34 | }, 35 | "combinedSchemaWithMultipleBaseSchemas": { 36 | "type": [ 37 | "string", 38 | "integer" 39 | ], 40 | "anyOf": [ 41 | { 42 | "pattern": "a.*" 43 | }, 44 | { 45 | "minLength": 50 46 | } 47 | ] 48 | }, 49 | "multipleKeywords": { 50 | "allOf": [ 51 | { 52 | "type": "boolean" 53 | } 54 | ], 55 | "anyOf": [ 56 | { 57 | "type": "string" 58 | } 59 | ] 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/config-propagation/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "causingExceptions": [ 3 | { 4 | "causingExceptions": [], 5 | "keyword": "minLength", 6 | "message": "expected minLength: 3, actual: 1", 7 | "pointerToViolation": "#/urnRefProp", 8 | "schemaLocation": "urn:uuid:85946d9c-b896-496c-a7ac-6835f4b59f63" 9 | }, 10 | { 11 | "causingExceptions": [], 12 | "keyword": "format", 13 | "message": "the length of srtring [a] is odd", 14 | "pointerToViolation": "#/urnRefProp", 15 | "schemaLocation": "urn:uuid:85946d9c-b896-496c-a7ac-6835f4b59f63" 16 | } 17 | ], 18 | "message": "2 schema violations found", 19 | "pointerToViolation": "#/urnRefProp", 20 | "schemaLocation": "urn:uuid:85946d9c-b896-496c-a7ac-6835f4b59f63" 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/config-propagation/instance.json: -------------------------------------------------------------------------------- 1 | { 2 | "nullableProp": null, 3 | "urnRefProp": "a" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/config-propagation/remote.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "nullableProp": { 4 | "type": "string", 5 | "nullable": true 6 | }, 7 | "propWithDefault": { 8 | "default": 42 9 | }, 10 | "urnRefProp": { 11 | "$ref": "urn:uuid:85946d9c-b896-496c-a7ac-6835f4b59f63" 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/config-propagation/schema-by-urn.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string", 3 | "minLength": 3, 4 | "format": "evenlength" 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/config-propagation/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "classpath:/org/everit/jsonvalidator/config-propagation/remote.json" 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/constobject.json: -------------------------------------------------------------------------------- 1 | { 2 | "const": { 3 | "a": "b", 4 | "b": "a" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/customformat-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "everitorg" 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/customformat-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "id": { 6 | "type": "string", 7 | "maxLength": 10, 8 | "minLength": 3, 9 | "format": "evenlength" 10 | } 11 | }, 12 | "required": [ 13 | "id" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/default-and-required-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "bugtest", 4 | "description": "everit bug", 5 | "type": "object", 6 | "additionalProperties": false, 7 | "dependencies": {}, 8 | "properties": { 9 | "arrayPropEnabled": { 10 | "type": "boolean" 11 | }, 12 | "arrayProp": { 13 | "type": "array", 14 | "items": { 15 | "type": "number" 16 | }, 17 | "default": [0,1,2,3] 18 | } 19 | }, 20 | "allOf": [ 21 | { 22 | "if": { 23 | "properties": { 24 | "arrayPropEnabled": true 25 | } 26 | }, 27 | "then": { 28 | "dependencies": { 29 | "arrayPropEnabled": [ 30 | "arrayProp" 31 | ] 32 | } 33 | } 34 | } 35 | ] 36 | } 37 | 38 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/default-and-required.json: -------------------------------------------------------------------------------- 1 | { 2 | "arrayPropEnabled": true 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/default-in-oneof.json: -------------------------------------------------------------------------------- 1 | { 2 | "parameter1": { 3 | "in": "query" 4 | }, 5 | "parameter2": { 6 | "in": "path" 7 | } 8 | } -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/combined-schema-match.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "match", 3 | "keyword": "anyOf" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/combined-schema-mismatch.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "mismatch", 3 | "keyword": "anyOf", 4 | "schema": { 5 | "anyOf": [ 6 | {}, 7 | false 8 | ] 9 | }, 10 | "subSchema": false, 11 | "instance": { 12 | "hello": [ 13 | "world" 14 | ] 15 | }, 16 | "failure": { 17 | "schemaLocation": "#/schema/location", 18 | "pointerToViolation": "#", 19 | "causingExceptions": [], 20 | "keyword": "anyOf", 21 | "message": "message" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/conditional-match-if.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "match", 3 | "keyword": "if" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/conditional-match-then-boolean.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "match", 3 | "keyword": "then", 4 | "schema": true, 5 | "instance": { 6 | "hello": [ 7 | "world" 8 | ] 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/conditional-mismatch-if.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "mismatch", 3 | "keyword": "if", 4 | "failure": { 5 | "schemaLocation": "#/schema/location", 6 | "pointerToViolation": "#", 7 | "causingExceptions": [], 8 | "keyword": "if", 9 | "message": "message" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/reference-event-with-instance.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "ref", 3 | "instance": { 4 | "hello": [ 5 | "world" 6 | ] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/reference-event-with-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "ref", 3 | "schema": { 4 | "$ref": "#/definitions/Stuff" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/event/reference-event.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "ref" 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/exception-to-json-with-causes.json: -------------------------------------------------------------------------------- 1 | { 2 | "pointerToViolation": "#/a", 3 | "message": "exception message", 4 | "keyword": "type", 5 | "causingExceptions": [ 6 | { 7 | "pointerToViolation": "#/a/0", 8 | "message": "cause msg", 9 | "keyword": "type", 10 | "causingExceptions": [] 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/exception-to-json-with-schema-location.json: -------------------------------------------------------------------------------- 1 | { 2 | "pointerToViolation": "#/a/b", 3 | "schemaLocation": "#/schema/location", 4 | "message": "exception message", 5 | "keyword": "type", 6 | "causingExceptions": [] 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/exception-to-json.json: -------------------------------------------------------------------------------- 1 | { 2 | "pointerToViolation": "#/a/b", 3 | "message": "exception message", 4 | "keyword": "type", 5 | "causingExceptions": [] 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/https-schema-uri.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft-07/schema", 3 | "properties": { 4 | "test": { 5 | "type": "boolean" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/issue345.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema":"http://json-schema.org/draft-04/schema#", 3 | "not":{ 4 | "type":"object", 5 | "properties":{ 6 | "name":{ 7 | "type":"string" 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/merge-testcases.json: -------------------------------------------------------------------------------- 1 | { 2 | "empty": {}, 3 | "propIsTrue": { 4 | "prop": true 5 | }, 6 | "propIsFalse": { 7 | "prop": false 8 | }, 9 | "prop2IsFalse": { 10 | "prop2": false 11 | }, 12 | "propTrueProp2False": { 13 | "prop": true, 14 | "prop2": false 15 | }, 16 | "multipleWithPropTrue": { 17 | "prop": true, 18 | "a": "a", 19 | "b": "b", 20 | "c": "c" 21 | }, 22 | "multipleWithPropFalse": { 23 | "prop": false, 24 | "b": "b2", 25 | "d": "d" 26 | }, 27 | "mergedMultiple": { 28 | "prop": true, 29 | "a": "a", 30 | "b": "b", 31 | "c": "c", 32 | "d": "d" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/multi-pointer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "a": { 5 | "$ref": "#/definitions/Length", 6 | "title": "A side", 7 | "description": "length of the A side", 8 | "unproc0": "unproc0 of A" 9 | }, 10 | "b": { 11 | "$ref": "#/definitions/Length", 12 | "title": "B side", 13 | "description": "length of the B side", 14 | "unproc0": "unproc0 of B" 15 | } 16 | }, 17 | "definitions": { 18 | "Length": { 19 | "type": "integer", 20 | "minimum": 0 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/numberschemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "v4Attributes": { 3 | "type": "number", 4 | "minimum": 5, 5 | "maximum": 10, 6 | "multipleOf": 2, 7 | "exclusiveMinimum": true, 8 | "exclusiveMaximum": true 9 | }, 10 | "v6Attributes": { 11 | "type": "number", 12 | "minimum": 5, 13 | "maximum": 10, 14 | "multipleOf": 2, 15 | "exclusiveMinimum": 5, 16 | "exclusiveMaximum": 10 17 | }, 18 | "v6DoubleLimits" : { 19 | "type": "number", 20 | "exclusiveMinimum": 5.5, 21 | "exclusiveMaximum": 10.1 22 | }, 23 | "onlyExMax": { 24 | "exclusiveMaximum": 3.0 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/pointer-eval-non-uri-failure.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaLocation": "#", 3 | "message": "Illegal character in path at index 0: ||||" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/read-write-context.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "readOnlyProp": { 5 | "type": "string", 6 | "readOnly": true 7 | }, 8 | "writeOnlyProp": { 9 | "type": "number", 10 | "writeOnly": true 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/ref-lookup-tests.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "sameDocPointer": { 4 | "$ref": "#/definitions/Bar" 5 | }, 6 | "lookupByDocLocalIdent": { 7 | "$ref": "has-id" 8 | }, 9 | "absoluteRef": { 10 | "$ref": "http://localhost/schema.json" 11 | }, 12 | "parent": { 13 | "$id": "http://localhost/", 14 | "child": { 15 | "$ref": "child-ref" 16 | } 17 | }, 18 | "definitionInRemote": { 19 | "$ref": "http://localhost/child-ref#/definitions/SubSchema" 20 | }, 21 | "pointerToIdIsJsonPointer": { 22 | "$ref": "#/definitions/pointer" 23 | } 24 | }, 25 | "definitions": { 26 | "$id": "folder/", 27 | "Foo": { 28 | "$ref": "folderInteger.json" 29 | }, 30 | "Bar": { 31 | "description": "dummy schema at #/definitions/Bar" 32 | }, 33 | "HasId": { 34 | "$id": "has-id", 35 | "description": "it has document-local identifier" 36 | }, 37 | "IdIsJsonPointer": { 38 | "$id": "#/definitions/pointer", 39 | "description": "the ID can be a JSON pointer" 40 | }, 41 | "someAllOf": { 42 | "allOf": [ 43 | { 44 | "$id": "all-of-part-0", 45 | "type": "boolean" 46 | } 47 | ] 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/registered-uris/ref-example-org.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "http://example.org" 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/registered-uris/ref-urn-fragment.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "urn:uuid:a773c7a2-1a13-4f6a-a70d-694befe0ce63#/definitions/A" 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/registered-uris/ref-urn.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "urn:uuid:a773c7a2-1a13-4f6a-a70d-694befe0ce63" 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/registered-uris/schema-by-urn.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "schema-by-urn", 3 | "definitions": { 4 | "A": { 5 | "title": "subschema-by-urn" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/arrayschema-contains.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "contains": { 4 | "type": "boolean" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/arrayschema-list.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "uniqueItems": true, 4 | "minItems": 5, 5 | "maxItems": 10, 6 | "items": { 7 | "type": "boolean" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/arrayschema-tuple.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "array", 3 | "uniqueItems": true, 4 | "minItems": 5, 5 | "maxItems": 10, 6 | "items": [ 7 | { 8 | "type" : "boolean" 9 | }, 10 | { 11 | "type" : "boolean" 12 | } 13 | ], 14 | "additionalItems" : { 15 | "type" : "array", 16 | "maxItems" : 2 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/boolean-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft-07/schema", 3 | "$id": "bool-id", 4 | "type": "boolean", 5 | "title": "bool-title", 6 | "description": "bool-description" 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/conditionalschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "if": true, 3 | "then": { 4 | "type": "object", 5 | "required": [ 6 | "prop" 7 | ] 8 | }, 9 | "else": {} 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/custom-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "custom": "schema", 3 | "description": "descr-custom" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/draft6-schema-id.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema", 3 | "$id": "root-schema", 4 | "type": "object", 5 | "properties": { 6 | "a": { 7 | "$id": "prop-a", 8 | "type": "object", 9 | "description": "$id in subschema should work", 10 | "properties": { 11 | "b": { 12 | "$schema": "http://json-schema.org/draft-04/schema", 13 | "description": "$schema override should be ignored", 14 | "$id": "prop-a-b" 15 | } 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/nonstring-schema-keyword.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": 42, 3 | "id": "my-id" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/null-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "null", 3 | "description": "it can only be null" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/numberschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "number", 3 | "minimum": 0, 4 | "maximum": 10, 5 | "multipleOf": 5, 6 | "exclusiveMinimum": true, 7 | "exclusiveMaximum": true 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/objectschema-default.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "a": { 5 | "default": { 6 | "description": "default empty value" 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/objectschema-propertynames.json: -------------------------------------------------------------------------------- 1 | { 2 | "required" : ["a", "aa"], 3 | "propertyNames": { 4 | "type": "string", 5 | "minLength": 3 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/objectschema-schemadep.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "prop1" : { 4 | "properties" : { 5 | "prop2": { 6 | "type": "number" 7 | }, 8 | "prop3": { 9 | "type" : "boolean" 10 | } 11 | } 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/objectschema-unprocessed.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "numprop": { 5 | "type": "number" 6 | } 7 | }, 8 | "minProperties": 3, 9 | "maxProperties": 4, 10 | "required": [ 11 | "numprop" 12 | ], 13 | "additionalProperties": { 14 | "type": "boolean" 15 | }, 16 | "dependencies": { 17 | "prop1": [ 18 | "prop2", 19 | "prop3" 20 | ] 21 | }, 22 | "patternProperties": { 23 | "pattern_.*": { 24 | "type": "boolean" 25 | } 26 | }, 27 | "unproc0": true, 28 | "unproc1": false, 29 | "unproc2": null, 30 | "unproc3": 2, 31 | "unproc4": { 32 | "a": 1 33 | }, 34 | "unproc5": [ 35 | 2, 36 | 3, 37 | null 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/objectschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "numprop": { 5 | "type": "number" 6 | } 7 | }, 8 | "minProperties": 3, 9 | "maxProperties": 4, 10 | "required": [ 11 | "numprop" 12 | ], 13 | "additionalProperties": { 14 | "type": "boolean" 15 | }, 16 | "dependencies": { 17 | "prop1": [ 18 | "prop2", 19 | "prop3" 20 | ] 21 | }, 22 | "patternProperties": { 23 | "pattern_.*": { 24 | "type": "boolean" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "prop": { 4 | "$ref" : "#/definitions/Ref" 5 | } 6 | }, 7 | "definitions" : { 8 | "Ref" : { 9 | "type" : "number" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/stringschema-readonly-true-writeonly-false.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "string", 3 | "readOnly": true, 4 | "writeOnly": false 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/stringschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "string", 3 | "minLength": 0, 4 | "maxLength": 10, 5 | "pattern": "a.b*c", 6 | "format": "date-time" 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/tostring/unrecognized-schema-keyword.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://example.org/nonexistent.json", 3 | "id": "my-id" 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/org/everit/jsonvalidator/v4-referred-subschema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema", 3 | "definitions": { 4 | "SubSchema": { 5 | "minimum": 2, 6 | "exclusiveMinimum": true 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /donate.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everit-org/json-schema/e00a94ef6ee4fbda9b31afbed4d675875dcb6ae6/donate.jpg -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | 6 | org.everit.json 7 | org.everit.json.schema.parent 8 | 0.0.0-develop 9 | 10 | pom 11 | 12 | 13 | core 14 | tests 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tests/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.everit.json 6 | org.everit.json.schema.parent 7 | 0.0.0-develop 8 | 9 | 10 | org.everit.json.schema.tests.parent 11 | 12 | pom 13 | 14 | 15 | vanilla 16 | android 17 | slim 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/CustomDateTimeFormatValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.text.DateFormat; 4 | import java.text.ParseException; 5 | import java.text.SimpleDateFormat; 6 | import java.util.Optional; 7 | 8 | import org.everit.json.schema.internal.DateTimeFormatValidator; 9 | 10 | public class CustomDateTimeFormatValidator extends DateTimeFormatValidator { 11 | 12 | private static final String DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; 13 | private DateFormat dateFormat; 14 | 15 | public CustomDateTimeFormatValidator() { 16 | dateFormat = new SimpleDateFormat(DATE_TIME_FORMAT); 17 | dateFormat.setLenient(false); 18 | } 19 | 20 | @Override 21 | public Optional validate(String subject) { 22 | try { 23 | dateFormat.parse(subject); 24 | return Optional.empty(); 25 | } catch (ParseException e) { 26 | return Optional.of(String.format("[%s] is not a valid %s. Expected %s", subject, formatName(), DATE_TIME_FORMAT)); 27 | } 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/EmptyObjectTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStreamReader; 5 | 6 | import org.apache.commons.io.IOUtils; 7 | import org.everit.json.schema.loader.SchemaLoader; 8 | import org.json.JSONObject; 9 | import org.json.JSONTokener; 10 | import org.junit.jupiter.api.Test; 11 | 12 | import static org.junit.jupiter.api.Assertions.assertEquals; 13 | 14 | public class EmptyObjectTest { 15 | 16 | @Test 17 | public void validateEmptyObject() throws IOException { 18 | JSONObject jsonSchema = new JSONObject(new JSONTokener(IOUtils.toString( 19 | new InputStreamReader(getClass().getResourceAsStream("/org/everit/json/schema/json-schema-draft-04.json"))))); 20 | 21 | JSONObject jsonSubject = new JSONObject("{\n" + 22 | " \"type\": \"object\",\n" + 23 | " \"properties\": {}\n" + 24 | "}"); 25 | 26 | Schema schema = SchemaLoader.load(jsonSchema); 27 | schema.validate(jsonSubject); 28 | 29 | assertEquals(schema, SchemaLoader.load(jsonSchema)); 30 | assertEquals(schema.hashCode(), SchemaLoader.load(jsonSchema).hashCode()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/EvenCharNumValidator.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.util.Optional; 4 | 5 | public class EvenCharNumValidator implements FormatValidator { 6 | 7 | @Override 8 | public Optional validate(final String subject) { 9 | if (subject.length() % 2 == 0) { 10 | return Optional.empty(); 11 | } else { 12 | return Optional.of(String.format("the length of srtring [%s] is odd", subject)); 13 | } 14 | } 15 | 16 | @Override 17 | public String formatName() { 18 | return "evenlength"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/InvalidObjectInArrayTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.io.IOException; 4 | import java.io.UncheckedIOException; 5 | 6 | import org.apache.commons.io.Charsets; 7 | import org.apache.commons.io.IOUtils; 8 | import org.everit.json.schema.loader.SchemaLoader; 9 | import org.json.JSONObject; 10 | import org.json.JSONTokener; 11 | import org.junit.jupiter.api.Assertions; 12 | import org.junit.jupiter.api.Test; 13 | 14 | public class InvalidObjectInArrayTest { 15 | 16 | private JSONObject readObject(final String fileName) { 17 | try { 18 | return new JSONObject(new JSONTokener(IOUtils.toString(getClass() 19 | .getResourceAsStream("/org/everit/json/schema/invalidobjectinarray/" + fileName), Charsets.toCharset("UTF-8")))); 20 | } catch (IOException e) { 21 | throw new UncheckedIOException(e); 22 | } 23 | } 24 | 25 | @Test 26 | public void test() { 27 | Schema schema = SchemaLoader.load(readObject("schema.json")); 28 | Object subject = readObject("subject.json"); 29 | try { 30 | schema.validate(subject); 31 | Assertions.fail("did not throw exception"); 32 | } catch (ValidationException e) { 33 | Assertions.assertEquals("#/notification/target/apps/0/id", e.getPointerToViolation()); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/JettyWrapper.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.eclipse.jetty.server.Server; 4 | import org.eclipse.jetty.servlet.ServletHandler; 5 | import org.eclipse.jetty.servlet.ServletHolder; 6 | 7 | /** 8 | * @author erosb 9 | */ 10 | class JettyWrapper { 11 | 12 | private Server server; 13 | 14 | JettyWrapper(String documentRootPath) { 15 | server = new Server(1234); 16 | ServletHandler handler = new ServletHandler(); 17 | server.setHandler(handler); 18 | handler.addServletWithMapping(new ServletHolder(new IssueServlet(documentRootPath)), "/*"); 19 | try { 20 | server.start(); 21 | } catch (Exception e) { 22 | throw new RuntimeException(e); 23 | } 24 | } 25 | 26 | public void start() { 27 | try { 28 | server.start(); 29 | } catch (Exception e) { 30 | throw new RuntimeException(e); 31 | } 32 | } 33 | 34 | public void stop() { 35 | try { 36 | server.stop(); 37 | } catch (Exception e) { 38 | throw new RuntimeException(e); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/MetaSchemaTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStreamReader; 5 | 6 | import org.apache.commons.io.IOUtils; 7 | import org.everit.json.schema.loader.SchemaLoader; 8 | import org.json.JSONObject; 9 | import org.json.JSONTokener; 10 | import org.junit.jupiter.api.Test; 11 | 12 | public class MetaSchemaTest { 13 | 14 | @Test 15 | public void validateMetaSchema() throws IOException { 16 | 17 | JSONObject jsonSchema = new JSONObject(new JSONTokener( 18 | IOUtils.toString( 19 | new InputStreamReader(getClass().getResourceAsStream("/org/everit/json/schema/json-schema-draft-04.json"))) 20 | )); 21 | 22 | Schema schema = SchemaLoader.load(jsonSchema); 23 | schema.validate(jsonSchema); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/RelativeURITest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import org.apache.commons.io.IOUtils; 4 | import org.everit.json.schema.loader.SchemaLoader; 5 | import org.json.JSONObject; 6 | import org.json.JSONTokener; 7 | import org.junit.jupiter.api.Test; 8 | 9 | public class RelativeURITest { 10 | 11 | @Test 12 | public void test() throws Exception { 13 | System.out.println(JettyWrapper.class 14 | .getResource("/org/everit/json/schema/relative-uri/").toExternalForm()); 15 | 16 | JettyWrapper jetty = new JettyWrapper("/org/everit/json/schema/relative-uri"); 17 | jetty.start(); 18 | try { 19 | SchemaLoader.builder() 20 | .resolutionScope("http://localhost:1234/schema/") 21 | .schemaJson( 22 | new JSONObject(new JSONTokener(IOUtils.toString(getClass().getResourceAsStream( 23 | "/org/everit/json/schema/relative-uri/schema/main.json"))))) 24 | .build().load().build(); 25 | } finally { 26 | jetty.stop(); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/java/org/everit/json/schema/V4TestSuiteTest.java: -------------------------------------------------------------------------------- 1 | package org.everit.json.schema; 2 | 3 | import java.util.List; 4 | 5 | import org.everit.json.schema.loader.SchemaLoader; 6 | 7 | import org.junit.jupiter.api.AfterAll; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.params.ParameterizedTest; 10 | import org.junit.jupiter.params.provider.Arguments; 11 | import org.junit.jupiter.params.provider.MethodSource; 12 | 13 | public class V4TestSuiteTest { 14 | 15 | private static JettyWrapper server; 16 | 17 | public static List params() { 18 | return TestCase.loadAsParamsFromPackage("org.everit.json.schema.draft4"); 19 | } 20 | 21 | @BeforeAll 22 | public static void startJetty() throws Exception { 23 | (server = new JettyWrapper("/org/everit/json/schema/remotes")).start(); 24 | } 25 | 26 | @AfterAll 27 | public static void stopJetty() throws Exception { 28 | server.stop(); 29 | } 30 | 31 | @ParameterizedTest 32 | @MethodSource("params") 33 | public void testInCollectingMode(TestCase tc) { 34 | tc.loadSchema(SchemaLoader.builder()); 35 | tc.runTestInCollectingMode(); 36 | } 37 | 38 | @ParameterizedTest 39 | @MethodSource("params") 40 | public void testInEarlyFailingMode(TestCase tc) { 41 | tc.loadSchema(SchemaLoader.builder()); 42 | tc.runTestInEarlyFailureMode(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/default.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "invalid type for default", 4 | "schema": { 5 | "properties": { 6 | "foo": { 7 | "type": "integer", 8 | "default": [] 9 | } 10 | } 11 | }, 12 | "tests": [ 13 | { 14 | "description": "valid when property is specified", 15 | "data": { 16 | "foo": 13 17 | }, 18 | "valid": true 19 | }, 20 | { 21 | "description": "still valid when the invalid default is used", 22 | "data": {}, 23 | "valid": true 24 | } 25 | ] 26 | }, 27 | { 28 | "description": "invalid string value for default", 29 | "schema": { 30 | "properties": { 31 | "bar": { 32 | "type": "string", 33 | "minLength": 4, 34 | "default": "bad" 35 | } 36 | } 37 | }, 38 | "tests": [ 39 | { 40 | "description": "valid when property is specified", 41 | "data": { 42 | "bar": "good" 43 | }, 44 | "valid": true 45 | }, 46 | { 47 | "description": "still valid when the invalid default is used", 48 | "data": {}, 49 | "valid": true 50 | } 51 | ] 52 | } 53 | ] 54 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "valid definition", 4 | "schema": { 5 | "$ref": "http://json-schema.org/draft-04/schema#" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "valid definition schema", 10 | "data": { 11 | "definitions": { 12 | "foo": { 13 | "type": "integer" 14 | } 15 | } 16 | }, 17 | "valid": true 18 | } 19 | ] 20 | }, 21 | { 22 | "description": "invalid definition", 23 | "schema": { 24 | "$ref": "http://json-schema.org/draft-04/schema#" 25 | }, 26 | "tests": [ 27 | { 28 | "description": "invalid definition schema", 29 | "data": { 30 | "definitions": { 31 | "foo": { 32 | "type": 1 33 | } 34 | } 35 | }, 36 | "valid": false 37 | } 38 | ] 39 | } 40 | ] 41 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/email.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of e-mail addresses", 4 | "schema": { 5 | "format": "email" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid e-mail address", 10 | "data": "joe.bloggs@example.com", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an invalid e-mail address", 15 | "data": "2962", 16 | "valid": false 17 | } 18 | ] 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/hostname.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of host names", 4 | "schema": { 5 | "format": "hostname" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid host name", 10 | "data": "www.example.com", 11 | "valid": true 12 | }, 13 | { 14 | "description": "a host name starting with an illegal character", 15 | "data": "-a-host-name-that-starts-with--", 16 | "valid": false 17 | }, 18 | { 19 | "description": "a host name containing illegal characters", 20 | "data": "not_a_valid_host_name", 21 | "valid": false 22 | }, 23 | { 24 | "description": "a host name with a component too long", 25 | "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", 26 | "valid": false 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/ipv4.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IP addresses", 4 | "schema": { 5 | "format": "ipv4" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid IP address", 10 | "data": "192.168.0.1", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an IP address with too many components", 15 | "data": "127.0.0.0.1", 16 | "valid": false 17 | }, 18 | { 19 | "description": "an IP address with out-of-range values", 20 | "data": "256.256.256.256", 21 | "valid": false 22 | }, 23 | { 24 | "description": "an IP address without 4 components", 25 | "data": "127.0", 26 | "valid": false 27 | }, 28 | { 29 | "description": "an IP address as an integer", 30 | "data": "0x7f000001", 31 | "valid": false 32 | } 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/ipv6.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IPv6 addresses", 4 | "schema": { 5 | "format": "ipv6" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid IPv6 address", 10 | "data": "::1", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an IPv6 address with out-of-range values", 15 | "data": "12345::", 16 | "valid": false 17 | }, 18 | { 19 | "description": "an IPv6 address with too many components", 20 | "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", 21 | "valid": false 22 | }, 23 | { 24 | "description": "an IPv6 address containing illegal characters", 25 | "data": "::laptop", 26 | "valid": false 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/items.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "a schema given for items", 4 | "schema": { 5 | "items": { 6 | "type": "integer" 7 | } 8 | }, 9 | "tests": [ 10 | { 11 | "description": "valid items", 12 | "data": [ 13 | 1, 14 | 2, 15 | 3 16 | ], 17 | "valid": true 18 | }, 19 | { 20 | "description": "wrong type of items", 21 | "data": [ 22 | 1, 23 | "x" 24 | ], 25 | "valid": false 26 | }, 27 | { 28 | "description": "ignores non-arrays", 29 | "data": { 30 | "foo": "bar" 31 | }, 32 | "valid": true 33 | } 34 | ] 35 | }, 36 | { 37 | "description": "an array of schemas for items", 38 | "schema": { 39 | "items": [ 40 | { 41 | "type": "integer" 42 | }, 43 | { 44 | "type": "string" 45 | } 46 | ] 47 | }, 48 | "tests": [ 49 | { 50 | "description": "correct types", 51 | "data": [ 52 | 1, 53 | "foo" 54 | ], 55 | "valid": true 56 | }, 57 | { 58 | "description": "wrong types", 59 | "data": [ 60 | "foo", 61 | 1 62 | ], 63 | "valid": false 64 | } 65 | ] 66 | } 67 | ] 68 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": { 5 | "maxItems": 2 6 | }, 7 | "tests": [ 8 | { 9 | "description": "shorter is valid", 10 | "data": [ 11 | 1 12 | ], 13 | "valid": true 14 | }, 15 | { 16 | "description": "exact length is valid", 17 | "data": [ 18 | 1, 19 | 2 20 | ], 21 | "valid": true 22 | }, 23 | { 24 | "description": "too long is invalid", 25 | "data": [ 26 | 1, 27 | 2, 28 | 3 29 | ], 30 | "valid": false 31 | }, 32 | { 33 | "description": "ignores non-arrays", 34 | "data": "foobar", 35 | "valid": true 36 | } 37 | ] 38 | } 39 | ] 40 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": { 5 | "maxLength": 2 6 | }, 7 | "tests": [ 8 | { 9 | "description": "shorter is valid", 10 | "data": "f", 11 | "valid": true 12 | }, 13 | { 14 | "description": "exact length is valid", 15 | "data": "fo", 16 | "valid": true 17 | }, 18 | { 19 | "description": "too long is invalid", 20 | "data": "foo", 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-strings", 25 | "data": 100, 26 | "valid": true 27 | }, 28 | { 29 | "description": "two supplementary Unicode code points is long enough", 30 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 31 | "valid": true 32 | } 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/maxProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxProperties validation", 4 | "schema": { 5 | "maxProperties": 2 6 | }, 7 | "tests": [ 8 | { 9 | "description": "shorter is valid", 10 | "data": { 11 | "foo": 1 12 | }, 13 | "valid": true 14 | }, 15 | { 16 | "description": "exact length is valid", 17 | "data": { 18 | "foo": 1, 19 | "bar": 2 20 | }, 21 | "valid": true 22 | }, 23 | { 24 | "description": "too long is invalid", 25 | "data": { 26 | "foo": 1, 27 | "bar": 2, 28 | "baz": 3 29 | }, 30 | "valid": false 31 | }, 32 | { 33 | "description": "ignores non-objects", 34 | "data": "foobar", 35 | "valid": true 36 | } 37 | ] 38 | } 39 | ] 40 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": { 5 | "maximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the maximum is valid", 10 | "data": 2.6, 11 | "valid": true 12 | }, 13 | { 14 | "description": "above the maximum is invalid", 15 | "data": 3.5, 16 | "valid": false 17 | }, 18 | { 19 | "description": "ignores non-numbers", 20 | "data": "x", 21 | "valid": true 22 | } 23 | ] 24 | }, 25 | { 26 | "description": "exclusiveMaximum validation", 27 | "schema": { 28 | "maximum": 3.0, 29 | "exclusiveMaximum": true 30 | }, 31 | "tests": [ 32 | { 33 | "description": "below the maximum is still valid", 34 | "data": 2.2, 35 | "valid": true 36 | }, 37 | { 38 | "description": "boundary point is invalid", 39 | "data": 3.0, 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": { 5 | "minItems": 1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "longer is valid", 10 | "data": [ 11 | 1, 12 | 2 13 | ], 14 | "valid": true 15 | }, 16 | { 17 | "description": "exact length is valid", 18 | "data": [ 19 | 1 20 | ], 21 | "valid": true 22 | }, 23 | { 24 | "description": "too short is invalid", 25 | "data": [], 26 | "valid": false 27 | }, 28 | { 29 | "description": "ignores non-arrays", 30 | "data": "", 31 | "valid": true 32 | } 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": { 5 | "minLength": 2 6 | }, 7 | "tests": [ 8 | { 9 | "description": "longer is valid", 10 | "data": "foo", 11 | "valid": true 12 | }, 13 | { 14 | "description": "exact length is valid", 15 | "data": "fo", 16 | "valid": true 17 | }, 18 | { 19 | "description": "too short is invalid", 20 | "data": "f", 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-strings", 25 | "data": 1, 26 | "valid": true 27 | }, 28 | { 29 | "description": "one supplementary Unicode code point is not long enough", 30 | "data": "\uD83D\uDCA9", 31 | "valid": false 32 | } 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": { 5 | "minProperties": 1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "longer is valid", 10 | "data": { 11 | "foo": 1, 12 | "bar": 2 13 | }, 14 | "valid": true 15 | }, 16 | { 17 | "description": "exact length is valid", 18 | "data": { 19 | "foo": 1 20 | }, 21 | "valid": true 22 | }, 23 | { 24 | "description": "too short is invalid", 25 | "data": {}, 26 | "valid": false 27 | }, 28 | { 29 | "description": "ignores non-objects", 30 | "data": "", 31 | "valid": true 32 | } 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/minimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minimum validation", 4 | "schema": { 5 | "minimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the minimum is valid", 10 | "data": 2.6, 11 | "valid": true 12 | }, 13 | { 14 | "description": "below the minimum is invalid", 15 | "data": 0.6, 16 | "valid": false 17 | }, 18 | { 19 | "description": "ignores non-numbers", 20 | "data": "x", 21 | "valid": true 22 | } 23 | ] 24 | }, 25 | { 26 | "description": "exclusiveMinimum validation", 27 | "schema": { 28 | "minimum": 1.1, 29 | "exclusiveMinimum": true 30 | }, 31 | "tests": [ 32 | { 33 | "description": "above the minimum is still valid", 34 | "data": 1.2, 35 | "valid": true 36 | }, 37 | { 38 | "description": "boundary point is invalid", 39 | "data": 1.1, 40 | "valid": false 41 | } 42 | ] 43 | } 44 | ] 45 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/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 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": { 5 | "pattern": "^a*$" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a matching pattern is valid", 10 | "data": "aaa", 11 | "valid": true 12 | }, 13 | { 14 | "description": "a non-matching pattern is invalid", 15 | "data": "abc", 16 | "valid": false 17 | }, 18 | { 19 | "description": "ignores non-strings", 20 | "data": true, 21 | "valid": true 22 | } 23 | ] 24 | }, 25 | { 26 | "description": "pattern is not anchored", 27 | "schema": { 28 | "pattern": "a+" 29 | }, 30 | "tests": [ 31 | { 32 | "description": "matches a substring", 33 | "data": "xxaayy", 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft4/required.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "required validation", 4 | "schema": { 5 | "properties": { 6 | "foo": {}, 7 | "bar": {} 8 | }, 9 | "required": [ 10 | "foo" 11 | ] 12 | }, 13 | "tests": [ 14 | { 15 | "description": "present required property is valid", 16 | "data": { 17 | "foo": 1 18 | }, 19 | "valid": true 20 | }, 21 | { 22 | "description": "non-present required property is invalid", 23 | "data": { 24 | "bar": 1 25 | }, 26 | "valid": false 27 | } 28 | ] 29 | }, 30 | { 31 | "description": "required default validation", 32 | "schema": { 33 | "properties": { 34 | "foo": {} 35 | } 36 | }, 37 | "tests": [ 38 | { 39 | "description": "not required by default", 40 | "data": {}, 41 | "valid": true 42 | } 43 | ] 44 | } 45 | ] 46 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "valid definition", 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 | }, 17 | { 18 | "description": "invalid definition", 19 | "schema": {"$ref": "http://json-schema.org/draft-06/schema#"}, 20 | "tests": [ 21 | { 22 | "description": "invalid definition schema", 23 | "data": { 24 | "definitions": { 25 | "foo": {"type": 1} 26 | } 27 | }, 28 | "valid": false 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/email.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of e-mail addresses", 4 | "schema": { 5 | "format": "email" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid e-mail address", 10 | "data": "joe.bloggs@example.com", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an invalid e-mail address", 15 | "data": "2962", 16 | "valid": false 17 | } 18 | ] 19 | } 20 | ] 21 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "exclusiveMaximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the exclusiveMaximum is valid", 10 | "data": 2.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 3.0, 16 | "valid": false 17 | }, 18 | { 19 | "description": "above the exclusiveMaximum is invalid", 20 | "data": 3.5, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "exclusiveMinimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the exclusiveMinimum is valid", 10 | "data": 1.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 1.1, 16 | "valid": false 17 | }, 18 | { 19 | "description": "below the exclusiveMinimum is invalid", 20 | "data": 0.6, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/hostname.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of host names", 4 | "schema": { 5 | "format": "hostname" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid host name", 10 | "data": "www.example.com", 11 | "valid": true 12 | }, 13 | { 14 | "description": "a host name starting with an illegal character", 15 | "data": "-a-host-name-that-starts-with--", 16 | "valid": false 17 | }, 18 | { 19 | "description": "a host name containing illegal characters", 20 | "data": "not_a_valid_host_name", 21 | "valid": false 22 | }, 23 | { 24 | "description": "a host name with a component too long", 25 | "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", 26 | "valid": false 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/ipv4.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IP addresses", 4 | "schema": { 5 | "format": "ipv4" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid IP address", 10 | "data": "192.168.0.1", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an IP address with too many components", 15 | "data": "127.0.0.0.1", 16 | "valid": false 17 | }, 18 | { 19 | "description": "an IP address with out-of-range values", 20 | "data": "256.256.256.256", 21 | "valid": false 22 | }, 23 | { 24 | "description": "an IP address without 4 components", 25 | "data": "127.0", 26 | "valid": false 27 | }, 28 | { 29 | "description": "an IP address as an integer", 30 | "data": "0x7f000001", 31 | "valid": false 32 | } 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/ipv6.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IPv6 addresses", 4 | "schema": { 5 | "format": "ipv6" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid IPv6 address", 10 | "data": "::1", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an IPv6 address with out-of-range values", 15 | "data": "12345::", 16 | "valid": false 17 | }, 18 | { 19 | "description": "an IPv6 address with too many components", 20 | "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", 21 | "valid": false 22 | }, 23 | { 24 | "description": "an IPv6 address containing illegal characters", 25 | "data": "::laptop", 26 | "valid": false 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/maxProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxProperties validation", 4 | "schema": {"maxProperties": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": {"foo": 1}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1, "bar": 2}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": {"foo": 1, "bar": 2, "baz": 3}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [1, 2, 3], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "foobar", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": {"maximum": 3.0}, 5 | "tests": [ 6 | { 7 | "description": "below the maximum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 3.0, 14 | "valid": true 15 | }, 16 | { 17 | "description": "above the maximum is invalid", 18 | "data": 3.5, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/minimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minimum validation", 4 | "schema": {"minimum": 1.1}, 5 | "tests": [ 6 | { 7 | "description": "above the minimum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 1.1, 14 | "valid": true 15 | }, 16 | { 17 | "description": "below the minimum is invalid", 18 | "data": 0.6, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/optional/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "ECMA 262 regex non-compliance", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "ECMA 262 has no support for \\Z anchor from .NET", 8 | "data": "^\\S(|(.|\\n)*\\S)\\Z", 9 | "valid": false 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/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 without fractional part is an integer", 10 | "data": 1.0, 11 | "valid": true 12 | } 13 | ] 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores non-strings", 18 | "data": true, 19 | "valid": true 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "pattern is not anchored", 25 | "schema": {"pattern": "a+"}, 26 | "tests": [ 27 | { 28 | "description": "matches a substring", 29 | "data": "xxaayy", 30 | "valid": true 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft6/uri-template.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "format: uri-template", 4 | "schema": { 5 | "format": "uri-template" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid uri-template", 10 | "data": "http://example.com/dictionary/{term:1}/{term}", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an invalid uri-template", 15 | "data": "http://example.com/dictionary/{term:1}/{term", 16 | "valid": false 17 | }, 18 | { 19 | "description": "a valid uri-template without variables", 20 | "data": "http://example.com/dictionary", 21 | "valid": true 22 | }, 23 | { 24 | "description": "a valid relative uri-template", 25 | "data": "dictionary/{term:1}/{term}", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/date-time.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of date-time strings", 4 | "schema": {"format": "date-time"}, 5 | "tests": [ 6 | { 7 | "description": "a valid date-time string", 8 | "data": "1963-06-19T08:30:06.283185Z", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid date-time string", 13 | "data": "06/19/1963 08:30:06 PST", 14 | "valid": false 15 | }, 16 | { 17 | "description": "only RFC3339 not all of ISO 8601 are valid", 18 | "data": "2013-350T01:01:01", 19 | "valid": false 20 | } 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/date.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of date strings", 4 | "schema": {"format": "date"}, 5 | "tests": [ 6 | { 7 | "description": "a valid date string", 8 | "data": "1963-06-19", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid date-time string", 13 | "data": "06/19/1963", 14 | "valid": false 15 | }, 16 | { 17 | "description": "only RFC3339 not all of ISO 8601 are valid", 18 | "data": "2013-350", 19 | "valid": false 20 | } 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/definitions.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "valid definition", 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 | }, 17 | { 18 | "description": "invalid definition", 19 | "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, 20 | "tests": [ 21 | { 22 | "description": "invalid definition schema", 23 | "data": { 24 | "definitions": { 25 | "foo": {"type": 1} 26 | } 27 | }, 28 | "valid": false 29 | } 30 | ] 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/email.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of e-mail addresses", 4 | "schema": {"format": "email"}, 5 | "tests": [ 6 | { 7 | "description": "a valid e-mail address", 8 | "data": "joe.bloggs@example.com", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid e-mail address", 13 | "data": "2962", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/exclusiveMaximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMaximum validation", 4 | "schema": { 5 | "exclusiveMaximum": 3.0 6 | }, 7 | "tests": [ 8 | { 9 | "description": "below the exclusiveMaximum is valid", 10 | "data": 2.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 3.0, 16 | "valid": false 17 | }, 18 | { 19 | "description": "above the exclusiveMaximum is invalid", 20 | "data": 3.5, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/exclusiveMinimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "exclusiveMinimum validation", 4 | "schema": { 5 | "exclusiveMinimum": 1.1 6 | }, 7 | "tests": [ 8 | { 9 | "description": "above the exclusiveMinimum is valid", 10 | "data": 1.2, 11 | "valid": true 12 | }, 13 | { 14 | "description": "boundary point is invalid", 15 | "data": 1.1, 16 | "valid": false 17 | }, 18 | { 19 | "description": "below the exclusiveMinimum is invalid", 20 | "data": 0.6, 21 | "valid": false 22 | }, 23 | { 24 | "description": "ignores non-numbers", 25 | "data": "x", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/hostname.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of host names", 4 | "schema": {"format": "hostname"}, 5 | "tests": [ 6 | { 7 | "description": "a valid host name", 8 | "data": "www.example.com", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a valid punycoded IDN hostname", 13 | "data": "xn--4gbwdl.xn--wgbh1c", 14 | "valid": true 15 | }, 16 | { 17 | "description": "a host name starting with an illegal character", 18 | "data": "-a-host-name-that-starts-with--", 19 | "valid": false 20 | }, 21 | { 22 | "description": "a host name containing illegal characters", 23 | "data": "not_a_valid_host_name", 24 | "valid": false 25 | }, 26 | { 27 | "description": "a host name with a component too long", 28 | "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/ipv4.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IP addresses", 4 | "schema": {"format": "ipv4"}, 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 | "description": "an IP address without 4 components", 23 | "data": "127.0", 24 | "valid": false 25 | }, 26 | { 27 | "description": "an IP address as an integer", 28 | "data": "0x7f000001", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/ipv6.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of IPv6 addresses", 4 | "schema": {"format": "ipv6"}, 5 | "tests": [ 6 | { 7 | "description": "a valid IPv6 address", 8 | "data": "::1", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an IPv6 address with out-of-range values", 13 | "data": "12345::", 14 | "valid": false 15 | }, 16 | { 17 | "description": "an IPv6 address with too many components", 18 | "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", 19 | "valid": false 20 | }, 21 | { 22 | "description": "an IPv6 address containing illegal characters", 23 | "data": "::laptop", 24 | "valid": false 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/maxItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxItems validation", 4 | "schema": {"maxItems": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": [1], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1, 2], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": [1, 2, 3], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "foobar", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/maxLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxLength validation", 4 | "schema": {"maxLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": "f", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": "foo", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 100, 24 | "valid": true 25 | }, 26 | { 27 | "description": "two supplementary Unicode code points is long enough", 28 | "data": "\uD83D\uDCA9\uD83D\uDCA9", 29 | "valid": true 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/maxProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maxProperties validation", 4 | "schema": {"maxProperties": 2}, 5 | "tests": [ 6 | { 7 | "description": "shorter is valid", 8 | "data": {"foo": 1}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1, "bar": 2}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too long is invalid", 18 | "data": {"foo": 1, "bar": 2, "baz": 3}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [1, 2, 3], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "foobar", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/maximum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "maximum validation", 4 | "schema": {"maximum": 3.0}, 5 | "tests": [ 6 | { 7 | "description": "below the maximum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 3.0, 14 | "valid": true 15 | }, 16 | { 17 | "description": "above the maximum is invalid", 18 | "data": 3.5, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/minItems.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minItems validation", 4 | "schema": {"minItems": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": [1, 2], 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": [1], 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": [], 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-arrays", 23 | "data": "", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/minLength.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minLength validation", 4 | "schema": {"minLength": 2}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": "foo", 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": "fo", 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": "f", 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-strings", 23 | "data": 1, 24 | "valid": true 25 | }, 26 | { 27 | "description": "one supplementary Unicode code point is not long enough", 28 | "data": "\uD83D\uDCA9", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/minProperties.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minProperties validation", 4 | "schema": {"minProperties": 1}, 5 | "tests": [ 6 | { 7 | "description": "longer is valid", 8 | "data": {"foo": 1, "bar": 2}, 9 | "valid": true 10 | }, 11 | { 12 | "description": "exact length is valid", 13 | "data": {"foo": 1}, 14 | "valid": true 15 | }, 16 | { 17 | "description": "too short is invalid", 18 | "data": {}, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores arrays", 23 | "data": [], 24 | "valid": true 25 | }, 26 | { 27 | "description": "ignores strings", 28 | "data": "", 29 | "valid": true 30 | }, 31 | { 32 | "description": "ignores other non-objects", 33 | "data": 12, 34 | "valid": true 35 | } 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/minimum.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "minimum validation", 4 | "schema": {"minimum": 1.1}, 5 | "tests": [ 6 | { 7 | "description": "above the minimum is valid", 8 | "data": 2.6, 9 | "valid": true 10 | }, 11 | { 12 | "description": "boundary point is valid", 13 | "data": 1.1, 14 | "valid": true 15 | }, 16 | { 17 | "description": "below the minimum is invalid", 18 | "data": 0.6, 19 | "valid": false 20 | }, 21 | { 22 | "description": "ignores non-numbers", 23 | "data": "x", 24 | "valid": true 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/optional/ecmascript-regex.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "ECMA 262 regex non-compliance", 4 | "schema": { "format": "regex" }, 5 | "tests": [ 6 | { 7 | "description": "ECMA 262 has no support for \\Z anchor from .NET", 8 | "data": "^\\S(|(.|\\n)*\\S)\\Z", 9 | "valid": false 10 | } 11 | ] 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/optional/idn-email.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of an internationalized e-mail addresses", 4 | "schema": {"format": "idn-email"}, 5 | "tests": [ 6 | { 7 | "description": "a valid idn e-mail (example@example.test in Hangul)", 8 | "data": "실례@실례.테스트", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid idn e-mail address", 13 | "data": "2962", 14 | "valid": false 15 | } 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/optional/idn-hostname.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of internationalized host names", 4 | "schema": {"format": "idn-hostname"}, 5 | "tests": [ 6 | { 7 | "description": "a valid host name (example.test in Hangul)", 8 | "data": "실례.테스트", 9 | "valid": true 10 | }, 11 | { 12 | "description": "illegal first char U+302E Hangul single dot tone mark", 13 | "data": "〮실례.테스트", 14 | "valid": false 15 | }, 16 | { 17 | "description": "contains illegal char U+302E Hangul single dot tone mark", 18 | "data": "실〮례.테스트", 19 | "valid": false 20 | }, 21 | { 22 | "description": "a host name with a component too long", 23 | "data": "실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실례례테스트례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례테스트례례실례.테스트", 24 | "valid": false 25 | } 26 | ] 27 | } 28 | ] 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/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 without fractional part is an integer", 10 | "data": 1.0, 11 | "valid": true 12 | } 13 | ] 14 | } 15 | ] 16 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/pattern.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "pattern validation", 4 | "schema": {"pattern": "^a*$"}, 5 | "tests": [ 6 | { 7 | "description": "a matching pattern is valid", 8 | "data": "aaa", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a non-matching pattern is invalid", 13 | "data": "abc", 14 | "valid": false 15 | }, 16 | { 17 | "description": "ignores non-strings", 18 | "data": true, 19 | "valid": true 20 | } 21 | ] 22 | }, 23 | { 24 | "description": "pattern is not anchored", 25 | "schema": {"pattern": "a+"}, 26 | "tests": [ 27 | { 28 | "description": "matches a substring", 29 | "data": "xxaayy", 30 | "valid": true 31 | } 32 | ] 33 | } 34 | ] 35 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/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 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/relative-json-pointer.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "validation of Relative JSON Pointers (RJP)", 4 | "schema": {"format": "relative-json-pointer"}, 5 | "tests": [ 6 | { 7 | "description": "a valid upwards RJP", 8 | "data": "1", 9 | "valid": true 10 | }, 11 | { 12 | "description": "a valid downwards RJP", 13 | "data": "0/foo/bar", 14 | "valid": true 15 | }, 16 | { 17 | "description": "a valid up and then down RJP, with array index", 18 | "data": "2/0/baz/1/zip", 19 | "valid": true 20 | }, 21 | { 22 | "description": "a valid RJP taking the member or index name", 23 | "data": "0#", 24 | "valid": true 25 | }, 26 | { 27 | "description": "an invalid RJP that is a valid JSON Pointer", 28 | "data": "/foo/bar", 29 | "valid": false 30 | } 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/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.283185Z", 9 | "valid": true 10 | }, 11 | { 12 | "description": "an invalid time string", 13 | "data": "08:30:06 PST", 14 | "valid": false 15 | }, 16 | { 17 | "description": "only RFC3339 not all of ISO 8601 are valid", 18 | "data": "01:01:01,1111", 19 | "valid": false 20 | } 21 | ] 22 | } 23 | ] 24 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/draft7/uri-template.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "description": "format: uri-template", 4 | "schema": { 5 | "format": "uri-template" 6 | }, 7 | "tests": [ 8 | { 9 | "description": "a valid uri-template", 10 | "data": "http://example.com/dictionary/{term:1}/{term}", 11 | "valid": true 12 | }, 13 | { 14 | "description": "an invalid uri-template", 15 | "data": "http://example.com/dictionary/{term:1}/{term", 16 | "valid": false 17 | }, 18 | { 19 | "description": "a valid uri-template without variables", 20 | "data": "http://example.com/dictionary", 21 | "valid": true 22 | }, 23 | { 24 | "description": "a valid relative uri-template", 25 | "data": "dictionary/{term:1}/{term}", 26 | "valid": true 27 | } 28 | ] 29 | } 30 | ] 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/invalidobjectinarray/subject.json: -------------------------------------------------------------------------------- 1 | { 2 | "notification": { 3 | "message": "test", 4 | "sound": "sounds/alarmsound.wav", 5 | "target": { 6 | "apps": [ 7 | { 8 | "id": "This should be a number type!", 9 | "platforms": [ 10 | "ios" 11 | ] 12 | } 13 | ] 14 | } 15 | }, 16 | "access_token": "access_token", 17 | "testNull": null, 18 | "testBoolean": true 19 | } 20 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/78/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaLocation": "#", 3 | "pointerToViolation": "#", 4 | "causingExceptions": [], 5 | "keyword": "maxItems", 6 | "message": "expected maximum item count: 1, found: 2" 7 | } 8 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/78/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "array", 3 | "maxItems" : 1 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/78/subject-invalid.json: -------------------------------------------------------------------------------- 1 | [1, 2] 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue125/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | { 4 | "properties": { 5 | "bar": { 6 | "type": "integer" 7 | } 8 | }, 9 | "required": [ 10 | "bar" 11 | ] 12 | }, 13 | { 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | }, 19 | "required": [ 20 | "foo" 21 | ] 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue125/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "bar": "quux", 3 | "foo": 2 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue125/validator-config.json: -------------------------------------------------------------------------------- 1 | {"failEarly":true} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue126/schema.json: -------------------------------------------------------------------------------- 1 | {"type":"object", "properties": {"prop": {"enum": [null, "foo", "bar"]}}} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue126/subject-valid.json: -------------------------------------------------------------------------------- 1 | {"prop": null} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue147/schema.json: -------------------------------------------------------------------------------- 1 | {"type":"object", "properties": {"prop": {"pattern": "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}}} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue147/subject-valid.json: -------------------------------------------------------------------------------- 1 | {"prop": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue147/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "regexpImplementation": "RE2J" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue152/remotes/customformat-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#", 3 | "properties": { 4 | "id": { 5 | "format": "evenlength", 6 | "maxLength": 10, 7 | "minLength": 3, 8 | "type": "string" 9 | } 10 | }, 11 | "required": [ 12 | "id" 13 | ], 14 | "type": "object" 15 | } 16 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue152/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "http://localhost:1234/customformat-schema.json", 3 | "$schema": "http://json-schema.org/draft-06/schema#" 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue152/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "everitorg" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue152/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "customFormats": { 3 | "evenlength": "org.everit.json.schema.EvenCharNumValidator" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue160/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "properties": { 5 | "date": { 6 | "type": "string", 7 | "format": "date" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue160/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": "2017-04-0" 3 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue164/remotes/v4-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema", 3 | "definitions": { 4 | "parameter": { 5 | "mininum": 2, 6 | "exclusiveMinimum": true 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue164/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#", 3 | "properties": { 4 | "parameter": { 5 | "type": "array", 6 | "items": { 7 | "$ref": "http://localhost:1234/v4-schema.json#/definitions/parameter" 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue164/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "parameter": [ 3 | { 4 | "name": "test", 5 | "in": "query", 6 | "type" : "string" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue17/remotes/yaala/_schemas/parent: -------------------------------------------------------------------------------- 1 | { 2 | "id":"http://localhost:1234/yaala/_schemas/parent#", 3 | "type":"object", 4 | "properties":{ "n":{ "type":"number" } }, 5 | "required":[ "n" ] 6 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue17/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://localhost:1234/yaala/_schemas/child#", 3 | "allOf": [ 4 | { 5 | "$ref": "parent" 6 | }, 7 | { 8 | "required": [ 9 | "s" 10 | ], 11 | "type": "object", 12 | "properties": { 13 | "s": { 14 | "type": "string" 15 | } 16 | } 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue17/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "n": "1", 3 | "s": "test" 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue17/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "n": 1, 3 | "s": "test" 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue174/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "JSON schema for JSONPatch files", 3 | "$schema": "http://json-schema.org/draft-04/schema#", 4 | "type": "object", 5 | "properties": { 6 | "prop": { 7 | "allOf": [ 8 | { 9 | "multipleOf": 2 10 | }, 11 | { 12 | "multipleOf": 3 13 | } 14 | ], 15 | "oneOf": [ 16 | { 17 | "enum": [ 18 | 1, 19 | 2 20 | ], 21 | "minimum": 3 22 | }, 23 | { 24 | "const": 1, 25 | "maximum": 0 26 | }, 27 | { 28 | "not": { 29 | "const": 2 30 | }, 31 | "const": 2 32 | } 33 | ] 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue174/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "prop": 4 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue182/remotes/schemaA.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "str": { 4 | "type": "string", 5 | "enum": [ 6 | "valueA1", 7 | "valueA2" 8 | ] 9 | } 10 | }, 11 | "$ref": "#/definitions/str" 12 | } 13 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue182/remotes/schemaB.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "str": { 4 | "type": "string", 5 | "enum": [ 6 | "valueB1", 7 | "valueB2" 8 | ] 9 | } 10 | }, 11 | "$ref": "#/definitions/str" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue182/remotes/schemaC.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "str": { 4 | "type": "string", 5 | "enum": [ 6 | "valueC1", 7 | "valueC2" 8 | ] 9 | } 10 | }, 11 | "$ref": "#/definitions/str" 12 | } 13 | 14 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue182/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "array", 4 | "items": { 5 | "$id": "http://localhost:1234/neverAccessed", 6 | "oneOf": [ 7 | { 8 | "$ref": "http://localhost:1234/schemaA.json#" 9 | }, 10 | { 11 | "$ref": "http://localhost:1234/schemaB.json#" 12 | }, 13 | { 14 | "$ref": "schemaC.json" 15 | } 16 | ] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue182/subject-valid.json: -------------------------------------------------------------------------------- 1 | [ 2 | "valueA1", 3 | "valueB1", 4 | "valueC1" 5 | ] 6 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue205/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#", 3 | "id": "http://hl7.org/fhir/test-json-schema/3.4", 4 | "description": "for unit tests", 5 | "discriminator": { 6 | "propertyName": "resourceType", 7 | "mapping": { 8 | "A": "#/definitions/A", 9 | "B": "#/definitions/B" 10 | } 11 | }, 12 | "oneOf": [ 13 | { 14 | "$ref": "#/definitions/A" 15 | }, 16 | { 17 | "$ref": "#/definitions/B" 18 | } 19 | ], 20 | "definitions": { 21 | "id": { 22 | "pattern": "^[A-Za-z0-9\\-\\.]{1,64}$", 23 | "type": "string" 24 | }, 25 | "A": { 26 | "properties": { 27 | "resourceType": { 28 | "const": "A" 29 | }, 30 | "id": { 31 | "$ref": "#/definitions/id" 32 | } 33 | }, 34 | "required": [ 35 | "resourceType" 36 | ] 37 | }, 38 | "B": { 39 | "properties": { 40 | "resourceType": { 41 | "const": "B" 42 | }, 43 | "code": { 44 | "$ref": "#/definitions/id" 45 | } 46 | }, 47 | "additionalProperties": false, 48 | "required": [ 49 | "resourceType", "code" 50 | ] 51 | } 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue205/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "resourceType" : "A" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue206/remotes/references/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "Example": { 4 | "type": "object", 5 | "properties": { 6 | "field": { 7 | "type": "string" 8 | } 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue206/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "reference": { 5 | "$ref": "example.json#/definitions/Example" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue206/subject-valid.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue206/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "resolutionScope": "http://localhost:1234/references/" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue217/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://myschema.org/mymetaschema#", 3 | "$id": "http://myschema.org/myschema#", 4 | "title": "My schema", 5 | "description": "My schema", 6 | "properties": { 7 | "prop1": { 8 | "type": "string", 9 | "ext1": "xxx", 10 | "ext2": { 11 | "foo": "bar" 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue217/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "prop1" : "foo" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue217/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaSchemaVersion": 7 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue22/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$schema": "http://json-schema.org/draft-04/schema#", 4 | "properties": { 5 | "date": { 6 | "type": "string", 7 | "format": "date-time" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue22/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "date": "" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue225/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "https://example.com/arrays.schema.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "description": "A representation of a person, company, organization, or place", 5 | "type": "object", 6 | "properties": { 7 | "fruits": { 8 | "type": "array", 9 | "items": { 10 | "type": "string" 11 | } 12 | }, 13 | "vegetables": { 14 | "type": "array", 15 | "items": { "$ref": "#/definitions/veggie" } 16 | } 17 | }, 18 | "definitions": { 19 | "veggie": { 20 | "type": "object", 21 | "required": [ "veggieName", "veggieLike" ], 22 | "properties": { 23 | "veggieName": { 24 | "type": "string", 25 | "description": "The name of the vegetable." 26 | }, 27 | "veggieLike": { 28 | "type": "boolean", 29 | "description": "Do I like this vegetable?" 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue225/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "fruits": [ "apple", "orange", "pear" ], 3 | "vegetables": [ 4 | { 5 | "veggieName": "potato" 6 | }, 7 | { 8 | "veggieName": "broccoli", 9 | "veggieLike": false 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue233/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaLocation": "http://localhost:1234/definitions.json#/definitions/address/properties/city", 3 | "pointerToViolation": "#/billing_address/city", 4 | "causingExceptions": [], 5 | "keyword": "type", 6 | "message": "expected type: String, found: Integer" 7 | } 8 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue233/remotes/definitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "address": { 4 | "type": "object", 5 | "properties": { 6 | "city": { "type": "string" }, 7 | "state": { "type": "string" } 8 | } 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue233/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "billing_address": { 4 | "$ref": "/definitions.json#/definitions/address" 5 | } 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue233/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "billing_address": { 3 | "city": 2 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue233/validator-config.json: -------------------------------------------------------------------------------- 1 | {"resolutionScope":"http://localhost:1234"} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue245/definitions.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "Str": { 4 | "type": "string", 5 | "maxLength": 3 6 | }, 7 | "Num": { 8 | "type": "integer", 9 | "maximum": 3 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue245/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "str": { 5 | "$ref": "classpath://org/everit/json/schema/issues/issue245/definitions.json#/definitions/Str" 6 | }, 7 | "num": { 8 | "$ref": "classpath:/org/everit/json/schema/issues/issue245/definitions.json#/definitions/Num" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue245/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "str": "aaaaa", 3 | "num": 10 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue245/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaClient": "classPathAware" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue246/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaLocation": "#", 3 | "pointerToViolation": "#", 4 | "causingExceptions": [ 5 | { 6 | "pointerToViolation": "#", 7 | "causingExceptions": [], 8 | "keyword": "type", 9 | "message": "expected: null, found: JSONArray" 10 | }, 11 | { 12 | "schemaLocation": "#/items", 13 | "pointerToViolation": "#/3", 14 | "causingExceptions": [ 15 | { 16 | "pointerToViolation": "#/3", 17 | "causingExceptions": [], 18 | "keyword": "enum", 19 | "message": "jibberish is not a valid enum value" 20 | } 21 | ], 22 | "keyword": "allOf", 23 | "message": "#: only 1 subschema matches out of 2" 24 | } 25 | ], 26 | "keyword": "anyOf", 27 | "message": "#: no subschema matched out of the total 2 subschemas" 28 | } 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue246/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "uniqueItems": true, 3 | "type": [ 4 | "array", 5 | "null" 6 | ], 7 | "items": { 8 | "type": "string", 9 | "enum": [ 10 | "Happy", 11 | "Sad", 12 | "Excited", 13 | "Angry" 14 | ] 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue246/subject-invalid.json: -------------------------------------------------------------------------------- 1 | [ 2 | "Happy", 3 | "Sad", 4 | "Excited", 5 | "jibberish" 6 | ] 7 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue25/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties" : { 3 | "weight" : { 4 | "type" : "number" 5 | } 6 | }, 7 | "additionalProperties" : false 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue25/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "weight" : -0 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue258/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$ref": "#/definitions/A%7CB", 3 | "definitions": { 4 | "A|B": { 5 | "type": "object" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue258/subject-invalid.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue260/remotes/example/definitions/buildings.json: -------------------------------------------------------------------------------- 1 | { 2 | "house": { 3 | "type": "object", 4 | "properties": { 5 | "rooms": { 6 | "type": "array", 7 | "items": { 8 | "$ref": "#/room" 9 | } 10 | } 11 | } 12 | }, 13 | "room": { 14 | "type": "object", 15 | "properties": { 16 | "door": { 17 | "$ref": "stuff.json#/door" 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue260/remotes/example/definitions/stuff.json: -------------------------------------------------------------------------------- 1 | { 2 | "door": { 3 | "type": "object", 4 | "properties": { 5 | "material": { "type": "string" } 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue260/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "$id": "http://localhost:1234/", 4 | "type": "object", 5 | "properties": { 6 | "house": { 7 | "$ref": "example/definitions/buildings.json#/house" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue260/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "house": { 3 | "rooms": [ { 4 | "door": { "material": 1 } 5 | }] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue260/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaSchemaVersion": 7 3 | } 4 | 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue270/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-06/schema#", 3 | "type": "object", 4 | "properties": { 5 | "events": { 6 | "type": "array", 7 | "items": { 8 | "oneOf": [ 9 | { 10 | "$ref": "#event" 11 | } 12 | ] 13 | } 14 | } 15 | }, 16 | "additionalProperties": false, 17 | "required": [ 18 | "events" 19 | ], 20 | "definitions": { 21 | "event": { 22 | "$id": "#event", 23 | "type": "object", 24 | "properties": { 25 | "name": { 26 | "type": "string" 27 | } 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue270/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "events": [ 3 | { 4 | "name": "example" 5 | } 6 | ] 7 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue270/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "metaSchemaVersion": 6 3 | } 4 | 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue271/remotes/dummy-schema.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue271/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "$id": { 4 | "type": "string" 5 | }, 6 | "other": { 7 | "$ref": "http://localhost:1234/dummy-schema.json" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue271/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "id-value" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue308/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "properties": { 5 | "aDate": { 6 | "type": "string", 7 | "format": "date-time" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue308/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "aDate": "2019-02-29T10:58:24Z" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue308/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "aDate": "2019-02-28T10:58:24Z" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue308/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "customFormats": { 3 | "date-time": "org.everit.json.schema.CustomDateTimeFormatValidator" 4 | }, 5 | "enableOverrideOfBuiltInFormatValidators" : true 6 | } 7 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue31/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "title": "JSON Schema X3D V3.3", 4 | "description": "Experimental JSON Schema for X3D V3.3 ", 5 | "type": "object", 6 | "properties": { 7 | "PixelTexture": { 8 | "type": "object", 9 | "properties": { 10 | "@image": { 11 | "type": "array", 12 | "minItems": 3, 13 | "items": [ 14 | { 15 | "type": "integer", 16 | "default": 0 17 | }, 18 | { 19 | "type": "integer", 20 | "default": 0 21 | }, 22 | { 23 | "type": "integer", 24 | "default": 0 25 | } 26 | ], 27 | "additionalItems": { 28 | "type": "integer" 29 | } 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue31/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "PixelTexture": { 3 | "@image": [ 4 | 4278190335, 5 | 4278190207, 6 | 45 7 | ] 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue321/remotes/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema", 3 | "$defs": { 4 | "a": { 5 | "$id": "#a", 6 | "type": "integer" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue321/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "a": { 4 | "$ref": "http://localhost:1234/schema.json#a" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue321/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 42 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue33-2/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "causingExceptions": [ 3 | { 4 | "causingExceptions": [], 5 | "keyword": "required", 6 | "message": "required key [agentId] not found", 7 | "pointerToViolation": "#", 8 | "schemaLocation": "#" 9 | }, 10 | { 11 | "causingExceptions": [], 12 | "keyword": "required", 13 | "message": "required key [reportType] not found", 14 | "pointerToViolation": "#", 15 | "schemaLocation": "#" 16 | } 17 | ], 18 | "message": "2 schema violations found", 19 | "pointerToViolation": "#", 20 | "schemaLocation": "#" 21 | } 22 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue33-2/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "agentType": "testType", 3 | "finishedAt": "2019-11-13T20:22:39+00:00", 4 | "reportJSON": { 5 | "certificates": [ 6 | { 7 | "appConfPath": "testAppConfPath", 8 | "appProduct": "testAppProduct", 9 | "appVersion": "testAppVersion", 10 | "certB64": "testCertB64", 11 | "certFileExt": "testCertFileExt", 12 | "certFileName": "testCertFileName", 13 | "certPath": "testCertPath", 14 | "hostFQDN": "testHostFQDN", 15 | "privateKeyPath": "testPrivateKeyPath" 16 | } 17 | ] 18 | }, 19 | "startedAt": "2019-11-13T20:20:39+00:00" 20 | } 21 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue33/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaLocation": "#", 3 | "pointerToViolation": "#", 4 | "causingExceptions": [ 5 | { 6 | "schemaLocation": "#/allOf/1/properties/b", 7 | "pointerToViolation": "#/b", 8 | "causingExceptions": [], 9 | "keyword": "type", 10 | "message": "expected type: String, found: Integer" 11 | } 12 | ], 13 | "keyword": "allOf", 14 | "message": "#: only 2 subschema matches out of 3" 15 | } 16 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue33/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "allOf": [ 3 | { 4 | "type": "object", 5 | "properties": { 6 | "a": { 7 | "type": "string" 8 | } 9 | } 10 | }, 11 | { 12 | "type": "object", 13 | "properties": { 14 | "b": { 15 | "type": "string" 16 | } 17 | } 18 | }, 19 | { 20 | "type": "object", 21 | "properties": { 22 | "c": { 23 | "type": "string" 24 | } 25 | } 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue33/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "a", 3 | "b": 2, 4 | "c": "c" 5 | } 6 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue35/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "CARDConfirmCashAdvanceWithInstallmentCompositionRequest": { 3 | "Body": { 4 | "Account": { 5 | "Branch": { 6 | "BranchCondition": 0, 7 | "Code": 247 8 | }, 9 | "Category": "C", 10 | "Currency": { 11 | "Code": 0 12 | }, 13 | "CustomerNumber": 49247, 14 | "Order": 0, 15 | "Type": "KS" 16 | }, 17 | "Amount": { 18 | "Currency": { 19 | "Code": 0 20 | }, 21 | "Value": 9 22 | }, 23 | "CardNo": "4203230000000406", 24 | "CustomerNo": 0, 25 | "CustomerServiceType": "Undefined", 26 | "InstallCount": 0, 27 | "ProcessType": 6, 28 | "RegistrationNo": 49247, 29 | "Source": 0 30 | }, 31 | "Header": { 32 | "Auth": {}, 33 | "Channel": "Branch", 34 | "Info": { 35 | "Data": [] 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue35/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "CARDConfirmCashAdvanceWithInstallmentCompositionRequest": { 3 | "Body": { 4 | "Account": { 5 | "Branch": { 6 | "BranchCondition": 0, 7 | "Code": 247 8 | }, 9 | "Category": "C", 10 | "Currency": { 11 | "Code": 0 12 | }, 13 | "CustomerNumber": 49247, 14 | "Order": 0, 15 | "Type": "KS" 16 | }, 17 | "Amount": { 18 | "Currency": { 19 | "Code": 0 20 | }, 21 | "Value": 9 22 | }, 23 | "CardNo": "4203230000000406", 24 | "CustomerNo": 0, 25 | "CustomerServiceType": "Undefined", 26 | "InstallCount": 0, 27 | "ProcessType": 6, 28 | "RegistrationNo": 49247, 29 | "Source": 0 30 | }, 31 | "Header": { 32 | "Auth": {}, 33 | "Channel": "Branch", 34 | "Info": { 35 | "Data": [] 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue36/remotes/geo: -------------------------------------------------------------------------------- 1 | { 2 | "id": "http://json-schema.org/geo", 3 | "$schema": "http://json-schema.org/draft-06/schema#", 4 | "description": "A geographical coordinate", 5 | "type": "object", 6 | "properties": { 7 | "latitude": { "type": "number" }, 8 | "longitude": { "type": "number" } 9 | } 10 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue36/subject-invalid.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 2, 4 | "name": [ 5 | "An ice sculpture" 6 | ], 7 | "price": 12.50, 8 | "tags": [ 9 | "cold", 10 | "ice" 11 | ], 12 | "dimensions": { 13 | "length": 7.0, 14 | "width": "12.0", 15 | "height": 9.5 16 | }, 17 | "warehouseLocation": { 18 | "latitude": -78.75, 19 | "longitude": 20.4 20 | } 21 | }, 22 | { 23 | "id": 3, 24 | "name": "A blue mouse", 25 | "dimensions": { 26 | "length": 3.1, 27 | "width": 1.0, 28 | "height": 1.0 29 | }, 30 | "warehouseLocation": { 31 | "latitude": 54.4, 32 | "longitude": -32.7 33 | } 34 | }, 35 | { 36 | "id": "4", 37 | "name": "A little chick", 38 | "price": 12.50, 39 | "dimensions": { 40 | "length": 3.1, 41 | "width": 1.0, 42 | "height": 1.0 43 | }, 44 | "warehouseLocation": { 45 | "latitude": 54.4, 46 | "longitude": -32.7 47 | } 48 | } 49 | ] 50 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue380/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "model.json", 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "additionalProperties": false, 5 | "properties": { 6 | "name": { 7 | "minLength": 1, 8 | "type": "string" 9 | }, 10 | "type": { 11 | "minLength": 1, 12 | "type": "string" 13 | } 14 | }, 15 | "required": [ 16 | "type", 17 | "name" 18 | ], 19 | "type": "object" 20 | } 21 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue380/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "my content type", 3 | "name": "content name" 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue386/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "a": { 4 | "$ref": "#/definitions/x5t%23S256" 5 | } 6 | }, 7 | "definitions": { 8 | "x5t#S256": { 9 | "type": "string" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue386/subject-valid.json: -------------------------------------------------------------------------------- 1 | {"a":""} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue399/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "assetid": 533, 3 | "bmi": 15.87, 4 | "date": "2020-11-17", 5 | "e": 25.97, 6 | "hc": -4.4, 7 | "lg": 0.07, 8 | "sc": -9.73 9 | } 10 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue400/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "number": { 5 | "type": "number", 6 | "maximum": 9999999999999999 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue400/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "number": 10000000000000001 3 | } -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue41/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "prop": { 4 | "type": "object", 5 | "$ref": "#/definitions/PropDef" 6 | } 7 | }, 8 | "definitions": { 9 | "PropDef": { 10 | "required": [ 11 | "a", 12 | "b" 13 | ] 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue41/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "prop": { 3 | "a": 2 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue428/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "properties": { 3 | "booleanProps": { 4 | "type": "array", 5 | "items": { 6 | "type": "boolean" 7 | } 8 | }, 9 | "integerProp": { 10 | "type": "integer" 11 | }, 12 | "nullProp": { 13 | "type": "null" 14 | }, 15 | "numberProp": { 16 | "type": "number" 17 | }, 18 | "stringProp": { 19 | "type": "array", 20 | "items": { 21 | "type": "string" 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue428/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "numberProp": "12.34", 3 | "integerProp": "12", 4 | "booleanProps": [ 5 | "y", 6 | "Y", 7 | "yes", 8 | "Yes", 9 | "YES", 10 | "n", 11 | "N", 12 | "no", 13 | "No", 14 | "NO", 15 | "true", 16 | "True", 17 | "TRUE", 18 | "false", 19 | "False", 20 | "FALSE", 21 | "on", 22 | "On", 23 | "ON", 24 | "off", 25 | "Off", 26 | "OFF" 27 | ], 28 | "nullProp": "null", 29 | "stringProp": [true, false, "yes", 12, 12.34] 30 | } 31 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue428/validator-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "primitiveParsing": "LENIENT" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue480/expected-exception.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaLocation": "#", 3 | "pointerToViolation": "#", 4 | "causingExceptions": [{ 5 | "pointerToViolation": "#", 6 | "causingExceptions": [{ 7 | "schemaLocation": "#/oneOf/2", 8 | "pointerToViolation": "#", 9 | "causingExceptions": [], 10 | "keyword": "required", 11 | "message": "required key [rest-url] not found" 12 | }], 13 | "keyword": "oneOf", 14 | "message": "#: 2 subschemas matched instead of one" 15 | }], 16 | "keyword": "allOf", 17 | "message": "#: only 1 subschema matches out of 2" 18 | } 19 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue480/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "oneOf": [ 3 | {"required": ["union-query"]}, 4 | {"required": ["sql-string"]}, 5 | {"required": ["rest-url"]} 6 | ], 7 | "type": "object", 8 | "additionalProperties": false, 9 | "properties": { 10 | "union-query": {"type": "string"}, 11 | "rest-url": {"type": "string"}, 12 | "sql-string": {"type": "string"} 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue480/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "union-query": "xyz", 3 | "sql-string": "xyz" 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue487/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "required": [ 5 | "name", 6 | "property1", 7 | "property2" 8 | ], 9 | "properties": { 10 | "name": { 11 | "title": "Object name", 12 | "description": "Description of object name", 13 | "type": "string", 14 | "maxLength": 5 15 | }, 16 | "property1": { 17 | "title": "Property 1", 18 | "description": "Description of property 1", 19 | "type": "integer" 20 | }, 21 | "property2": { 22 | "title": "Property 2", 23 | "description": "Description of property 2", 24 | "type": "string", 25 | "maxLength": 5 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue487/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "oh yeah", 3 | "property1": 3, 4 | "property2": "87" 5 | } 6 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue56/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "created": { 6 | "type": "string", 7 | "format": "date-time" 8 | } 9 | }, 10 | "required": [ 11 | "created" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue56/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "created": "2011-12-03T10:15:30.1Z" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue57/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type":"object", 3 | "$schema": "http://json-schema.org/draft-04/schema", 4 | "required": ["one"], 5 | "properties":{ 6 | "one": { 7 | "type":"string", 8 | "id": "http://example.com/one" 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue57/subject-valid.json: -------------------------------------------------------------------------------- 1 | {"one":"1"} 2 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue62/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "type": "object", 4 | "properties": { 5 | "only_as_1": { 6 | "pattern": "^a+$", 7 | "type": ["string", "null"] 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue62/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "only_as_1": "bbb" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/issue65/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "arrayOfObjs": [ 4 | { 5 | "numObj": 3, 6 | "StringArrayObj": [ 7 | "NotATestString" 8 | ] 9 | }, 10 | { 11 | "numObj": 8, 12 | "StringArrayObj": [ 13 | "NotATestString1", 14 | "NotATestString2", 15 | "NotATestString3" 16 | ] 17 | }, 18 | { 19 | "numObj": 4, 20 | "numObj2": 43, 21 | "StringArrayObj": [ 22 | "NotATestString5", 23 | "NotATestString6" 24 | ] 25 | } 26 | ], 27 | "anotherArrayOfObjs": [] 28 | } 29 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "type": "object", 4 | "title": "The SimpleTestClass Schema", 5 | "required": [ 6 | "stringKey", 7 | "floatKey" 8 | ], 9 | "properties": { 10 | "stringKey": { 11 | "const": "issue", 12 | "title": "The stringKey Schema", 13 | "type": "string" 14 | }, 15 | "floatKey": { 16 | "maximum": 10.1, 17 | "title": "The floatKey Schema", 18 | "type": "number", 19 | "minimum": 10.1 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/subject-valid.json: -------------------------------------------------------------------------------- 1 | { 2 | "stringKey": "issue", 3 | "floatKey": 10.1 4 | } 5 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/xissue120/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "UserName": { 5 | "type": "string" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/xissue120/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "UserName": 1234567890123456789012345 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/xissue21/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "$schema": "http://json-schema.org/draft-04/schema#", 4 | "definitions": { 5 | "language_object": { 6 | "type": "object", 7 | "additionalProperties": false, 8 | "patternProperties": { 9 | "^[a-z]{2}$": { 10 | "type": "string" 11 | } 12 | } 13 | } 14 | }, 15 | "properties": { 16 | "name": { 17 | "$ref": "#/definitions/language_object", 18 | "minProperties": 1 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/xissue21/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": {} 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/xissue38/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "id": "urn:jsonschema:com:zzzzz:tests:commons:jsonschema:models:Person", 4 | "properties": { 5 | "book": { 6 | "type": "object", 7 | "id": "urn:jsonschema:com:zzzzz:tests:commons:jsonschema:models:PhoneBook", 8 | "properties": { 9 | "numbers": { 10 | "type": "array", 11 | "items": { 12 | "type": "object", 13 | "id": "urn:jsonschema:com:zzzzz:tests:commons:jsonschema:models:PhoneNumber", 14 | "properties": { 15 | "number": { 16 | "type": "string", 17 | "pattern": "\\+?\\d+" 18 | }, 19 | "type": { 20 | "type": "string" 21 | } 22 | } 23 | } 24 | } 25 | } 26 | }, 27 | "phoneBooks": { 28 | "type": "array", 29 | "items": { 30 | "type": "object", 31 | "$ref": "urn:jsonschema:com:zzzzz:tests:commons:jsonschema:models:PhoneBook" 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/issues/xissue38/subject-invalid.json: -------------------------------------------------------------------------------- 1 | { 2 | "book": { 3 | "numbers": [ 4 | { 5 | "number": "22222" 6 | }, 7 | { 8 | "number": "11111" 9 | } 10 | ] 11 | }, 12 | "phoneBooks": [ 13 | { 14 | "numbers": [ 15 | { 16 | "number": "22222" 17 | }, 18 | { 19 | "number": "11111" 20 | }, 21 | { 22 | "number": "aaaaa" 23 | } 24 | ] 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/relative-uri/schema/directory/subschemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "Identifier": { 4 | "type": "string", 5 | "maxLength": 10 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/relative-uri/schema/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "object", 3 | "properties": { 4 | "rect": { 5 | "$ref": "props.json#/definitions/Rectangle" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/relative-uri/schema/props.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "Rectangle": { 4 | "type": "object", 5 | "properties": { 6 | "a": { 7 | "$ref": "#/definitions/Size" 8 | }, 9 | "b": { 10 | "$ref": "#/definitions/Size" 11 | }, 12 | "id": { 13 | "$ref": "directory/subschemas.json#/definitions/Identifier" 14 | } 15 | } 16 | }, 17 | "Size": { 18 | "type": "number" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/remotes/folder/folderInteger.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/remotes/integer.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "integer" 3 | } 4 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/remotes/name.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": { 3 | "orNull": { 4 | "anyOf": [ 5 | {"type": "null"}, 6 | {"$ref": "#"} 7 | ] 8 | } 9 | }, 10 | "type": "string" 11 | } 12 | -------------------------------------------------------------------------------- /tests/vanilla/src/main/resources/org/everit/json/schema/remotes/subSchemas.json: -------------------------------------------------------------------------------- 1 | { 2 | "integer": { 3 | "type": "integer" 4 | }, 5 | "refToInteger": { 6 | "$ref": "#/integer" 7 | } 8 | } 9 | --------------------------------------------------------------------------------