diff --git a/src/main/generated/io/vertx/json/schema/SchemaRouterOptionsConverter.java b/src/main/generated/io/vertx/json/schema/SchemaRouterOptionsConverter.java deleted file mode 100644 index 6789fadb..00000000 --- a/src/main/generated/io/vertx/json/schema/SchemaRouterOptionsConverter.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.vertx.json.schema; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.impl.JsonUtil; -import java.time.Instant; -import java.time.format.DateTimeFormatter; -import java.util.Base64; - -/** - * Converter and mapper for {@link io.vertx.json.schema.SchemaRouterOptions}. - * NOTE: This class has been automatically generated from the {@link io.vertx.json.schema.SchemaRouterOptions} original class using Vert.x codegen. - */ -public class SchemaRouterOptionsConverter { - - - private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER; - private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER; - - public static void fromJson(Iterable> json, SchemaRouterOptions obj) { - for (java.util.Map.Entry member : json) { - switch (member.getKey()) { - case "authHeaders": - if (member.getValue() instanceof JsonObject) { - } - break; - case "authQueryParams": - if (member.getValue() instanceof JsonObject) { - } - break; - } - } - } - - public static void toJson(SchemaRouterOptions obj, JsonObject json) { - toJson(obj, json.getMap()); - } - - public static void toJson(SchemaRouterOptions obj, java.util.Map json) { - if (obj.getAuthHeaders() != null) { - JsonObject map = new JsonObject(); - obj.getAuthHeaders().forEach((key, value) -> map.put(key, value)); - json.put("authHeaders", map); - } - if (obj.getAuthQueryParams() != null) { - JsonObject map = new JsonObject(); - obj.getAuthQueryParams().forEach((key, value) -> map.put(key, value)); - json.put("authQueryParams", map); - } - } -} diff --git a/src/main/java/io/vertx/json/schema/NoSyncValidationException.java b/src/main/java/io/vertx/json/schema/NoSyncValidationException.java deleted file mode 100644 index 77b19a30..00000000 --- a/src/main/java/io/vertx/json/schema/NoSyncValidationException.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema; - -import io.vertx.core.VertxException; -import io.vertx.json.schema.common.MutableStateValidator; - -/** - * This exception is thrown when you call {@link Schema#validateSync(Object)} when the schema is in an asynchronous state - * @deprecated users should migrate to the new validator - */ -@Deprecated -public class NoSyncValidationException extends VertxException { - - private final MutableStateValidator validator; - - public NoSyncValidationException(String message, MutableStateValidator validator) { - super(message); - this.validator = validator; - } - - public NoSyncValidationException(String message, Throwable cause, MutableStateValidator validator) { - super(message, cause); - this.validator = validator; - } - - public MutableStateValidator getValidator() { - return validator; - } -} diff --git a/src/main/java/io/vertx/json/schema/Schema.java b/src/main/java/io/vertx/json/schema/Schema.java deleted file mode 100644 index 5c39dff1..00000000 --- a/src/main/java/io/vertx/json/schema/Schema.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema; - -import io.vertx.codegen.annotations.VertxGen; -import io.vertx.core.Future; -import io.vertx.core.json.pointer.JsonPointer; - -/** - * Interface representing a Json Schema
- *

- * A schema could have two states:
- *

    - *
  • Synchronous: The validators tree can provide a synchronous validation, so you can validate your json both using {@link this#validateSync(Object)} and {@link this#validateAsync(Object)}
  • - *
  • Asynchronous: One or more branches of the validator tree requires an asynchronous validation, so you must use {@link this#validateAsync(Object)} to validate your json. If you use {@link this#validateSync(Object)} it will throw a {@link NoSyncValidationException}
  • - *
- *

- * To check the schema state you can use method {@link this#isSync()}. Note that invoking {@link #validateAsync(Object)} generally doesn't have any additional overhead than invoking {@link #validateSync(Object)}.
- * The schema can mutate the state in time, e.g. if you have a schema that is asynchronous because of a {@code $ref}, - * after the first validation the external schema is cached inside {@link SchemaRouter} and this schema will switch to synchronous state
- * @deprecated users should migrate to the new validator - */ -@Deprecated -@VertxGen -public interface Schema { - - /** - * Validate the json performing an asynchronous validation.
- *

- * Note: If the schema is synchronous, this method will call internally {@link this#validateSync(Object)} - * - * @param json input to validate - * @return a failed future with {@link ValidationException} if json doesn't match the schema, otherwise a succeeded future. - */ - Future validateAsync(Object json); - - /** - * Validate the json performing a synchronous validation. Throws a {@link ValidationException} if json doesn't match the schema.
- * - * @param json input to validate - * @throws ValidationException if the input doesn't match the schema - * @throws NoSyncValidationException If the schema cannot perform a synchronous validation - */ - void validateSync(Object json) throws ValidationException, NoSyncValidationException; - - /** - * @return scope of this schema - */ - JsonPointer getScope(); - - /** - * @return Json representation of the schema - */ - Object getJson(); - - /** - * @return true if this validator can provide a synchronous validation. - */ - boolean isSync(); - -} diff --git a/src/main/java/io/vertx/json/schema/SchemaParser.java b/src/main/java/io/vertx/json/schema/SchemaParser.java deleted file mode 100644 index 0cd5f81e..00000000 --- a/src/main/java/io/vertx/json/schema/SchemaParser.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema; - -import io.vertx.codegen.annotations.Fluent; -import io.vertx.codegen.annotations.GenIgnore; -import io.vertx.codegen.annotations.VertxGen; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.common.ValidatorFactory; -import io.vertx.json.schema.openapi3.OpenAPI3SchemaParser; - -import java.util.function.Predicate; - -/** - * Parse a Json Schema. The parser can be extended to support custom keywords using {@link this#withValidatorFactory(ValidatorFactory)} - * @deprecated users should migrate to the new validator - */ -@Deprecated -@VertxGen -public interface SchemaParser { - - /** - * Build a schema from provided json assigning a random scope. This method registers the parsed schema (and relative subschemas) to the schema router - * - * @param jsonSchema JSON representing the schema - * @return the schema instance - * @throws IllegalArgumentException If scope is relative - * @throws SchemaException If schema is invalid - */ - Schema parse(JsonObject jsonSchema); - - /** - * Build a schema from provided json. This method registers the parsed schema (and relative subschemas) to the schema router - * - * @param jsonSchema JSON representing the schema - * @param schemaPointer Scope of schema. Must be a JSONPointer with absolute URI - * @return the schema instance - * @throws IllegalArgumentException If scope is relative - * @throws SchemaException If schema is invalid - */ - Schema parse(JsonObject jsonSchema, JsonPointer schemaPointer); - - /** - * Builds a true of false schema assigning a random scope - * - * @param jsonSchema JSON representing the schema - * @return the schema instance - * @throws IllegalArgumentException If scope is relative - * @throws SchemaException If schema is invalid - */ - Schema parse(Boolean jsonSchema); - - /** - * Builds a true of false schema - * - * @param jsonSchema JSON representing the schema - * @param schemaPointer Scope of schema. Must be a JSONPointer with absolute URI - * @return the schema instance - * @throws IllegalArgumentException If scope is relative - * @throws SchemaException If schema is invalid - */ - Schema parse(Boolean jsonSchema, JsonPointer schemaPointer); - - /** - * Build a schema from provided unparsed json assigning a random scope. This method registers the parsed schema (and relative subschemas) to the schema router - * - * @param unparsedJson Unparsed JSON representing the schema. - * @return the schema instance - * @throws IllegalArgumentException If scope is relative - * @throws SchemaException If schema is invalid - */ - Schema parseFromString(String unparsedJson); - - /** - * Build a schema from provided unparsed json. This method registers the parsed schema (and relative subschemas) to the schema router - * - * @param unparsedJson Unparsed JSON representing the schema. - * @param schemaPointer Scope of schema. Must be a JSONPointer with absolute URI - * @return the schema instance - * @throws IllegalArgumentException If scope is relative - * @throws SchemaException If schema is invalid - */ - Schema parseFromString(String unparsedJson, JsonPointer schemaPointer); - - /** - * Get schema router registered to this schema parser - * - * @return - */ - SchemaRouter getSchemaRouter(); - - /** - * Add a {@link ValidatorFactory} to this schema parser to support custom keywords - * - * @param factory new factory - * @return a reference to this - */ - @GenIgnore(GenIgnore.PERMITTED_TYPE) - @Fluent - SchemaParser withValidatorFactory(ValidatorFactory factory); - - /** - * Add a custom format validator - * - * @param formatName format name - * @param predicate predicate for the new format - * @return a reference to this - */ - @GenIgnore(GenIgnore.PERMITTED_TYPE) - @Fluent - SchemaParser withStringFormatValidator(String formatName, Predicate predicate); - - /** - * Create a new {@link SchemaParser} for OpenAPI schemas - * - * @param router - * @return - */ - static SchemaParser createOpenAPI3SchemaParser(SchemaRouter router) { - return OpenAPI3SchemaParser.create(router); - } -} diff --git a/src/main/java/io/vertx/json/schema/SchemaRouter.java b/src/main/java/io/vertx/json/schema/SchemaRouter.java deleted file mode 100644 index 40afc8f3..00000000 --- a/src/main/java/io/vertx/json/schema/SchemaRouter.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema; - -import io.vertx.codegen.annotations.Fluent; -import io.vertx.codegen.annotations.GenIgnore; -import io.vertx.codegen.annotations.Nullable; -import io.vertx.codegen.annotations.VertxGen; -import io.vertx.core.Future; -import io.vertx.core.Vertx; -import io.vertx.core.file.FileSystem; -import io.vertx.core.http.HttpClient; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.common.SchemaRouterImpl; - -import java.net.URI; -import java.util.List; - -/** - * Represents a pool where parsed schemas are addressed and cached.
- *

- * It also contains a cache of {@link JsonObject} including on top or inner level some json schemas that could eventually parsed later.
- *

- * You should not share this object between different threads - * - * @author slinkydeveloper - * @deprecated users should migrate to the new validator - */ -@Deprecated -@VertxGen -public interface SchemaRouter { - - /** - * Resolve cached schema based on refPointer. If a schema isn't cached, it returns null - * - * @param refPointer - * @param schemaScope - * @param parser - * @return the resolved schema, or null if no schema was found - * @throws SchemaException If was found an unparsed schema that is an invalid json schema - */ - @Nullable Schema resolveCachedSchema(JsonPointer refPointer, JsonPointer schemaScope, SchemaParser parser) throws SchemaException; - - /** - * Resolve $ref.
- * This method tries to resolve schema from local cache. If it's not found, it solve external references. - * It can solve external references on filesystem and remote references using http. - * When you pass a relative reference without protocol, it tries to infer the absolute path from scope and cached schemas
- * Returns a future that can contain Schema or be null or can fail with a {@link SchemaException} or an {@link IllegalArgumentException} - * - * @param pointer - * @param scope - * @param schemaParser - * @return a succeeded future that contains the resolved {@link Schema} or failed with a {@link SchemaException} or an {@link IllegalArgumentException} - */ - Future resolveRef(JsonPointer pointer, JsonPointer scope, SchemaParser schemaParser); - - /** - * Add a parsed schema to this router. When a schema is added to the cache, a new entry is created for {@link Schema#getScope()} and, - * if you provide additional aliasScopes, this method register links to this schema with these scopes. - * This method is automatically called by {@link SchemaParser} when a new schema is parsed - * - * @param schema schema to add - * @return a reference to this - * @throws IllegalStateException if the schema contains a scope with a relative {@link URI} or one of the aliasScopes has a relative {@link URI} - */ - @GenIgnore(GenIgnore.PERMITTED_TYPE) - @Fluent - SchemaRouter addSchema(Schema schema, JsonPointer... aliasScopes); - - /** - * Add a parsed schema to this router. When a schema is added to the cache, a new entry is created for the provided scope, - * but NOT for {@link Schema#getScope()}. This may be useful to register links to singleton schemas. - * This method is automatically called by {@link SchemaParser} when a new schema is parsed - * - * @param schema schema to add - * @return a reference to this - * @throws IllegalStateException if the provided scope contains a relative {@link URI} - */ - @Fluent - SchemaRouter addSchemaWithScope(Schema schema, JsonPointer scope); - - /** - * Add an alias to a schema already registered in this router (this alias can be solved only from schema scope). - * - * @param schema schema to add - * @param alias the schema alias - * @return a reference to this - */ - @Fluent - SchemaRouter addSchemaAlias(Schema schema, String alias); - - /** - * Add one or more json documents including schemas on top or inner levels. This method doesn't trigger the schema parsing
- *

- * You can use this schema if you have externally loaded some json document and you want to register to the schema router. - * You can later parse and retrieve a schema from this json structure using {@link this#resolveCachedSchema(JsonPointer, JsonPointer, SchemaParser)}, - * providing the correct {@code refPointer} - * - * @param uri - * @param object - * @return a reference to this - */ - @GenIgnore(GenIgnore.PERMITTED_TYPE) - @Fluent - SchemaRouter addJson(URI uri, JsonObject object); - - /** - * Add one or more json documents including schemas on top or inner levels. This method doesn't trigger the schema parsing
- *

- * You can use this schema if you have externally loaded some json document and you want to register to the schema router. - * You can later parse and retrieve a schema from this json structure using {@link this#resolveCachedSchema(JsonPointer, JsonPointer, SchemaParser)}, - * providing the correct {@code refPointer} - * - * @param uri - * @param object - * @return a reference to this - */ - @Fluent - default SchemaRouter addJson(String uri, JsonObject object) { - return addJson(URI.create(uri), object); - } - - /** - * @return a list of all registered schemas - */ - List registeredSchemas(); - - /** - * Create a new {@link SchemaRouter} - * - * @param vertx - * @param schemaRouterOptions - * @return - */ - static SchemaRouter create(Vertx vertx, SchemaRouterOptions schemaRouterOptions) { - return new SchemaRouterImpl(vertx, vertx.createHttpClient(), vertx.fileSystem(), schemaRouterOptions); - } - - /** - * Create a new {@link SchemaRouter} - * - * @param client - * @param fs - * @param schemaRouterOptions - * @return - */ - static SchemaRouter create(Vertx vertx, HttpClient client, FileSystem fs, SchemaRouterOptions schemaRouterOptions) { - return new SchemaRouterImpl(vertx, client, fs, schemaRouterOptions); - } - -} diff --git a/src/main/java/io/vertx/json/schema/SchemaRouterOptions.java b/src/main/java/io/vertx/json/schema/SchemaRouterOptions.java deleted file mode 100644 index f0220792..00000000 --- a/src/main/java/io/vertx/json/schema/SchemaRouterOptions.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema; - -import io.vertx.codegen.annotations.DataObject; -import io.vertx.codegen.annotations.Fluent; -import io.vertx.core.json.JsonObject; - -import java.util.HashMap; -import java.util.Map; - -/** - * Represents the options to resolve external schemas. You can configure auth options to access to external services - * @deprecated users should migrate to the new validator - */ -@Deprecated -@DataObject(generateConverter = true) -public class SchemaRouterOptions { - - private Map authQueryParams; - private Map authHeaders; - - public SchemaRouterOptions() { - authHeaders = new HashMap<>(); - authQueryParams = new HashMap<>(); - } - - public SchemaRouterOptions(JsonObject obj) { - SchemaRouterOptionsConverter.fromJson(obj, this); - } - - public JsonObject toJson() { - JsonObject obj = new JsonObject(); - SchemaRouterOptionsConverter.toJson(this, obj); - return obj; - } - - /** - * Put an header to authenticate requests while loading an external schema - * - * @param headerName - * @param headerValue - * @return - */ - @Fluent - public SchemaRouterOptions putAuthHeader(String headerName, String headerValue) { - authHeaders.put(headerName, headerValue); - return this; - } - - /** - * Put a query parameter to authenticate requests while loading an external schema - * - * @param queryParamName - * @param queryParamValue - * @return - */ - @Fluent - public SchemaRouterOptions putAuthQueryParam(String queryParamName, String queryParamValue) { - authQueryParams.put(queryParamName, queryParamValue); - return this; - } - - public Map getAuthQueryParams() { - return authQueryParams; - } - - public Map getAuthHeaders() { - return authHeaders; - } -} diff --git a/src/main/java/io/vertx/json/schema/ValidationException.java b/src/main/java/io/vertx/json/schema/ValidationException.java index 89bf2ca7..3d949f87 100644 --- a/src/main/java/io/vertx/json/schema/ValidationException.java +++ b/src/main/java/io/vertx/json/schema/ValidationException.java @@ -26,7 +26,6 @@ public abstract class ValidationException extends VertxException { final private String keyword; final private Object input; - protected Schema schema; protected JsonPointer inputScope; protected ValidationException(String message, String keyword, Object input) { @@ -100,22 +99,6 @@ public Object input() { return input; } - /** - * @return the schema that failed the validation - */ - public Schema schema() { - return schema; - } - - /** - * @return the scope of the schema that failed the validation - * @deprecated use {@link #schema()} and then {@link Schema#getScope()} instead - */ - @Deprecated - public JsonPointer scope() { - return this.schema.getScope(); - } - /** * @return the scope of the input, where the validation failed. */ @@ -129,7 +112,6 @@ public String toString() { "message='" + getMessage() + '\'' + ", keyword='" + keyword + '\'' + ", input=" + input + - ", schema=" + schema + ((inputScope != null) ? ", inputScope=" + inputScope.toURI() : "") + '}'; } diff --git a/src/main/java/io/vertx/json/schema/common/AllOfValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/AllOfValidatorFactory.java deleted file mode 100644 index d3542445..00000000 --- a/src/main/java/io/vertx/json/schema/common/AllOfValidatorFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.CompositeFuture; -import io.vertx.core.Future; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -import java.util.Arrays; -import java.util.stream.Collectors; - -public class AllOfValidatorFactory extends BaseCombinatorsValidatorFactory { - - @Override - BaseCombinatorsValidator instantiate(MutableStateValidator parent) { - return new AllOfValidator(parent); - } - - @Override - String getKeyword() { - return "allOf"; - } - - static class AllOfValidator extends BaseCombinatorsValidator { - - public AllOfValidator(MutableStateValidator parent) { - super(parent); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.checkSync(); - for (SchemaInternal s : schemas) s.validateSync(context, in); - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - if (isSync()) return validateSyncAsAsync(context, in); - return Future - .all(Arrays.stream(schemas).map(s -> s.validateAsync(context, in)).collect(Collectors.toList())) - .mapEmpty(); - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/AnyOfValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/AnyOfValidatorFactory.java deleted file mode 100644 index b38febe6..00000000 --- a/src/main/java/io/vertx/json/schema/common/AnyOfValidatorFactory.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.CompositeFuture; -import io.vertx.core.Future; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class AnyOfValidatorFactory extends BaseCombinatorsValidatorFactory { - - @Override - BaseCombinatorsValidator instantiate(MutableStateValidator parent) { - return new AnyOfValidator(parent); - } - - @Override - String getKeyword() { - return "anyOf"; - } - - static class AnyOfValidator extends BaseCombinatorsValidator { - - public AnyOfValidator(MutableStateValidator parent) { - super(parent); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.checkSync(); - List res = null; - for (SchemaInternal s : this.schemas) { - try { - s.validateSync(context, in); - return; - } catch (ValidationException e) { - if (res == null) { - res = new ArrayList<>(); - } - res.add(e); - } - } - throw ValidationException.create( - "anyOf subschemas don't match", - "anyOf", - in, - res - ); - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - if (isSync()) return validateSyncAsAsync(context, in); - return Future - .any(Arrays.stream(this.schemas).map(s -> s.validateAsync(context, in)).collect(Collectors.toList())) - .compose(cf -> { - if (cf.succeeded()) { - return Future.succeededFuture(); - } else { - return Future.failedFuture( - ValidationException.create( - "anyOf subschemas don't match", - "anyOf", - in, - IntStream.range(0, cf.size()).mapToObj(cf::cause).filter(Objects::nonNull).collect(Collectors.toList())) - ); - } - }); - } - - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/AsyncValidator.java b/src/main/java/io/vertx/json/schema/common/AsyncValidator.java deleted file mode 100644 index aac15350..00000000 --- a/src/main/java/io/vertx/json/schema/common/AsyncValidator.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.json.schema.ValidationException; - -public interface AsyncValidator extends Validator { - - /** - * Return a Future that succeed when the validation succeed, while fail with a {@link ValidationException} when validation fails - * - * @param context - * @param in - * @return - */ - Future validateAsync(ValidatorContext context, Object in); - -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseAsyncValidator.java b/src/main/java/io/vertx/json/schema/common/BaseAsyncValidator.java deleted file mode 100644 index 7e8a64df..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseAsyncValidator.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -public abstract class BaseAsyncValidator implements AsyncValidator { - - @Override - public boolean isSync() { - return false; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.NORMAL_PRIORITY; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseCombinatorsValidator.java b/src/main/java/io/vertx/json/schema/common/BaseCombinatorsValidator.java deleted file mode 100644 index 654cf040..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseCombinatorsValidator.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.CompositeFuture; -import io.vertx.core.Future; -import io.vertx.json.schema.Schema; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static io.vertx.json.schema.common.JsonUtil.isArray; -import static io.vertx.json.schema.common.JsonUtil.isObject; - -public abstract class BaseCombinatorsValidator extends BaseMutableStateValidator implements DefaultApplier { - - protected SchemaInternal[] schemas; - - public BaseCombinatorsValidator(MutableStateValidator parent) { - super(parent); - } - - @Override - public boolean calculateIsSync() { - return Arrays.stream(schemas).map(Schema::isSync).reduce(true, Boolean::logicalAnd); - } - - void setSchemas(List schemas) { - this.schemas = schemas.toArray(new SchemaInternal[0]); - Arrays.sort(this.schemas, ValidatorPriority.COMPARATOR); - this.initializeIsSync(); - } - - @Override - public Future applyDefaultValue(Object obj) { - if (!(isObject(obj) || isArray(obj))) { - return Future.succeededFuture(); - } - - if (this.isSync()) { - for (Schema s : schemas) { - ((SchemaImpl) s).getOrApplyDefaultAsync(obj); - } - return Future.succeededFuture(); - } - return Future.all( - Arrays.stream(schemas) - .map(s -> s.getOrApplyDefaultAsync(obj)) - .collect(Collectors.toList()) - ).mapEmpty(); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseCombinatorsValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/BaseCombinatorsValidatorFactory.java deleted file mode 100644 index 1e9c978b..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseCombinatorsValidatorFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; - -import java.util.ArrayList; -import java.util.List; - -public abstract class BaseCombinatorsValidatorFactory implements ValidatorFactory { - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - JsonArray allOfSchemas = schema.getJsonArray(getKeyword()); - if (allOfSchemas.size() == 0) - throw new SchemaException(schema, getKeyword() + " must have at least one element"); - JsonPointer basePointer = scope.append(getKeyword()); - List parsedSchemas = new ArrayList<>(); - - BaseCombinatorsValidator validator = instantiate(parent); - for (int i = 0; i < allOfSchemas.size(); i++) { - parsedSchemas.add(parser.parse(allOfSchemas.getValue(i), basePointer.copy().append(Integer.toString(i)), validator)); - } - validator.setSchemas(parsedSchemas); - return validator; - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for " + getKeyword() + " keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null " + getKeyword() + " keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey(getKeyword()); - } - - abstract BaseCombinatorsValidator instantiate(MutableStateValidator parent); - - abstract String getKeyword(); -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseFormatValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/BaseFormatValidatorFactory.java deleted file mode 100644 index 9d598959..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseFormatValidatorFactory.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.net.IDN; -import java.net.URI; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.function.Predicate; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -public abstract class BaseFormatValidatorFactory implements ValidatorFactory { - - protected final static Predicate URI_VALIDATOR = in -> { - try { - return URI.create(in).isAbsolute(); - } catch (IllegalArgumentException e) { - return false; - } - }; - - protected final static Predicate URI_REFERENCE_VALIDATOR = in -> { - try { - URI.create(in); - return true; - } catch (IllegalArgumentException e) { - return false; - } - }; - - protected final static Predicate REGEX_VALIDATOR = in -> { - try { - Pattern.compile(in); - return true; - } catch (PatternSyntaxException e) { - return false; - } - }; - - protected final static Predicate IDN_HOSTNAME_VALIDATOR = in -> { - try { - IDN.toASCII(in); - return true; - } catch (IllegalArgumentException e) { - return false; - } - }; - - protected final static Predicate IDN_EMAIL_VALIDATOR = in -> { - try { - int atIndex = in.indexOf('@'); - if (atIndex < 0) { - return false; - } - String localPart = in.substring(0, atIndex); - if (!RegularExpressions.EMAIL_LOCAL.matcher(localPart).matches()) { - return false; - } - IDN.toASCII(in.substring(atIndex + 1)); - return true; - } catch (IllegalArgumentException | StringIndexOutOfBoundsException e) { - return false; - } - }; - - protected final static Predicate UUID_VALIDATOR = in -> { - try { - UUID.fromString(in); - return true; - } catch (IllegalArgumentException e) { - return false; - } - }; - - static class FormatValidator extends BaseSyncValidator { - - final Predicate validator; - - public FormatValidator(Predicate validator) { - this.validator = validator; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof String) { - if (!validator.test((String) in)) { - throw ValidationException.create("Provided value don't match pattern", "pattern", in); - } - } - } - } - - protected final Map> formats; - protected final List ignoringFormats; - - public BaseFormatValidatorFactory() { - this.formats = initFormatsMap(); - this.ignoringFormats = initIgnoringFormats(); - } - - protected List initIgnoringFormats() { - return Arrays.asList( - "int32", - "int64", - "float", - "double" - ); - } - - public abstract Map> initFormatsMap(); - - public void addStringFormatValidator(String formatName, Predicate validator) { - this.formats.put(formatName, validator); - } - - protected Predicate createPredicateFromPattern(final Pattern pattern) { - return (in) -> pattern.matcher(in).matches(); - } - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - String format = schema.getString("format"); - if (ignoringFormats.contains(format)) return null; - else { - Predicate v = formats.get(format); - if (v == null) throw new SchemaException(schema, "Format not supported"); - else return new FormatValidator(v); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("format"); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseMutableStateValidator.java b/src/main/java/io/vertx/json/schema/common/BaseMutableStateValidator.java deleted file mode 100644 index e0c53421..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseMutableStateValidator.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -public abstract class BaseMutableStateValidator implements MutableStateValidator { - - boolean isSync; - final private MutableStateValidator parent; - - public BaseMutableStateValidator(MutableStateValidator parent) { - this.parent = parent; - this.isSync = false; - } - - public abstract boolean calculateIsSync(); - - protected Future validateSyncAsAsync(ValidatorContext context, Object in) { - try { - validateSync(context, in); - triggerUpdateIsSync(); - return Future.succeededFuture(); - } catch (ValidationException e) { - return Future.failedFuture(e); - } - } - - protected void initializeIsSync() { - isSync = calculateIsSync(); - } - - @Override - public void triggerUpdateIsSync() { - boolean calculated = calculateIsSync(); - boolean previous = isSync; - isSync = calculated; - if (calculated != previous && getParent() != null) - getParent().triggerUpdateIsSync(); - } - - @Override - public MutableStateValidator getParent() { - return parent; - } - - protected void checkSync() throws ValidationException, NoSyncValidationException { - if (!isSync) - throw new NoSyncValidationException("Trying to execute validateSync() for a Validator in asynchronous state", this); - } - - @Override - public boolean isSync() { - return isSync; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.NORMAL_PRIORITY; - } -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseSchemaParser.java b/src/main/java/io/vertx/json/schema/common/BaseSchemaParser.java deleted file mode 100644 index 27debcef..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseSchemaParser.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.Json; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.SchemaRouter; - -import java.net.URI; -import java.util.AbstractMap.SimpleImmutableEntry; -import java.util.*; -import java.util.function.Predicate; - -/** - * @author Francesco Guardiani @slinkydeveloper - */ -@Deprecated -public abstract class BaseSchemaParser implements SchemaParserInternal { - - protected final List validatorFactories; - protected final SchemaRouter router; - - protected BaseSchemaParser(SchemaRouter router) { - this.router = router; - this.validatorFactories = initValidatorFactories(); - } - - @Override - public SchemaRouter getSchemaRouter() { - return router; - } - - @Override - public SchemaInternal parse(Object jsonSchema, final JsonPointer scope, MutableStateValidator parent) { - if (jsonSchema instanceof Map) jsonSchema = new JsonObject((Map) jsonSchema); - if (jsonSchema instanceof JsonObject) { - JsonObject json = (JsonObject) jsonSchema; - Set validators = new HashSet<>(); - - // 1. No $id, No $anchor, just add the schema with the provided scope - // 2. $id build the schema using $id (eventually resolved) and addSchema(schema), then addSchema(schema, scope) - // 2.1 If $id has also a fragment, add it as alias ( <= draft-7) - // 2.2 If $anchor, add it as alias ( >= draft2019-09) - Map.Entry, Optional> e = resolveIdAndAlias(json, scope.getURIWithoutFragment()); - - SchemaImpl s = e - .getKey() - .map(id -> createSchema(json, id, parent)).orElseGet(() -> createSchema(json, scope, parent)); - - if (e.getKey().isPresent()) { - router.addSchema(s, scope); - } else { - router.addSchema(s); - } - - e.getValue().ifPresent(alias -> router.addSchemaAlias(s, alias)); - - for (ValidatorFactory factory : validatorFactories) { - if (factory.canConsumeSchema(json)) { - Validator v = factory.createValidator(json, e.getKey().orElse(scope).copy(), this, s); - if (v != null) validators.add(v); - } - } - s.setValidators(validators); - return s; - } else if (jsonSchema instanceof Boolean) { - SchemaInternal s = ((Boolean) jsonSchema) ? TrueSchema.getInstance() : FalseSchema.getInstance(); - router.addSchemaWithScope(s, scope); - return s; - } else - throw new SchemaException(jsonSchema, "Schema must be a JsonObject or a Boolean"); - } - - protected SchemaImpl createSchema(JsonObject schema, JsonPointer scope, MutableStateValidator parent) { - if (schema.containsKey("$ref")) - return new RefSchema(schema, scope, this, parent, false); - else - return new SchemaImpl(schema, scope, parent); - } - - protected abstract List initValidatorFactories(); - - protected Map.Entry, Optional> resolveIdAndAlias(JsonObject schema, URI scope) { - // 2.1 If $id has also a fragment, add it as alias ( <= draft-7) - Optional id = Optional.empty(); - Optional alias = Optional.empty(); - - // Resolve the scope looking in $id - if (schema.containsKey("$id")) { - URI originalId = URI.create(schema.getString("$id")); - URI idWithoutFragment = URIUtils.removeFragment(originalId); - if (originalId.isAbsolute()) { - id = Optional.of(JsonPointer.fromURI(idWithoutFragment)); - } else if (originalId.getPath() != null && !originalId.getPath().isEmpty()) { - id = Optional.of(JsonPointer.fromURI(URIUtils.resolvePath(scope, idWithoutFragment.getPath()))); - } - - if (originalId.getFragment() != null && !originalId.getFragment().isEmpty()) { - alias = Optional.of(originalId.getFragment()); - } - } - - return new SimpleImmutableEntry<>(id, alias); - } - - @Override - public BaseSchemaParser withValidatorFactory(ValidatorFactory factory) { - this.validatorFactories.add(factory); - return this; - } - - @Override - public BaseSchemaParser withStringFormatValidator(String formatName, Predicate predicate) { - BaseFormatValidatorFactory f = (BaseFormatValidatorFactory) validatorFactories - .stream() - .filter(factory -> factory instanceof BaseFormatValidatorFactory) - .findFirst() - .orElseThrow(() -> new IllegalStateException("This json schema version doesn't support format keyword")); - f.addStringFormatValidator(formatName, predicate); - return this; - } - - @Override - public SchemaInternal parseFromString(String unparsedJson, JsonPointer scope, MutableStateValidator parent) { - return this.parse(Json.decodeValue(unparsedJson.trim()), scope, parent); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseSingleSchemaValidator.java b/src/main/java/io/vertx/json/schema/common/BaseSingleSchemaValidator.java deleted file mode 100644 index 17cadaff..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseSingleSchemaValidator.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -public abstract class BaseSingleSchemaValidator extends BaseMutableStateValidator { - - protected SchemaInternal schema; - - public BaseSingleSchemaValidator(MutableStateValidator parent) { - super(parent); - } - - @Override - public boolean calculateIsSync() { - return schema.isSync(); - } - - public void setSchema(SchemaInternal schema) { - this.schema = schema; - this.initializeIsSync(); - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseSingleSchemaValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/BaseSingleSchemaValidatorFactory.java deleted file mode 100644 index 8e703856..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseSingleSchemaValidatorFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; - -public abstract class BaseSingleSchemaValidatorFactory implements ValidatorFactory { - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Object itemsSchema = schema.getValue(getKeyword()); - BaseSingleSchemaValidator validator = instantiate(parent); - validator.setSchema(parser.parse(itemsSchema, scope.append(getKeyword()), validator)); - return validator; - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for " + getKeyword() + " keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null " + getKeyword() + " keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey(getKeyword()); - } - - protected abstract BaseSingleSchemaValidator instantiate(MutableStateValidator parent); - - protected abstract String getKeyword(); -} diff --git a/src/main/java/io/vertx/json/schema/common/BaseSyncValidator.java b/src/main/java/io/vertx/json/schema/common/BaseSyncValidator.java deleted file mode 100644 index 7c99c308..00000000 --- a/src/main/java/io/vertx/json/schema/common/BaseSyncValidator.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -public abstract class BaseSyncValidator implements SyncValidator { - - @Override - public boolean isSync() { - return true; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.NORMAL_PRIORITY; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/ComparisonUtils.java b/src/main/java/io/vertx/json/schema/common/ComparisonUtils.java deleted file mode 100644 index a6ca9627..00000000 --- a/src/main/java/io/vertx/json/schema/common/ComparisonUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.Objects; - -public class ComparisonUtils { - - /* - In Json Schema there is no difference between different number sizing. - So we eventually need to coerce types - */ - public static boolean equalsNumberSafe(Object a, Object b) { - if (a == null || b == null) { - return a == null && b == null; - } - - if (a.getClass().equals(b.getClass())) { - return Objects.equals(a, b); - } - - if (a instanceof Number && b instanceof Number) { - if ((a instanceof Integer && b instanceof Long) || (a instanceof Long && b instanceof Integer)) { - return ((Number) a).longValue() == ((Number) b).longValue(); - } - return ((Number) a).doubleValue() == ((Number) b).doubleValue(); - - } - return Objects.equals(a, b); - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/ConstValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/ConstValidatorFactory.java deleted file mode 100644 index 0edff5d5..00000000 --- a/src/main/java/io/vertx/json/schema/common/ConstValidatorFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.ValidationException; - -public class ConstValidatorFactory implements ValidatorFactory { - - @SuppressWarnings("unchecked") - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - Object allowedValue = schema.getValue("const"); - return new ConstValidator(allowedValue); - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("const"); - } - - public static class ConstValidator extends BaseSyncValidator { - - private final Object allowedValue; - - public ConstValidator(Object allowedValue) { - this.allowedValue = allowedValue; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.MAX_PRIORITY; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (!ComparisonUtils.equalsNumberSafe(allowedValue, in)) - throw ValidationException.create("Input doesn't match const: " + allowedValue, "const", in); - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/DefaultApplier.java b/src/main/java/io/vertx/json/schema/common/DefaultApplier.java deleted file mode 100644 index 34c961d3..00000000 --- a/src/main/java/io/vertx/json/schema/common/DefaultApplier.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; - -public interface DefaultApplier { - - Future applyDefaultValue(Object value); - -} diff --git a/src/main/java/io/vertx/json/schema/common/DefinitionsValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/DefinitionsValidatorFactory.java deleted file mode 100644 index 8502184a..00000000 --- a/src/main/java/io/vertx/json/schema/common/DefinitionsValidatorFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; - -import java.util.Map; - -public class DefinitionsValidatorFactory implements ValidatorFactory { - - private final String definitionsKey; - - public DefinitionsValidatorFactory(String definitionsKey) { - this.definitionsKey = definitionsKey; - } - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - JsonObject definitions = schema.getJsonObject(this.definitionsKey); - JsonPointer basePointer = scope.append(this.definitionsKey); - definitions.forEach(e -> - parser.parse((e.getValue() instanceof Map) ? new JsonObject((Map) e.getValue()) : e.getValue(), basePointer.copy().append(e.getKey()), null)); - return null; - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for " + this.definitionsKey + " keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null " + this.definitionsKey + " keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey(this.definitionsKey); - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/EnumValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/EnumValidatorFactory.java deleted file mode 100644 index d6544c45..00000000 --- a/src/main/java/io/vertx/json/schema/common/EnumValidatorFactory.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -public class EnumValidatorFactory implements ValidatorFactory { - - @SuppressWarnings("unchecked") - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - JsonArray allowedValues = (JsonArray) schema.getValue("enum"); - Set allowedValuesParsed = (Set) allowedValues - .getList().stream() - .map(o -> - (o instanceof Map) ? new JsonObject((Map) o) : - (o instanceof List) ? new JsonArray((List) o) : - o - ).collect(Collectors.toSet()); - return new EnumValidator(allowedValuesParsed); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for enum keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null enum keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("enum"); - } - - public static class EnumValidator extends BaseSyncValidator { - private final Object[] allowedValues; - - public EnumValidator(Set allowedValues) { - this.allowedValues = allowedValues.toArray(); - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.MAX_PRIORITY; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - for (Object allowedValue : allowedValues) { - if (ComparisonUtils.equalsNumberSafe(allowedValue, in)) - return; - } - throw ValidationException.create("Input doesn't match one of allowed values of enum: " + Arrays.toString(allowedValues), "enum", in); - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/ExclusiveMaximumValidator.java b/src/main/java/io/vertx/json/schema/common/ExclusiveMaximumValidator.java deleted file mode 100644 index e6d95436..00000000 --- a/src/main/java/io/vertx/json/schema/common/ExclusiveMaximumValidator.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.json.schema.ValidationException; - -import static io.vertx.json.schema.ValidationException.create; - -public class ExclusiveMaximumValidator extends BaseSyncValidator { - private final double maximum; - - public ExclusiveMaximumValidator(double maximum) { - this.maximum = maximum; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof Number) { - if (((Number) in).doubleValue() >= maximum) { - throw create("value should be < " + maximum, "maximum", in); - } - } - } -} diff --git a/src/main/java/io/vertx/json/schema/common/ExclusiveMinimumValidator.java b/src/main/java/io/vertx/json/schema/common/ExclusiveMinimumValidator.java deleted file mode 100644 index 69828f70..00000000 --- a/src/main/java/io/vertx/json/schema/common/ExclusiveMinimumValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.json.schema.ValidationException; - -public class ExclusiveMinimumValidator extends BaseSyncValidator { - private final double minimum; - - public ExclusiveMinimumValidator(double minimum) { - this.minimum = minimum; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof Number) { - if (((Number) in).doubleValue() <= minimum) { - throw ValidationException.create("value should be > " + minimum, "minimum", in); - } - } - } -} diff --git a/src/main/java/io/vertx/json/schema/common/FalseSchema.java b/src/main/java/io/vertx/json/schema/common/FalseSchema.java deleted file mode 100644 index 5b1bed1c..00000000 --- a/src/main/java/io/vertx/json/schema/common/FalseSchema.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -public class FalseSchema implements SchemaInternal { - - private static class FalseSchemaHolder { - static final FalseSchema INSTANCE = new FalseSchema(null); - } - - public static FalseSchema getInstance() { - return FalseSchemaHolder.INSTANCE; - } - - final MutableStateValidator parent; - - public FalseSchema(MutableStateValidator parent) { - this.parent = parent; - } - - @Override - public boolean isSync() { - return true; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.MAX_PRIORITY; - } - - @Override - public void validateSync(Object in) throws ValidationException, NoSyncValidationException { - throw ValidationException.create("False schema always fail validation", null, in); - } - - @Override - public Future validateAsync(Object in) { - return Future.failedFuture(ValidationException.create("False schema always fail validation", null, in)); - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - return this.validateAsync(in); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.validateSync(in); - } - - @Override - public JsonPointer getScope() { - return JsonPointer.create(); - } - - @Override - public Boolean getJson() { - return false; - } - - @Override - public Future getOrApplyDefaultAsync(Object input) { - return Future.succeededFuture(input); - } - - @Override - public Object getOrApplyDefaultSync(Object input) { - return input; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/FutureUtils.java b/src/main/java/io/vertx/json/schema/common/FutureUtils.java deleted file mode 100644 index f48ce340..00000000 --- a/src/main/java/io/vertx/json/schema/common/FutureUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.core.Promise; - -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -public class FutureUtils { - - public static Future oneOf(List> results) { - final Promise res = Promise.promise(); - final AtomicInteger processed = new AtomicInteger(0); - final AtomicBoolean atLeastOneOk = new AtomicBoolean(false); - final AtomicReference result = new AtomicReference<>(); - final int len = results.size(); - for (Future tFuture : results) { - tFuture.onComplete(ar -> { - int p = processed.incrementAndGet(); - if (ar.succeeded()) { - if (atLeastOneOk.get()) - res.tryFail(new IllegalStateException("One future was already completed")); - else { - atLeastOneOk.set(true); - result.set(res.future().result()); - } - } - if (p == len) { - if (atLeastOneOk.get()) res.tryComplete(result.get()); - else res.tryFail(new IllegalStateException(ar.cause())); - } - }); - } - return res.future(); - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/ItemsValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/ItemsValidatorFactory.java deleted file mode 100644 index c39bd85f..00000000 --- a/src/main/java/io/vertx/json/schema/common/ItemsValidatorFactory.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.CompositeFuture; -import io.vertx.core.Future; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -import java.util.ArrayList; -import java.util.List; - -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class ItemsValidatorFactory extends BaseSingleSchemaValidatorFactory { - - @Override - protected BaseSingleSchemaValidator instantiate(MutableStateValidator parent) { - return new ItemsValidator(parent); - } - - @Override - protected String getKeyword() { - return "items"; - } - - static class ItemsValidator extends BaseSingleSchemaValidator implements DefaultApplier { - - public ItemsValidator(MutableStateValidator parent) { - super(parent); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.checkSync(); - in = unwrap(in); - if (in instanceof List) { - List arr = (List) in; - for (int i = 0; i < arr.size(); i++) { - context.markEvaluatedItem(i); - schema.validateSync(context.lowerLevelContext(i), arr.get(i)); - } - } - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - if (isSync()) return validateSyncAsAsync(context, in); - in = unwrap(in); - if (in instanceof List) { - List arr = (List) in; - List> futs = new ArrayList<>(); - for (int i = 0; i < arr.size(); i++) { - context.markEvaluatedItem(i); - Future f = schema.validateAsync(context.lowerLevelContext(i), arr.get(i)); - if (f.isComplete()) { - if (f.failed()) return Future.failedFuture(f.cause()); - } else { - futs.add(f); - } - } - if (futs.isEmpty()) - return Future.succeededFuture(); - else - return Future.all(futs).compose(cf -> Future.succeededFuture()); - } else return Future.succeededFuture(); - } - - @Override - public Future applyDefaultValue(Object value) { - value = unwrap(value); - if (!(value instanceof List)) { - return Future.succeededFuture(); - } - - List> futures = new ArrayList<>(); - List arr = (List) value; - for (Object valToDefault : arr) { - if (schema.isSync()) { - schema.getOrApplyDefaultSync(valToDefault); - } else { - futures.add( - schema.getOrApplyDefaultAsync(valToDefault) - ); - } - } - - if (futures.isEmpty()) { - return Future.succeededFuture(); - } - - return Future.all(futures).mapEmpty(); - } - } -} diff --git a/src/main/java/io/vertx/json/schema/common/JsonSchemaType.java b/src/main/java/io/vertx/json/schema/common/JsonSchemaType.java deleted file mode 100644 index 13bfbf0b..00000000 --- a/src/main/java/io/vertx/json/schema/common/JsonSchemaType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.Objects; -import java.util.function.Predicate; - -public enum JsonSchemaType { - NULL(Objects::isNull), - BOOLEAN(o -> o instanceof Boolean), - OBJECT(JsonUtil::isObject), - ARRAY(JsonUtil::isArray), - NUMBER(o -> o instanceof Number), - NUMBER_DECIMAL(o -> o instanceof Double || o instanceof Float), - INTEGER(o -> o instanceof Long || o instanceof Integer), - STRING(o -> o instanceof String); - - private final Predicate checkInstancePredicate; - - JsonSchemaType(Predicate checkInstancePredicate) { - this.checkInstancePredicate = checkInstancePredicate; - } - - public boolean checkInstance(Object obj) { - return checkInstancePredicate.test(obj); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/JsonUtil.java b/src/main/java/io/vertx/json/schema/common/JsonUtil.java deleted file mode 100644 index 2b351c86..00000000 --- a/src/main/java/io/vertx/json/schema/common/JsonUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; - -import java.util.List; -import java.util.Map; - -public final class JsonUtil { - private JsonUtil() {} - - public static boolean isObject(Object o) { - return o instanceof JsonObject || o instanceof Map; - } - - public static boolean isArray(Object o) { - return o instanceof JsonArray || o instanceof List; - } - - public static Object unwrap(Object o) { - if (o instanceof JsonObject) { - return ((JsonObject) o).getMap(); - } - if (o instanceof JsonArray) { - return ((JsonArray) o).getList(); - } - return o; - } -} diff --git a/src/main/java/io/vertx/json/schema/common/MaxItemsValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MaxItemsValidatorFactory.java deleted file mode 100644 index 19a8199c..00000000 --- a/src/main/java/io/vertx/json/schema/common/MaxItemsValidatorFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.List; - -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class MaxItemsValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number maximum = (Number) schema.getValue("maxItems"); - if (maximum.intValue() < 0) - throw new SchemaException(schema, "maxItems must be >= 0"); - return new MaxItemsValidator(maximum.intValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for maxItems keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null maxItems keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("maxItems"); - } - - public static class MaxItemsValidator extends BaseSyncValidator { - private final int maximum; - - public MaxItemsValidator(int maximum) { - this.maximum = maximum; - } - - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException { - Object o = unwrap(in); - if (o instanceof List) { - List arr = (List) o; - if (arr.size() > maximum) { - throw ValidationException.create("provided array should have size <= " + maximum, "maxItems", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MaxLengthValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MaxLengthValidatorFactory.java deleted file mode 100644 index 92bec464..00000000 --- a/src/main/java/io/vertx/json/schema/common/MaxLengthValidatorFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -public class MaxLengthValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number maximum = (Number) schema.getValue("maxLength"); - if (maximum.intValue() < 0) - throw new SchemaException(schema, "maxLength must be >= 0"); - return new MaxLengthValidator(maximum.intValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for maxLength keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null maxLength keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("maxLength"); - } - - public static class MaxLengthValidator extends BaseSyncValidator { - private final int maximum; - - public MaxLengthValidator(int maximum) { - this.maximum = maximum; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof String) { - if (((String) in).codePointCount(0, ((String) in).length()) > maximum) { - throw ValidationException.create("provided string should have size <= " + maximum, "maxLength", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MaxPropertiesValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MaxPropertiesValidatorFactory.java deleted file mode 100644 index d887f32b..00000000 --- a/src/main/java/io/vertx/json/schema/common/MaxPropertiesValidatorFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.Map; - -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class MaxPropertiesValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number maximum = (Number) schema.getValue("maxProperties"); - if (maximum.intValue() < 0) - throw new SchemaException(schema, "maxProperties must be >= 0"); - return new MaxPropertiesValidator(maximum.intValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for maxProperties keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null maxProperties keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("maxProperties"); - } - - public static class MaxPropertiesValidator extends BaseSyncValidator { - private final int maximum; - - public MaxPropertiesValidator(int maximum) { - this.maximum = maximum; - } - - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException { - Object o = unwrap(in); - if (o instanceof Map) { - if (((Map) o).size() > maximum) { - throw ValidationException.create("provided object should have size <= " + maximum, "maxProperties", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MaximumValidator.java b/src/main/java/io/vertx/json/schema/common/MaximumValidator.java deleted file mode 100644 index 3aca1a6a..00000000 --- a/src/main/java/io/vertx/json/schema/common/MaximumValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.json.schema.ValidationException; - -public class MaximumValidator extends BaseSyncValidator { - private final double maximum; - - public MaximumValidator(double maximum) { - this.maximum = maximum; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof Number) { - if (((Number) in).doubleValue() > maximum) { - throw ValidationException.create("value should be <= " + maximum, "maximum", in); - } - } - } -} diff --git a/src/main/java/io/vertx/json/schema/common/MinItemsValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MinItemsValidatorFactory.java deleted file mode 100644 index 2f392dea..00000000 --- a/src/main/java/io/vertx/json/schema/common/MinItemsValidatorFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.List; - -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class MinItemsValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number minimum = (Number) schema.getValue("minItems"); - if (minimum.intValue() < 0) - throw new SchemaException(schema, "minItems must be >= 0"); - return new MinItemsValidator(minimum.intValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for minItems keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null minItems keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("minItems"); - } - - public static class MinItemsValidator extends BaseSyncValidator { - private final int minimum; - - public MinItemsValidator(int minimum) { - this.minimum = minimum; - } - - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException { - Object o = unwrap(in); - if (o instanceof List) { - List arr = (List) o; - if (arr.size() < minimum) { - throw ValidationException.create("provided array should have size >= " + minimum, "minItems", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MinLengthValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MinLengthValidatorFactory.java deleted file mode 100644 index 7f605ecb..00000000 --- a/src/main/java/io/vertx/json/schema/common/MinLengthValidatorFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -public class MinLengthValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number minimum = (Number) schema.getValue("minLength"); - if (minimum.intValue() < 0) - throw new SchemaException(schema, "minLength must be >= 0"); - return new MinLengthValidator(minimum.intValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for minLength keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null minLength keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("minLength"); - } - - public static class MinLengthValidator extends BaseSyncValidator { - private final int minimum; - - public MinLengthValidator(int minimum) { - this.minimum = minimum; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof String) { - if (((String) in).codePointCount(0, ((String) in).length()) < minimum) { - throw ValidationException.create("provided string should have size >= " + minimum, "minLength", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MinPropertiesValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MinPropertiesValidatorFactory.java deleted file mode 100644 index 07f78cfd..00000000 --- a/src/main/java/io/vertx/json/schema/common/MinPropertiesValidatorFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.Map; - -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class MinPropertiesValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number minimum = (Number) schema.getValue("minProperties"); - if (minimum.intValue() < 0) - throw new SchemaException(schema, "minProperties must be >= 0"); - return new MinPropertiesValidator(minimum.intValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for minProperties keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null minProperties keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("minProperties"); - } - - public static class MinPropertiesValidator extends BaseSyncValidator { - private final int minimum; - - public MinPropertiesValidator(int minimum) { - this.minimum = minimum; - } - - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException { - Object o = unwrap(in); - if (o instanceof Map) { - if (((Map) o).size() < minimum) { - throw ValidationException.create("provided object should have size >= " + minimum, "minProperties", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MinimumValidator.java b/src/main/java/io/vertx/json/schema/common/MinimumValidator.java deleted file mode 100644 index 25159959..00000000 --- a/src/main/java/io/vertx/json/schema/common/MinimumValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.json.schema.ValidationException; - -public class MinimumValidator extends BaseSyncValidator { - private final double minimum; - - public MinimumValidator(double minimum) { - this.minimum = minimum; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof Number) { - if (((Number) in).doubleValue() < minimum) { - throw ValidationException.create("value should be >= " + minimum, "minimum", in); - } - } - } -} diff --git a/src/main/java/io/vertx/json/schema/common/MultipleOfValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/MultipleOfValidatorFactory.java deleted file mode 100644 index 847cf3b6..00000000 --- a/src/main/java/io/vertx/json/schema/common/MultipleOfValidatorFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -public class MultipleOfValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number multipleOf = (Number) schema.getValue("multipleOf"); - return new MultipleOfValidator(multipleOf.doubleValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for multipleOf keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null multipleOf keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("multipleOf"); - } - - static class MultipleOfValidator extends BaseSyncValidator { - private final double multipleOf; - - public MultipleOfValidator(double multipleOf) { - this.multipleOf = multipleOf; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof Number) { - if (((Number) in).doubleValue() % multipleOf != 0) { - throw ValidationException.create("provided number should be multiple of " + multipleOf, "multipleOf", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/MutableStateValidator.java b/src/main/java/io/vertx/json/schema/common/MutableStateValidator.java deleted file mode 100644 index 681676ad..00000000 --- a/src/main/java/io/vertx/json/schema/common/MutableStateValidator.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -public interface MutableStateValidator extends AsyncValidator, SyncValidator { - - /** - * Returns the parent of this schema. This is required for sync state update - * - * @return - */ - MutableStateValidator getParent(); - - /** - * Manually trigger the sync state update - */ - void triggerUpdateIsSync(); - -} diff --git a/src/main/java/io/vertx/json/schema/common/NoopValidatorContext.java b/src/main/java/io/vertx/json/schema/common/NoopValidatorContext.java deleted file mode 100644 index d4883d0b..00000000 --- a/src/main/java/io/vertx/json/schema/common/NoopValidatorContext.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.Collections; -import java.util.Set; - -/** - * This noop {@link ValidatorContext} can be used when no contextual keywords are used - */ -public class NoopValidatorContext implements ValidatorContext { - - final private ValidatorContext parent; - final private String inputKey; - - public NoopValidatorContext() { - this.parent = null; - this.inputKey = null; - } - - public NoopValidatorContext(ValidatorContext parent, String inputKey) { - this.parent = parent; - this.inputKey = inputKey; - } - - @Override - public ValidatorContext startRecording() { - return new RecordingValidatorContext(parent, inputKey); - } - - @Override - public void markEvaluatedItem(int index) { - } - - @Override - public void markEvaluatedProperty(String propertyName) { - } - - @Override - public Set evaluatedItems() { - return Collections.emptySet(); - } - - @Override - public Set evaluatedProperties() { - return Collections.emptySet(); - } - - @Override - public ValidatorContext lowerLevelContext(String key) { - return new NoopValidatorContext(this, key); - } - - @Override - public ValidatorContext lowerLevelContext(int key) { - return new NoopValidatorContext(this, Integer.toString(key)); - } - - @Override - public ValidatorContext parent() { - return parent; - } - - @Override - public String inputKey() { - return inputKey; - } -} diff --git a/src/main/java/io/vertx/json/schema/common/NotValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/NotValidatorFactory.java deleted file mode 100644 index 43610336..00000000 --- a/src/main/java/io/vertx/json/schema/common/NotValidatorFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -public class NotValidatorFactory extends BaseSingleSchemaValidatorFactory { - - @Override - protected BaseSingleSchemaValidator instantiate(MutableStateValidator parent) { - return new NotValidator(parent); - } - - @Override - protected String getKeyword() { - return "not"; - } - - static class NotValidator extends BaseSingleSchemaValidator { - - public NotValidator(MutableStateValidator parent) { - super(parent); - } - - private boolean isValidSync(ValidatorContext context, Object in) { - try { - schema.validateSync(context, in); - return true; - } catch (ValidationException e) { - return false; - } - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.checkSync(); - if (isValidSync(context, in)) throw ValidationException.create("input should be invalid", "not", in); - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - if (isSync()) return validateSyncAsAsync(context, in); - return schema - .validateAsync(context, in) - .compose( - res -> Future.failedFuture(ValidationException.create("input should be invalid", "not", in)), - err -> Future.succeededFuture() - ); - } - - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/OneOfValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/OneOfValidatorFactory.java deleted file mode 100644 index bc67ed68..00000000 --- a/src/main/java/io/vertx/json/schema/common/OneOfValidatorFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -import java.util.Arrays; -import java.util.stream.Collectors; - -public class OneOfValidatorFactory extends BaseCombinatorsValidatorFactory { - - @Override - BaseCombinatorsValidator instantiate(MutableStateValidator parent) { - return new OneOfValidator(parent); - } - - @Override - String getKeyword() { - return "oneOf"; - } - - static class OneOfValidator extends BaseCombinatorsValidator { - - public OneOfValidator(MutableStateValidator parent) { - super(parent); - } - - private boolean isValidSync(SchemaInternal schema, ValidatorContext context, Object in) { - try { - schema.validateSync(context, in); - return true; - } catch (ValidationException e) { - return false; - } - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.checkSync(); - long validCount = Arrays.stream(schemas).map(s -> isValidSync(s, context, in)).filter(b -> b.equals(true)).count(); - if (validCount > 1) throw ValidationException.create("More than one schema valid", "oneOf", in); - else if (validCount == 0) throw ValidationException.create("No schema matches", "oneOf", in); - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - if (isSync()) return validateSyncAsAsync(context, in); - return FutureUtils - .oneOf(Arrays.stream(schemas).map(s -> s.validateAsync(context, in)).collect(Collectors.toList())) - .recover(err -> Future.failedFuture(ValidationException.create("No schema matches", "oneOf", in, err))); - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/PatternValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/PatternValidatorFactory.java deleted file mode 100644 index 7c0432e3..00000000 --- a/src/main/java/io/vertx/json/schema/common/PatternValidatorFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -public class PatternValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - String pattern = (String) schema.getValue("pattern"); - return new PatternValidator(Pattern.compile(pattern)); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for pattern keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null pattern keyword", e); - } catch (PatternSyntaxException e) { - throw new SchemaException(schema, "Invalid pattern in pattern keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("pattern"); - } - - public static class PatternValidator extends BaseSyncValidator { - private final Pattern pattern; - - public PatternValidator(Pattern pattern) { - this.pattern = pattern; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in instanceof String) { - Matcher m = pattern.matcher((String) in); - if (!(m.matches() || m.lookingAt() || m.find())) { - throw ValidationException.create("provided string should respect pattern " + pattern, "pattern", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/PriorityGetter.java b/src/main/java/io/vertx/json/schema/common/PriorityGetter.java deleted file mode 100644 index eecba4ea..00000000 --- a/src/main/java/io/vertx/json/schema/common/PriorityGetter.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -public interface PriorityGetter { - - /** - * Returns the priority - * - * @return - */ - ValidatorPriority getPriority(); - -} diff --git a/src/main/java/io/vertx/json/schema/common/PropertiesValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/PropertiesValidatorFactory.java deleted file mode 100644 index ac6ce6d5..00000000 --- a/src/main/java/io/vertx/json/schema/common/PropertiesValidatorFactory.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.CompositeFuture; -import io.vertx.core.Future; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; -import java.util.stream.Stream; - -import static io.vertx.json.schema.ValidationException.create; -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class PropertiesValidatorFactory implements ValidatorFactory { - - private SchemaInternal parseAdditionalProperties(Object obj, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - return parser.parse(obj, scope.copy().append("additionalProperties"), parent); - } catch (ClassCastException e) { - throw new SchemaException(obj, "Wrong type for additionalProperties keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(obj, "Null additionalProperties keyword", e); - } - } - - private Map parseProperties(JsonObject obj, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - JsonPointer basePointer = scope.copy().append("properties"); - Map parsedSchemas = new HashMap<>(); - for (Map.Entry entry : obj) { - try { - parsedSchemas.put(entry.getKey(), parser.parse( - entry.getValue(), - basePointer.copy().append(entry.getKey()), - parent - )); - } catch (ClassCastException | NullPointerException e) { - throw new SchemaException(obj, "Property descriptor " + entry.getKey() + " should be a not null JsonObject", e); - } - } - return parsedSchemas; - } - - private Map parsePatternProperties(JsonObject obj, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - JsonPointer basePointer = scope.copy().append("patternProperties"); - Map parsedSchemas = new HashMap<>(); - for (Map.Entry entry : obj) { - try { - parsedSchemas.put(Pattern.compile(entry.getKey()), parser.parse( - entry.getValue(), - basePointer.copy().append(entry.getKey()), - parent - )); - } catch (PatternSyntaxException e) { - throw new SchemaException(obj, "Invalid pattern for pattern keyword", e); - } catch (ClassCastException | NullPointerException e) { - throw new SchemaException(obj, "Property descriptor " + entry.getKey() + " should be a not null JsonObject", e); - } - } - return parsedSchemas; - } - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - JsonObject properties = schema.getJsonObject("properties"); - JsonObject patternProperties = schema.getJsonObject("patternProperties"); - Object additionalProperties = schema.getValue("additionalProperties"); - - PropertiesValidator validator = new PropertiesValidator(parent); - - Map parsedProperties = (properties != null) ? parseProperties(properties, scope, parser, validator) : null; - Map parsedPatternProperties = (patternProperties != null) ? parsePatternProperties(patternProperties, scope, parser, validator) : null; - - if (additionalProperties instanceof JsonObject) { - validator.configure(parsedProperties, parsedPatternProperties, parseAdditionalProperties(additionalProperties, scope, parser, validator)); - } else if (additionalProperties instanceof Boolean) { - validator.configure(parsedProperties, parsedPatternProperties, (Boolean) additionalProperties); - } else { - validator.configure(parsedProperties, parsedPatternProperties, true); - } - return validator; - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for properties/patternProperties keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("properties") || schema.containsKey("patternProperties") || schema.containsKey("additionalProperties"); - } - - private Future fillAdditionalPropertyException(Throwable t, Object in) { - return Future.failedFuture(ValidationException.create("additionalProperties schema should match", "additionalProperties", in, t)); - } - - class PropertiesValidator extends BaseMutableStateValidator implements DefaultApplier { - - private Map properties; - private Map patternProperties; - private boolean allowAdditionalProperties; - private SchemaInternal additionalPropertiesSchema; - - public PropertiesValidator(MutableStateValidator parent) { - super(parent); - } - - private void configure(Map properties, Map patternProperties, boolean allowAdditionalProperties) { - this.properties = properties; - this.patternProperties = patternProperties; - this.allowAdditionalProperties = allowAdditionalProperties; - this.additionalPropertiesSchema = null; - initializeIsSync(); - } - - private void configure(Map properties, Map patternProperties, SchemaInternal additionalPropertiesSchema) { - this.properties = properties; - this.patternProperties = patternProperties; - this.allowAdditionalProperties = true; - this.additionalPropertiesSchema = additionalPropertiesSchema; - initializeIsSync(); - } - - @Override - public boolean calculateIsSync() { - Stream props = (properties != null) ? properties.values().stream().map(Schema::isSync) : Stream.empty(); - Stream patternProps = (patternProperties != null) ? patternProperties.values().stream().map(Schema::isSync) : Stream.empty(); - Stream additionalProps = (additionalPropertiesSchema != null) ? Stream.of(additionalPropertiesSchema.isSync()) : Stream.empty(); - return Stream.concat( - props, - Stream.concat(patternProps, additionalProps) - ).reduce(true, Boolean::logicalAnd); - } - - @Override - public Future validateAsync(ValidatorContext context, final Object in) throws ValidationException { - if (isSync()) return validateSyncAsAsync(context, in); - Object o = unwrap(in); - if (o instanceof Map) { - Map obj = (Map) o; - List> futs = new ArrayList<>(); - for (String key : obj.keySet()) { - boolean found = false; - if (properties != null && properties.containsKey(key)) { - SchemaInternal s = properties.get(key); - context.markEvaluatedProperty(key); - if (s.isSync()) { - try { - s.validateSync(context.lowerLevelContext(key), obj.get(key)); - } catch (ValidationException e) { - return Future.failedFuture(e); - } - } else { - futs.add(s.validateAsync(context.lowerLevelContext(key), obj.get(key))); - } - found = true; - } - if (patternProperties != null) { - for (Map.Entry patternProperty : patternProperties.entrySet()) { - if (patternProperty.getKey().matcher(key).find()) { - SchemaInternal s = patternProperty.getValue(); - context.markEvaluatedProperty(key); - if (s.isSync()) { - try { - s.validateSync(context.lowerLevelContext(key), obj.get(key)); - } catch (ValidationException e) { - return Future.failedFuture(e); - } - } else { - futs.add(s.validateAsync(context.lowerLevelContext(key), obj.get(key))); - } - found = true; - } - } - } - if (!found) { - if (allowAdditionalProperties) { - if (additionalPropertiesSchema != null) { - context.markEvaluatedProperty(key); - if (additionalPropertiesSchema.isSync()) { - try { - additionalPropertiesSchema.validateSync(context.lowerLevelContext(key), obj.get(key)); - } catch (ValidationException e) { - return fillAdditionalPropertyException(e, in); - } - } else { - futs.add(additionalPropertiesSchema - .validateAsync(context.lowerLevelContext(key), obj.get(key)) - .recover(t -> fillAdditionalPropertyException(t, in)) - ); - } - } - } else { - return Future.failedFuture(create("Provided object contains unexpected additional property: " + key, "additionalProperties", in)); - } - } - } - if (futs.isEmpty()) return Future.succeededFuture(); - else return Future.all(futs).compose(cf -> Future.succeededFuture()); - } else return Future.succeededFuture(); - } - - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException { - this.checkSync(); - Object o = unwrap(in); - if (o instanceof Map) { - Map obj = (Map) o; - for (String key : obj.keySet()) { - boolean found = false; - if (properties != null && properties.containsKey(key)) { - SchemaInternal s = properties.get(key); - context.markEvaluatedProperty(key); - s.validateSync(context.lowerLevelContext(key), obj.get(key)); - found = true; - } - if (patternProperties != null) { - for (Map.Entry patternProperty : patternProperties.entrySet()) { - if (patternProperty.getKey().matcher(key).find()) { - SchemaInternal s = patternProperty.getValue(); - context.markEvaluatedProperty(key); - s.validateSync(context.lowerLevelContext(key), obj.get(key)); - found = true; - } - } - } - if (!found) { - if (allowAdditionalProperties) { - if (additionalPropertiesSchema != null) { - context.markEvaluatedProperty(key); - additionalPropertiesSchema.validateSync(context.lowerLevelContext(key), obj.get(key)); - } - } else { - throw create("Provided object contains unexpected additional property: " + key, "additionalProperties", in); - } - } - } - } - } - - @Override - public Future applyDefaultValue(Object value) { - value = unwrap(value); - if (!(value instanceof Map && properties != null)) { - return Future.succeededFuture(); - } - - List> futs = new ArrayList<>(); - Map obj = (Map) value; - for (Map.Entry e : properties.entrySet()) { - final String key = e.getKey(); - final SchemaInternal schema = e.getValue(); - - if (!obj.containsKey(key)) { - if (schema.isSync()) { - Object def = schema.getOrApplyDefaultSync(null); - if (def != null) { - obj.put(key, def); - } - } else { - futs.add( - schema.getOrApplyDefaultAsync(null).onSuccess(def -> { - if (def != null) { - obj.put(key, def); - } - }) - ); - } - } else { - if (schema.isSync()) { - schema.getOrApplyDefaultSync(obj.get(key)); - } else { - futs.add( - schema.getOrApplyDefaultAsync(obj.get(key)) - ); - } - } - } - - if (futs.isEmpty()) { - return Future.succeededFuture(); - } - - return Future.all(futs).mapEmpty(); - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/RecordingValidatorContext.java b/src/main/java/io/vertx/json/schema/common/RecordingValidatorContext.java deleted file mode 100644 index d12c8afc..00000000 --- a/src/main/java/io/vertx/json/schema/common/RecordingValidatorContext.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -public class RecordingValidatorContext implements ValidatorContext { - - final private ValidatorContext parent; - final private String inputKey; - private Set evaluatedItems; - private Set evaluatedProperties; - - public RecordingValidatorContext(ValidatorContext parent, String key) { - this.parent = parent; - this.inputKey = key; - } - - @Override - public ValidatorContext startRecording() { - return this; - } - - @Override - public void markEvaluatedItem(int index) { - if (evaluatedItems == null) { - this.evaluatedItems = new HashSet<>(); - } - evaluatedItems.add(index); - } - - @Override - public void markEvaluatedProperty(String propertyName) { - if (evaluatedProperties == null) { - this.evaluatedProperties = new HashSet<>(); - } - evaluatedProperties.add(propertyName); - } - - @Override - public Set evaluatedItems() { - return evaluatedItems != null ? evaluatedItems : Collections.emptySet(); - } - - @Override - public Set evaluatedProperties() { - return evaluatedProperties != null ? evaluatedProperties : Collections.emptySet(); - } - - @Override - public ValidatorContext lowerLevelContext(String key) { - return new NoopValidatorContext(this, key); - } - - @Override - public ValidatorContext lowerLevelContext(int key) { - return new NoopValidatorContext(this, Integer.toString(key)); - } - - @Override - public ValidatorContext parent() { - return this.parent; - } - - @Override - public String inputKey() { - return this.inputKey; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/RecursiveAnchorValidatorContextDecorator.java b/src/main/java/io/vertx/json/schema/common/RecursiveAnchorValidatorContextDecorator.java deleted file mode 100644 index 34400c5d..00000000 --- a/src/main/java/io/vertx/json/schema/common/RecursiveAnchorValidatorContextDecorator.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.pointer.JsonPointer; - -import java.util.Set; - -public class RecursiveAnchorValidatorContextDecorator implements ValidatorContext { - - private final ValidatorContext context; - private final JsonPointer recursiveAnchor; - - private RecursiveAnchorValidatorContextDecorator(ValidatorContext context, JsonPointer recursiveAnchor) { - this.context = context; - this.recursiveAnchor = recursiveAnchor; - } - - @Override - public void markEvaluatedItem(int index) { - this.context.markEvaluatedItem(index); - } - - @Override - public void markEvaluatedProperty(String propertyName) { - this.context.markEvaluatedProperty(propertyName); - } - - @Override - public Set evaluatedItems() { - return this.context.evaluatedItems(); - } - - @Override - public Set evaluatedProperties() { - return this.context.evaluatedProperties(); - } - - @Override - public ValidatorContext startRecording() { - return wrapNewContext(this.context.startRecording()); - } - - @Override - public ValidatorContext lowerLevelContext(String key) { - return wrapNewContext(this.context.lowerLevelContext(key)); - } - - @Override - public ValidatorContext lowerLevelContext(int key) { - return wrapNewContext(this.context.lowerLevelContext(key)); - } - - @Override - public ValidatorContext parent() { - return this.context.parent(); - } - - @Override - public String inputKey() { - return this.context.inputKey(); - } - - public JsonPointer getRecursiveAnchor() { - return this.recursiveAnchor; - } - - public ValidatorContext unwrap() { - return this.context; - } - - private ValidatorContext wrapNewContext(ValidatorContext newContext) { - if (newContext == this.context) { - return this; - } - return new RecursiveAnchorValidatorContextDecorator(newContext, this.recursiveAnchor); - } - - public static ValidatorContext wrap(ValidatorContext context, JsonPointer recursiveAnchor) { - if (context instanceof RecursiveAnchorValidatorContextDecorator) { - return context; - } else { - return new RecursiveAnchorValidatorContextDecorator(context, recursiveAnchor); - } - } - - public static ValidatorContext unwrap(ValidatorContext context) { - if (context instanceof RecursiveAnchorValidatorContextDecorator) { - return ((RecursiveAnchorValidatorContextDecorator) context).unwrap(); - } else { - return context; - } - } -} diff --git a/src/main/java/io/vertx/json/schema/common/RecursiveRefSchema.java b/src/main/java/io/vertx/json/schema/common/RecursiveRefSchema.java deleted file mode 100644 index 8ab3097e..00000000 --- a/src/main/java/io/vertx/json/schema/common/RecursiveRefSchema.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.core.impl.logging.Logger; -import io.vertx.core.impl.logging.LoggerFactory; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.SchemaParser; -import io.vertx.json.schema.ValidationException; - -import java.net.URI; - -import static io.vertx.json.schema.ValidationException.create; - -public class RecursiveRefSchema extends SchemaImpl { - - private static final Logger log = LoggerFactory.getLogger(RecursiveRefSchema.class); - - private final JsonPointer refPointer; - private final SchemaParser schemaParser; - - public RecursiveRefSchema(JsonObject schema, JsonPointer scope, SchemaParser schemaParser, MutableStateValidator parent) { - super(schema, scope, parent); - this.schemaParser = schemaParser; - try { - String unparsedUri = schema.getString("$recursiveRef"); - refPointer = URIUtils.createJsonPointerFromURI(URI.create(unparsedUri)); - if (log.isDebugEnabled()) log.debug(String.format("Parsed %s $recursiveRef for schema %s", refPointer, schema)); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null $recursiveRef keyword", e); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for $recursiveRef keyword", e); - } catch (IllegalArgumentException e) { - throw new SchemaException(schema, "$recursiveRef URI is invalid: " + e.getMessage(), e); - } - } - - @Override - public Future validateAsync(ValidatorContext inContext, Object in) { - // A recursive ref is always cached!!! - SchemaInternal solvedSchema; - try { - solvedSchema = resolveSchema(inContext); - } catch (SchemaException e) { - return Future.failedFuture(ValidationException.create("Error while resolving $recursiveRef " + refPointer.toURI(), "$recursiveRef", in, e)); - } - if (solvedSchema == null) { - return Future.failedFuture(create("Cannot resolve $recursiveRef " + refPointer.toURI(), "$recursiveRef", in)); - } - - ValidatorContext newContext = generateValidationContext(solvedSchema, inContext); - - if (solvedSchema.isSync() && this.isSync) { - try { - solvedSchema.validateSync(RecursiveAnchorValidatorContextDecorator.unwrap(newContext)); - runSyncValidator(newContext, in); - } catch (ValidationException e) { - return Future.failedFuture(e); - } - } - return solvedSchema - .validateAsync(RecursiveAnchorValidatorContextDecorator.unwrap(newContext), in) - .compose(v -> runAsyncValidators(newContext, in)); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - this.checkSync(); - } - - @Override - public boolean isSync() { - return false; - } - - @Override - protected void checkSync() throws ValidationException, NoSyncValidationException { - throw new NoSyncValidationException("Trying to execute validateSync() for a $recursiveRef schema", this); - } - - private SchemaInternal resolveSchema(ValidatorContext inContext) { - return (SchemaInternal) schemaParser.getSchemaRouter().resolveCachedSchema(this.refPointer, computeScope(inContext), schemaParser); - } - - private JsonPointer computeScope(ValidatorContext context) { - if (context instanceof RecursiveAnchorValidatorContextDecorator) { - RecursiveAnchorValidatorContextDecorator decorator = (RecursiveAnchorValidatorContextDecorator) context; - return decorator.getRecursiveAnchor(); - } - return this.getScope(); - } - - protected ValidatorContext generateValidationContext(SchemaInternal schema, ValidatorContext parent) { - ValidatorContext context = (schema instanceof SchemaImpl && ((SchemaImpl) schema).shouldRecordContext) ? parent.startRecording() : parent; - if (this.recursiveAnchor) { - return RecursiveAnchorValidatorContextDecorator.wrap(context, this.getScope()); - } - return context; - } - - @Override - public Future getOrApplyDefaultAsync(Object input) { - return Future.succeededFuture(input); // TODO Does it really makes sense default on $recursiveRef? - } - - @Override - public Object getOrApplyDefaultSync(Object input) { - return input; // TODO Does it really makes sense default on $recursiveRef? - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/RefSchema.java b/src/main/java/io/vertx/json/schema/common/RefSchema.java deleted file mode 100644 index d02ff3d7..00000000 --- a/src/main/java/io/vertx/json/schema/common/RefSchema.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.core.impl.logging.Logger; -import io.vertx.core.impl.logging.LoggerFactory; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.SchemaParser; -import io.vertx.json.schema.ValidationException; - -import java.net.URI; - -public class RefSchema extends SchemaImpl { - - private static final Logger log = LoggerFactory.getLogger(RefSchema.class); - - private final JsonPointer refPointer; - private final SchemaParser schemaParser; - private SchemaInternal cachedSchema; - - private final boolean executeSchemaValidators; - - public RefSchema(JsonObject schema, JsonPointer scope, SchemaParser schemaParser, MutableStateValidator parent, boolean executeSchemaValidators) { - super(schema, scope, parent); - this.schemaParser = schemaParser; - this.executeSchemaValidators = executeSchemaValidators; - try { - String unparsedUri = schema.getString("$ref"); - refPointer = URIUtils.createJsonPointerFromURI(URI.create(unparsedUri)); - if (log.isDebugEnabled()) log.debug(String.format("Parsed %s ref for schema %s", refPointer, schema)); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null $ref keyword", e); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for $ref keyword", e); - } catch (IllegalArgumentException e) { - throw new SchemaException(schema, "$ref URI is invalid: " + e.getMessage(), e); - } - } - - private void registerCachedSchema(SchemaInternal s) { - this.cachedSchema = s; - if (s instanceof SchemaImpl) - ((SchemaImpl) s).registerReferredSchema(this); - } - - @Override - public Future validateAsync(ValidatorContext inContext, Object in) { - if (isSync()) return validateSyncAsAsync(inContext, in); - ValidatorContext context = generateValidationContext(inContext); - if (cachedSchema == null) { - Future fut = schemaParser - .getSchemaRouter() - .resolveRef(refPointer, this.getScope(), schemaParser) - .compose( - s -> { - if (s == null) - return Future.failedFuture(ValidationException.create("Cannot resolve reference " + this.refPointer.toURI(), "$ref", in)); - SchemaInternal solvedSchema = (SchemaInternal) s; - registerCachedSchema(solvedSchema); - if (solvedSchema instanceof RefSchema) { - // We need to call solved schema validateAsync to solve upper ref, then we can update sync status - return solvedSchema.validateAsync(context, in).compose(v -> { - this.triggerUpdateIsSync(); - return Future.succeededFuture(); - }); - } else { - this.triggerUpdateIsSync(); - return solvedSchema.validateAsync(context, in); - } - }, - err -> Future.failedFuture(ValidationException.create("Error while resolving reference " + this.refPointer.toURI(), "$ref", in, err)) - ); - if (executeSchemaValidators) { - return fut.compose(v -> this.runAsyncValidators(context, in)); - } - return fut; - } else { - if (executeSchemaValidators) { - return cachedSchema - .validateAsync(context, in) - .compose(v -> this.runAsyncValidators(context, in)); - } else { - return cachedSchema.validateAsync(context, in); - } - } - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - this.checkSync(); - context = generateValidationContext(context); - // validateSync in RefSchema asserts that a cached schema exists - cachedSchema.validateSync(context, in); - if (executeSchemaValidators) { - runSyncValidator(context, in); - } - } - - @Override - public boolean calculateIsSync() { - return (!executeSchemaValidators || super.calculateIsSync()) && cachedSchema != null && cachedSchema.isSync(); - } - - @Override - protected void initializeIsSync() { - isSync = false; - } - - @Override - public Future getOrApplyDefaultAsync(Object input) { - if (this.isSync()) { - return Future.succeededFuture(getOrApplyDefaultSync(input)); - } - return trySolveSchema().compose(schemaInternal -> schemaInternal.getOrApplyDefaultAsync(input)); - } - - @Override - public Object getOrApplyDefaultSync(Object input) { - this.checkSync(); - return cachedSchema.getOrApplyDefaultSync(input); - } - - synchronized Future trySolveSchema() { - if (cachedSchema == null) { - return schemaParser - .getSchemaRouter() - .resolveRef(refPointer, this.getScope(), schemaParser) - .compose( - s -> { - if (s == null) - return Future.failedFuture(ValidationException.create("Cannot resolve reference " + this.refPointer.toURI(), "$ref", null)); - registerCachedSchema((SchemaInternal) s); - if (s instanceof RefSchema) { - // We need to call solved schema validateAsync to solve upper ref, then we can update sync status - return ((RefSchema) s).trySolveSchema().map(s1 -> { - this.triggerUpdateIsSync(); - return cachedSchema; - }); - } else { - this.triggerUpdateIsSync(); - return Future.succeededFuture(cachedSchema); - } - }, - err -> Future.failedFuture(ValidationException.create("Error while resolving reference " + this.refPointer.toURI(), "$ref", null, err)) - ); - } else return Future.succeededFuture(cachedSchema); - } - - void prePropagateSyncState() { - isSync = true; - if (getParent() != null) - getParent().triggerUpdateIsSync(); - } - - void setIsSync(boolean s) { - isSync = s; - if (getParent() != null) - getParent().triggerUpdateIsSync(); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/RegularExpressions.java b/src/main/java/io/vertx/json/schema/common/RegularExpressions.java deleted file mode 100644 index d6940df1..00000000 --- a/src/main/java/io/vertx/json/schema/common/RegularExpressions.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.regex.Pattern; - -/** - * @author Francesco Guardiani @slinkydeveloper - */ -public class RegularExpressions { - - public static final Pattern EMAIL_LOCAL = Pattern.compile("^(?:[\\w!#\\$%&'\\*\\+\\-/=\\?\\^`\\{\\|\\}~]+\\.)" + - "*[\\w!#\\$%&'\\*\\+\\-/=\\?\\^`\\{\\|\\}~]+$"); - public static final Pattern EMAIL = Pattern.compile("^(?:[\\w!#\\$%&'\\*\\+\\-/=\\?\\^`\\{\\|\\}~]+\\.)" + - "*[\\w!#\\$%&'\\*\\+\\-/=\\?\\^`\\{\\|\\}~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\\-](?!\\.)){0,61}[a-zA-Z0-9]?\\.)" - + "+[a-zA-Z0-9](?:[a-zA-Z0-9\\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\\[(?:(?:[01]?\\d{1,2}|2[0-4]\\d|25[0-5])\\.){3}" + - "(?:[01]?\\d{1,2}|2[0-4]\\d|25[0-5])\\]))$"); - public static final Pattern URI = Pattern.compile("^[a-zA-Z][a-zA-Z0-9+-.]*:[^\\s]*$"); - public static final Pattern DATE = Pattern.compile("^\\d{4}-(?:0[0-9]|1[0-2])-[0-9]{2}$"); - public static final Pattern DATETIME = Pattern.compile("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$"); - public static final Pattern TIME = Pattern.compile("^(?:[0-2]\\d:[0-5]\\d:[0-5]\\d|23:59:60)(?:\\.\\d+)?(?:[zZ]|[+-]\\d\\d:\\d\\d)?$"); - public static final Pattern BASE64 = Pattern.compile("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$"); - public static final Pattern IPV4 = Pattern.compile("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}" + "" + - "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); - public static final Pattern IPV6 = Pattern.compile("^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}" + "" + - "(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(" + - "([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\." + "" + - "(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|(" + "" + - "(:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|" + - "(" + "([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:(" + "" + - "(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:)" + - "{2}" + "(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\." + "" + - "(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|(" + "" + - "(:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))" - + "|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\." + "" + - "(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$"); - public static final Pattern HOSTNAME = Pattern.compile("^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])\\.)*" + "" + - "([A-Za-z]|[A-Za-z][A-Za-z0-9\\-]{0,61}[A-Za-z0-9])$"); - public static final Pattern RELATIVE_JSON_POINTER = Pattern.compile("^[0-9]+(#|(/(([^/~])|(~[01]))*))*$"); - public static final Pattern URI_TEMPLATE = Pattern.compile("^(?:(?:[^\\x00-\\x20\"'<>%\\\\^`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$"); - -} diff --git a/src/main/java/io/vertx/json/schema/common/RequiredValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/RequiredValidatorFactory.java deleted file mode 100644 index a4a7130a..00000000 --- a/src/main/java/io/vertx/json/schema/common/RequiredValidatorFactory.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static io.vertx.json.schema.ValidationException.create; -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class RequiredValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator validator) { - try { - JsonArray keys = (JsonArray) schema.getValue("required"); - return new RequiredValidator(new HashSet(keys.getList())); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for enum keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null enum keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("required"); - } - - public static class RequiredValidator extends BaseSyncValidator { - private final Set requiredKeys; - - public RequiredValidator(Set requiredKeys) { - this.requiredKeys = requiredKeys; - } - - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException { - Object o = unwrap(in); - if (o instanceof Map) { - Map obj = (Map) o; - for (String k : requiredKeys) { - if (!obj.containsKey(k)) - throw create("provided object should contain property " + k, "required", in); - } - } - } - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/RouterNode.java b/src/main/java/io/vertx/json/schema/common/RouterNode.java deleted file mode 100644 index d4eb3bd0..00000000 --- a/src/main/java/io/vertx/json/schema/common/RouterNode.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.json.schema.Schema; - -import java.util.*; -import java.util.stream.Stream; - -class RouterNode { - private SchemaInternal schema; - private final Map childs; - - public RouterNode() { - this(null); - } - - public RouterNode(SchemaInternal schema) { - this.schema = schema; - this.childs = new HashMap<>(); - } - - public void setSchema(SchemaInternal schema) { - this.schema = schema; - } - - public Schema getSchema() { - return schema; - } - - public Map getChilds() { - return childs; - } - - public Stream flattened() { - return flattenedList().stream(); - } - - public Stream reverseFlattened() { - List output = flattenedList(); - Collections.reverse(output); - return output.stream(); - } - - private List flattenedList() { - Stack nodesToScan = new Stack<>(); - nodesToScan.push(this); - List output = new ArrayList<>(); - - while (!nodesToScan.isEmpty()) { - RouterNode next = nodesToScan.pop(); - if (!output.contains(next)) { - next.childs.values().forEach(nodesToScan::push); - output.add(next); - } - } - - return output; - } -} diff --git a/src/main/java/io/vertx/json/schema/common/RouterNodeJsonPointerIterator.java b/src/main/java/io/vertx/json/schema/common/RouterNodeJsonPointerIterator.java deleted file mode 100644 index ab366f7e..00000000 --- a/src/main/java/io/vertx/json/schema/common/RouterNodeJsonPointerIterator.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.codegen.annotations.Nullable; -import io.vertx.core.json.pointer.JsonPointerIterator; - -class RouterNodeJsonPointerIterator implements JsonPointerIterator { - - public final static RouterNodeJsonPointerIterator INSTANCE = new RouterNodeJsonPointerIterator(); - - @Override - public boolean isObject(Object value) { - return !isNull(value); - } - - @Override - public boolean isArray(Object value) { - return false; - } - - @Override - public boolean isNull(Object value) { - return value == null; - } - - @Override - public boolean objectContainsKey(Object value, String key) { - return !isNull(value) && ((RouterNode) value).getChilds().containsKey(key); - } - - @Override - public Object getObjectParameter(Object value, String key, boolean createOnMissing) { - if (isObject(value)) { - if (!objectContainsKey(value, key)) { - if (createOnMissing) { - RouterNode node = new RouterNode(); - ((RouterNode) value).getChilds().put(key, node); - } else { - return null; - } - } - return ((RouterNode) value).getChilds().get(key); - } - return null; - } - - @Override - public Object getArrayElement(Object value, int i) { - return null; - } - - @Override - public boolean writeObjectParameter(Object value, String key, Object newElement) { - if (newElement instanceof SchemaInternal) { - value = this.getObjectParameter(value, key, true); - if (value != null) - ((RouterNode) value).setSchema((SchemaInternal) newElement); - return true; - } else if (newElement instanceof RouterNode) { - ((RouterNode) value).getChilds().put(key, (RouterNode) newElement); - return true; - } - return false; - } - - @Override - public boolean writeArrayElement(Object value, int i, @Nullable Object newElement) { - return false; - } - - @Override - public boolean appendArrayElement(Object value, Object newElement) { - return false; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/SchemaImpl.java b/src/main/java/io/vertx/json/schema/common/SchemaImpl.java deleted file mode 100644 index 4a8cc1b6..00000000 --- a/src/main/java/io/vertx/json/schema/common/SchemaImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.core.impl.logging.Logger; -import io.vertx.core.impl.logging.LoggerFactory; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -import java.util.*; -import java.util.stream.Collectors; - -public class SchemaImpl extends BaseMutableStateValidator implements SchemaInternal { - - private static final Logger log = LoggerFactory.getLogger(SchemaImpl.class); - - private final JsonObject schema; - private final JsonPointer scope; - private Validator[] validators; - protected boolean shouldRecordContext; - final boolean recursiveAnchor; - - private final Set referringSchemas; - - public SchemaImpl(JsonObject schema, JsonPointer scope, MutableStateValidator parent) { - super(parent); - this.schema = schema; - this.scope = scope; - this.shouldRecordContext = false; - this.recursiveAnchor = schema.getBoolean("$recursiveAnchor", false); - referringSchemas = new HashSet<>(); - } - - @Override - public Future validateAsync(Object json) { - return this.validateAsync(new NoopValidatorContext(), json); - } - - @Override - public void validateSync(Object json) throws ValidationException, NoSyncValidationException { - this.validateSync(new NoopValidatorContext(), json); - } - - @Override - public JsonPointer getScope() { - return scope; - } - - @Override - public JsonObject getJson() { - return schema; - } - - private Object getDefaultValue() { - return schema.getValue("default"); - } - - @Override - public Future getOrApplyDefaultAsync(Object input) { - if (this.isSync()) { - return Future.succeededFuture(this.getOrApplyDefaultSync(input)); - } - if (input == null) { - return Future.succeededFuture(getDefaultValue()); - } - return Future.all( - Arrays.stream(validators) - .filter(v -> v instanceof DefaultApplier) - .map(v -> ((DefaultApplier) v).applyDefaultValue(input)) - .collect(Collectors.toList()) - ).map(input); - } - - @Override - public Object getOrApplyDefaultSync(Object input) { - this.checkSync(); - if (input == null) { - return getDefaultValue(); - } - for (Validator v : validators) { - if (v instanceof DefaultApplier) { - ((DefaultApplier) v).applyDefaultValue(input); - } - } - return input; - } - - @Override - public void triggerUpdateIsSync() { - boolean calculated = calculateIsSync(); - boolean previous = isSync; - isSync = calculated; - if (calculated != previous) { - if (!referringSchemas.isEmpty()) - referringSchemas.forEach(r -> r.setIsSync(calculated)); - if (getParent() != null) - getParent().triggerUpdateIsSync(); - } - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - if (isSync()) return validateSyncAsAsync(context, in); - if (log.isTraceEnabled()) - log.trace(String.format("Starting async validation for schema %s and input %s", schema, in)); - - context = generateValidationContext(context); - - return runAsyncValidators(context, in); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.checkSync(); - context = generateValidationContext(context); - runSyncValidator(context, in); - } - - @Override - public boolean calculateIsSync() { - return validators.length == 0 || Arrays.stream(validators).map(Validator::isSync).reduce(true, Boolean::logicalAnd); - } - - void setValidators(Set validators) { - this.shouldRecordContext = validators - .stream() - .map(Validator::getPriority) - .anyMatch(p -> p == ValidatorPriority.CONTEXTUAL_VALIDATOR); - this.validators = validators.toArray(new Validator[0]); - Arrays.sort(this.validators, ValidatorPriority.COMPARATOR); - this.initializeIsSync(); - } - - void registerReferredSchema(RefSchema ref) { - referringSchemas.add(ref); - if (log.isTraceEnabled()) { - log.trace(String.format("Ref schema %s reefers to schema %s", ref, this)); - log.trace(String.format("Ref schemas that refeers to %s: %s", this, this.referringSchemas.size())); - } - // This is a trick to solve the circular references. - // 1. for each ref that reefers to this schema we propagate isSync = true to the upper levels. - // If this schema isSync = false only because its childs contains refs to itself, after the pre propagation - // this schema isSync = true, otherwise is still false - // 2. for each ref schema we set the isSync calculated and propagate to upper levels of refs - referringSchemas.forEach(RefSchema::prePropagateSyncState); - referringSchemas.forEach(r -> r.setIsSync(this.isSync)); - } - - protected ValidatorContext generateValidationContext(ValidatorContext parent) { - ValidatorContext context = shouldRecordContext ? parent.startRecording() : parent; - if (this.recursiveAnchor) { - return RecursiveAnchorValidatorContextDecorator.wrap(context, this.scope); - } - return context; - } - - protected Future runAsyncValidators(ValidatorContext context, Object in) { - List> futures = new ArrayList<>(); - for (Validator validator : validators) { - if (!validator.isSync()) { - Future asyncValidate = ((AsyncValidator) validator).validateAsync(context, in); - asyncValidate = asyncValidate.recover(t -> fillException(t, context, in)); - futures.add(asyncValidate); - } else try { - ((SyncValidator) validator).validateSync(context, in); - } catch (ValidationException e) { - fillValidationException(e, context); - return Future.failedFuture(e); - } - } - if (!futures.isEmpty()) { - return Future.all(futures).compose(cf -> Future.succeededFuture()); - } else { - return Future.succeededFuture(); - } - } - - protected void runSyncValidator(ValidatorContext context, Object in) { - for (Validator validator : validators) { - try { - ((SyncValidator) validator).validateSync(context, in); - } catch (ValidationException e) { - fillValidationException(e, context); - throw e; - } - } - } - - private void fillValidationException(ValidationException e, ValidatorContext context) { - if (e.inputScope() == null) { // We need to fill the exception only if it's not filled - ((ValidationExceptionImpl) e).setSchema(this); - // Compute the input scope pointer - List pointerChunks = new ArrayList<>(); - recursiveWalkBackTheValidationContext(context, pointerChunks); - ((ValidationExceptionImpl) e).setInputScope(JsonPointer.create().append(pointerChunks)); - } - } - - private Future fillException(Throwable e, ValidatorContext ctx, Object in) { - if (e instanceof ValidationException) { - ValidationException ve = (ValidationException) e; - fillValidationException(ve, ctx); - return Future.failedFuture(ve); - } else { - return Future.failedFuture(ValidationException.create("Error while validating", null, in, e)); - } - } - - private void recursiveWalkBackTheValidationContext(ValidatorContext context, List pointerElements) { - ValidatorContext parent = context.parent(); - if (parent == null) { - return; - } - recursiveWalkBackTheValidationContext(parent, pointerElements); - pointerElements.add(context.inputKey()); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/SchemaInternal.java b/src/main/java/io/vertx/json/schema/common/SchemaInternal.java deleted file mode 100644 index 8f785077..00000000 --- a/src/main/java/io/vertx/json/schema/common/SchemaInternal.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.json.schema.Schema; - -/** - * Schema should implement sync and async validator too - */ -public interface SchemaInternal extends Schema, AsyncValidator, SyncValidator { - - Future getOrApplyDefaultAsync(Object input); - - Object getOrApplyDefaultSync(Object input); - -} diff --git a/src/main/java/io/vertx/json/schema/common/SchemaParserInternal.java b/src/main/java/io/vertx/json/schema/common/SchemaParserInternal.java deleted file mode 100644 index 21e1b28f..00000000 --- a/src/main/java/io/vertx/json/schema/common/SchemaParserInternal.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaParser; - -import java.net.URI; - -@Deprecated -public interface SchemaParserInternal extends SchemaParser { - - @Override - default SchemaInternal parse(JsonObject jsonSchema) { - return parse(jsonSchema, new SchemaURNId().toPointer()); - } - - @Override - default SchemaInternal parse(Boolean jsonSchema) { - return parse(jsonSchema, new SchemaURNId().toPointer()); - } - - @Override - default SchemaInternal parseFromString(String unparsedJson) { - return parseFromString(unparsedJson, new SchemaURNId().toPointer()); - } - - @Override - default SchemaInternal parse(JsonObject jsonSchema, JsonPointer schemaPointer) { - return parse((Object) jsonSchema, schemaPointer); - } - - @Override - default SchemaInternal parse(Boolean jsonSchema, JsonPointer schemaPointer) { - return parse((Object) jsonSchema, schemaPointer); - } - - SchemaInternal parse(Object jsonSchema, JsonPointer scope, MutableStateValidator parent); - - default SchemaInternal parse(Object jsonSchema, JsonPointer scope) { - return parse(jsonSchema, scope, null); - } - - default SchemaInternal parse(Object jsonSchema, URI scope, MutableStateValidator parent) { - return this.parse(jsonSchema, JsonPointer.fromURI(scope), parent); - } - - default SchemaInternal parse(Object jsonSchema, URI scope) { - return parse(jsonSchema, scope, null); - } - - SchemaInternal parseFromString(String unparsedJson, JsonPointer scope, MutableStateValidator parent); - - default SchemaInternal parseFromString(String unparsedJson, JsonPointer schemaPointer) { - return parseFromString(unparsedJson, schemaPointer, null); - } - - default SchemaInternal parseFromString(String unparsedJson, URI scope, MutableStateValidator parent) { - return this.parseFromString(unparsedJson, JsonPointer.fromURI(scope), parent); - } - - default SchemaInternal parseFromString(String unparsedJson, URI scope) { - return this.parseFromString(unparsedJson, JsonPointer.fromURI(scope), null); - } - - -} diff --git a/src/main/java/io/vertx/json/schema/common/SchemaRouterImpl.java b/src/main/java/io/vertx/json/schema/common/SchemaRouterImpl.java deleted file mode 100644 index 26d96a07..00000000 --- a/src/main/java/io/vertx/json/schema/common/SchemaRouterImpl.java +++ /dev/null @@ -1,371 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.netty.handler.codec.http.QueryStringEncoder; -import io.vertx.core.*; -import io.vertx.core.buffer.Buffer; -import io.vertx.core.file.FileSystem; -import io.vertx.core.http.HttpClient; -import io.vertx.core.http.HttpHeaders; -import io.vertx.core.http.HttpMethod; -import io.vertx.core.http.RequestOptions; -import io.vertx.core.impl.VertxInternal; -import io.vertx.core.json.Json; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.*; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class SchemaRouterImpl implements SchemaRouter { - - private final Vertx vertx; - private final Map absolutePaths; - private final Map rootJsons; - private final HttpClient client; - private final FileSystem fs; - private final Map> externalSchemasSolving; - private final SchemaRouterOptions options; - - public SchemaRouterImpl(Vertx vertx, HttpClient client, FileSystem fs, SchemaRouterOptions options) { - this.vertx = vertx; - this.client = client; - this.fs = fs; - this.absolutePaths = new HashMap<>(); - this.rootJsons = new HashMap<>(); - this.externalSchemasSolving = new ConcurrentHashMap<>(); - this.options = options; - } - - @Override - public List registeredSchemas() { - return absolutePaths - .values() - .stream() - .flatMap(RouterNode::flattened) - .map(RouterNode::getSchema) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - } - - @Override - public Schema resolveCachedSchema(JsonPointer refPointer, JsonPointer scope, final SchemaParser parser) { - // Let's try first searching in already parsed cached schemas - return resolveParentNode(refPointer, scope) - .flatMap(parentNode -> { - Optional resultNode = Optional.ofNullable((RouterNode) refPointer.query(parentNode, RouterNodeJsonPointerIterator.INSTANCE)); - if (resultNode.isPresent()) - return resultNode.map(RouterNode::getSchema); - if (parentNode.getSchema() instanceof SchemaImpl) // Maybe the schema that we are searching was not parsed yet! - return Optional.ofNullable(refPointer.queryJson(parentNode.getSchema().getJson())) - .map(queryResult -> ((SchemaParserInternal) parser).parse(queryResult, URIUtils.replaceFragment(parentNode.getSchema().getScope().getURIWithoutFragment(), refPointer.toString()))); - return Optional.empty(); - }) - // Let's try from the rootJson, user could be requesting a json added but not parsed - .orElseGet(() -> resolveAbsoluteUriAlternatives(refPointer, scope) - .filter(rootJsons::containsKey) - .map(uriToSolve -> { - Object realLocation = refPointer.queryJson(rootJsons.get(uriToSolve)); - if (realLocation == null) { - return null; - } - return ((SchemaParserInternal) parser).parse( - realLocation, - JsonPointer.fromURI(URIUtils.replaceFragment(uriToSolve, refPointer.toString())) - ); - }) - .filter(Objects::nonNull) - .findFirst() - .orElse(null) - ); - } - - @Override - public Future resolveRef(final JsonPointer pointer, final JsonPointer scope, final SchemaParser schemaParser) { - try { - Schema cachedSchema = this.resolveCachedSchema(pointer, scope, schemaParser); - if (cachedSchema == null) { - return resolveExternalRef(pointer, scope, schemaParser); - } else return Future.succeededFuture(cachedSchema); - } catch (SchemaException e) { - return Future.failedFuture(e); - } - } - - @Override - public SchemaRouter addSchema(Schema schema, JsonPointer... aliasScope) { - JsonPointer pointer = schema.getScope(); - if (!pointer.getURIWithoutFragment().isAbsolute()) { - throw new IllegalStateException("Schema scope MUST be a pointer with an absolute URI. Actual: " + pointer.getURIWithoutFragment()); - } - RouterNode parentNode = absolutePaths.computeIfAbsent(pointer.getURIWithoutFragment(), k -> new RouterNode()); - insertSchema(pointer, parentNode, schema); - RouterNode insertedNode = (RouterNode) pointer.query(parentNode, RouterNodeJsonPointerIterator.INSTANCE); - - for (JsonPointer alias : aliasScope) { - if (!alias.getURIWithoutFragment().isAbsolute()) { - throw new IllegalStateException("Schema scope MUST be a pointer with an absolute URI. Actual: " + alias.getURIWithoutFragment()); - } - - insertRouterNode(alias, insertedNode); - } - - return this; - } - - @Override - public SchemaRouter addSchemaWithScope(Schema schema, JsonPointer scope) { - URIUtils.requireAbsoluteUri(scope.getURIWithoutFragment(), "schema scope"); - RouterNode parentNode = absolutePaths.computeIfAbsent(scope.getURIWithoutFragment(), k -> new RouterNode()); - insertSchema(scope, parentNode, schema); - return this; - } - - @Override - public SchemaRouter addSchemaAlias(Schema schema, String alias) { - RouterNode parentNode = absolutePaths.get(schema.getScope().getURIWithoutFragment()); - if (parentNode == null) { - throw new IllegalStateException("Schema parent node does not exists: " + schema.getScope().getURIWithoutFragment()); - } - RouterNode schemaNode = (RouterNode) schema.getScope().query(parentNode, RouterNodeJsonPointerIterator.INSTANCE); - if (schemaNode == null) { - throw new IllegalStateException("Schema node does not exists: " + schema.getScope().toURI()); - } - parentNode - .getChilds() - .put(alias, schemaNode); - return this; - } - - @Override - public SchemaRouter addJson(URI uri, JsonObject object) { - URIUtils.requireAbsoluteUri(uri); - this.rootJsons.put(uri, object); - return this; - } - - // Very very expensive method - public Future resolveAllSchemas() { - return Future - .all(this.registeredSchemas().stream().map(this::solveAllSchemaReferences).collect(Collectors.toList())) - .mapEmpty(); - } - - /** - * Deeply resolve all references of the provided {@code schema} - * - * @param schema - * @return returns a succeeded future with same instance of provided schema, or a failed schema if something went wrong - */ - public Future solveAllSchemaReferences(Schema schema) { - if (schema instanceof RefSchema) { - return ((RefSchema) schema) - .trySolveSchema() - .compose(s -> (s != schema) ? solveAllSchemaReferences(s).map(schema) : Future.succeededFuture(schema)); - } else { - // If not absolute, then there is nothing to resolve - if (schema.getScope().getURIWithoutFragment() == null || !schema.getScope().getURIWithoutFragment().isAbsolute()) { - return Future.succeededFuture(schema); - } - RouterNode node = absolutePaths.get(schema.getScope().getURIWithoutFragment()); - node = (RouterNode) schema.getScope().query(node, RouterNodeJsonPointerIterator.INSTANCE); - return Future.all( - node - .reverseFlattened() - .collect(Collectors.toList())// Must create a collection to avoid ConcurrentModificationException - .stream() - .map(RouterNode::getSchema) - .filter(Objects::nonNull) - .filter(s -> s instanceof RefSchema) - .map(s -> (RefSchema) s) - .map(RefSchema::trySolveSchema) - .collect(Collectors.toList()) - ).map(schema); - } - } - - // The idea is to traverse from base to actual scope all tree and find aliases - private Stream getScopeParentAliases(JsonPointer scope) { - Stream.Builder uriStreamBuilder = Stream.builder(); - RouterNode startingNode = absolutePaths.get(scope.getURIWithoutFragment()); - // If this is the first external ref solved by this schema router, then the startingNode could not be there - if (startingNode == null) { - return Stream.of(scope.getURIWithoutFragment()); - } - scope.tracedQuery(startingNode, RouterNodeJsonPointerIterator.INSTANCE) - .forEach((node) -> absolutePaths.forEach((uri, n) -> { - if (n == node) uriStreamBuilder.accept(uri); - })); - return uriStreamBuilder.build(); - } - - private Stream resolveAbsoluteUriAlternatives(JsonPointer refPointer, JsonPointer scope) { - URI refURI = refPointer.getURIWithoutFragment(); - if (!refURI.isAbsolute()) { - if (refURI.getPath() != null && !refURI.getPath().isEmpty()) { - // Path pointer - return Stream.concat( - getScopeParentAliases(scope) - .map(e -> URIUtils.resolvePath(e, refURI.getPath())), - Stream.of( - getResourceAbsoluteURI(refURI), - refURI - ) - ).filter(Objects::nonNull); - } else { - // Fragment pointer, fallback to scope - return Stream.of(scope.getURIWithoutFragment()); - } - } else { - // Absolute pointer - return Stream.of(refURI); - } - } - - private Optional resolveParentNode(JsonPointer refPointer, JsonPointer scope) { - return resolveAbsoluteUriAlternatives(refPointer, scope) - .map(absolutePaths::get) - .filter(Objects::nonNull) - .findFirst(); - } - - private Future solveRemoteRef(final URI ref) { - String uri = ref.toString(); - if (!options.getAuthQueryParams().isEmpty()) { - QueryStringEncoder encoder = new QueryStringEncoder(uri); - options.getAuthQueryParams().forEach(encoder::addParam); - uri = encoder.toString(); - } - - RequestOptions reqOptions = new RequestOptions() - .setMethod(HttpMethod.GET) - .setAbsoluteURI(uri) - .setFollowRedirects(true) - .addHeader(HttpHeaders.ACCEPT.toString(), "application/json, application/schema+json"); - - options.getAuthHeaders().forEach(reqOptions::addHeader); - - return client.request(reqOptions) - .compose(req -> req.send() - .compose(resp -> { - int statusCode = resp.statusCode(); - if (statusCode < 200 || statusCode > 299) { - return Future.failedFuture(new IllegalStateException("Wrong status " + statusCode + " " + resp.statusMessage() + " received while resolving remote ref")); - } else { - return resp - .body() - .map(Buffer::toString); - } - })); - } - - private Future solveLocalRef(final URI ref) { - return fs.readFile(ref.getPath()).map(Buffer::toString); - } - - private Future resolveExternalRef(final JsonPointer pointer, final JsonPointer scope, final SchemaParser schemaParser) { - URI refURI = pointer.getURIWithoutFragment(); - return externalSchemasSolving.computeIfAbsent(refURI, (r) -> { - Stream candidatesURIs; - if (refURI.isAbsolute()) { // $ref uri is absolute, just solve it - candidatesURIs = Stream.of(refURI); - } else { // $ref is relative, so it should resolve all aliases of scope and then relativize - candidatesURIs = Stream.concat( - getScopeParentAliases(scope) - .map(u -> URIUtils.resolvePath(u, refURI.getPath())) - .filter(u -> URIUtils.isRemoteURI(u) || URIUtils.isLocalURI(u)) // Remove aliases not resolvable - .sorted((u1, u2) -> (URIUtils.isLocalURI(u1) && !URIUtils.isLocalURI(u2)) ? 1 : (u1.equals(u2)) ? 0 : -1), // Try to solve local refs before - Stream.of( - getResourceAbsoluteURI(refURI) // Last hope: try to solve from class loader - ) - ); - } - URI uriToSolve = candidatesURIs - .filter(Objects::nonNull) - .findFirst() - .orElse(refURI); // REALLY Last hope: try to solve as is from file system - - return - ((URIUtils.isRemoteURI(uriToSolve)) ? solveRemoteRef(uriToSolve) : solveLocalRef(uriToSolve)) - .map(s -> { - Object root = Json.decodeValue(s.trim()); - this.rootJsons.put(uriToSolve, root); - Object realSchema = pointer.queryJson(root); - ((SchemaParserInternal) schemaParser).parse( - realSchema, - JsonPointer.fromURI(URIUtils.replaceFragment(uriToSolve, pointer.toString())) - ); - return resolveCachedSchema(pointer, scope, schemaParser); - }); - }); - } - - private URI getResourceAbsoluteURI(URI source) { - String path = source.getPath(); - File resolved = ((VertxInternal) vertx).resolveFile(path); - URI uri = null; - if (resolved != null) { - if (resolved.exists()) { - try { - resolved = resolved.getCanonicalFile(); - uri = new URI("file://" + slashify(resolved.getPath(), resolved.isDirectory())); - } catch (URISyntaxException | IOException e) { - throw new RuntimeException(e); - } - } - } - - return uri; - } - - private static String slashify(String path, boolean isDirectory) { - String p = path; - if (File.separatorChar != '/') - p = p.replace(File.separatorChar, '/'); - if (!p.startsWith("/")) - p = "/" + p; - if (!p.endsWith("/") && isDirectory) - p = p + "/"; - return p; - } - - public void insertSchema(JsonPointer pointer, RouterNode initialNode, Schema schema) { - if (pointer.isRootPointer()) - initialNode.setSchema((SchemaInternal) schema); - else - pointer.write( - initialNode, - RouterNodeJsonPointerIterator.INSTANCE, - schema, - true - ); - } - - public void insertRouterNode(JsonPointer pointer, RouterNode nodeToWrite) { - if (pointer.isRootPointer()) - absolutePaths.put(pointer.getURIWithoutFragment(), nodeToWrite); - else - pointer.write( - absolutePaths.computeIfAbsent(pointer.getURIWithoutFragment(), k -> new RouterNode()), - RouterNodeJsonPointerIterator.INSTANCE, - nodeToWrite, - true - ); - } -} diff --git a/src/main/java/io/vertx/json/schema/common/SetUtils.java b/src/main/java/io/vertx/json/schema/common/SetUtils.java deleted file mode 100644 index 123dfac3..00000000 --- a/src/main/java/io/vertx/json/schema/common/SetUtils.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class SetUtils { - - /** - * Returns the difference between initial and the operands - */ - public static Set minus(Set initial, Set subtracted) { - initial = new HashSet<>(initial); - initial.removeAll(subtracted); - return Collections.unmodifiableSet(initial); - } - - public static Set minus(Set initial, T subtracted) { - initial = new HashSet<>(initial); - initial.remove(subtracted); - return Collections.unmodifiableSet(initial); - } - - public static Set plus(Set initial, Set addend) { - initial = new HashSet<>(initial); - initial.addAll(addend); - return Collections.unmodifiableSet(initial); - } - - public static Set plus(Set initial, T addend) { - initial = new HashSet<>(initial); - initial.add(addend); - return Collections.unmodifiableSet(initial); - } - - public static Set range(int startInclusive, int endExclusive) { - return IntStream - .range(startInclusive, endExclusive) - .boxed() - .collect(Collectors.toSet()); - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/SyncValidator.java b/src/main/java/io/vertx/json/schema/common/SyncValidator.java deleted file mode 100644 index 85e887e2..00000000 --- a/src/main/java/io/vertx/json/schema/common/SyncValidator.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -public interface SyncValidator extends Validator { - - /** - * Validate the provided value - * - * @param context - * @param in - * @throws ValidationException if the object is not valid - * @throws NoSyncValidationException if no sync validation can be provided - */ - void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException; - -} diff --git a/src/main/java/io/vertx/json/schema/common/TrueSchema.java b/src/main/java/io/vertx/json/schema/common/TrueSchema.java deleted file mode 100644 index ef1b0588..00000000 --- a/src/main/java/io/vertx/json/schema/common/TrueSchema.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Future; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.ValidationException; - -public class TrueSchema implements SchemaInternal { - - private static class TrueSchemaHolder { - static final TrueSchema INSTANCE = new TrueSchema(null); - } - - public static TrueSchema getInstance() { - return TrueSchemaHolder.INSTANCE; - } - - final MutableStateValidator parent; - - public TrueSchema(MutableStateValidator parent) { - this.parent = parent; - } - - @Override - public boolean isSync() { - return true; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.MAX_PRIORITY; - } - - @Override - public void validateSync(Object in) throws ValidationException, NoSyncValidationException { - } - - @Override - public Future validateAsync(Object in) { - return Future.succeededFuture(); - } - - @Override - public Future validateAsync(ValidatorContext context, Object in) { - return this.validateAsync(in); - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - this.validateSync(in); - } - - @Override - public JsonPointer getScope() { - return JsonPointer.create(); - } - - @Override - public Boolean getJson() { - return true; - } - - @Override - public Future getOrApplyDefaultAsync(Object input) { - return Future.succeededFuture(input); - } - - @Override - public Object getOrApplyDefaultSync(Object input) { - return input; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/URIUtils.java b/src/main/java/io/vertx/json/schema/common/URIUtils.java deleted file mode 100644 index 459b0870..00000000 --- a/src/main/java/io/vertx/json/schema/common/URIUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.pointer.JsonPointer; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Objects; - -public class URIUtils { - - public static URI removeFragment(URI oldURI) { - return URIUtils.replaceFragment(oldURI, null); - } - - public static URI replaceFragment(URI oldURI, String fragment) { - try { - if (oldURI != null) { - return new URI(oldURI.getScheme(), oldURI.getSchemeSpecificPart(), fragment); - } else return new URI(null, null, fragment); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e); - } - } - - public static boolean isRemoteURI(URI uri) { - return "http".equals(uri.getScheme()) || "https".equals(uri.getScheme()); - } - - public static boolean isLocalURI(URI uri) { - return "file".equals(uri.getScheme()); - } - - public static URI resolvePath(URI oldURI, String path) { - if (path.isEmpty()) { - return oldURI; - } else { - return oldURI.resolve(path); - } - } - - /** - * This function converts eventual "#a" to valid json pointer "#/a" - * - * @param original - * @return - */ - public static JsonPointer createJsonPointerFromURI(URI original) { - String frag = original.getFragment(); - if (frag != null && !frag.isEmpty()) { - if (frag.charAt(0) != '/') frag = "/" + frag; - } - return JsonPointer.fromURI(replaceFragment(original, frag)); - } - - public static URI requireAbsoluteUri(URI uri) { - Objects.requireNonNull(uri); - if (!uri.isAbsolute()) { - throw new IllegalArgumentException("Provided uri should be absolute. Actual: " + uri.toString()); - } - return uri; - } - - public static URI requireAbsoluteUri(URI uri, String name) { - Objects.requireNonNull(uri); - if (!uri.isAbsolute()) { - throw new IllegalArgumentException("Provided " + name + " uri should be absolute. Actual: " + uri.toString()); - } - return uri; - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/UniqueItemsValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/UniqueItemsValidatorFactory.java deleted file mode 100644 index a8c87ba9..00000000 --- a/src/main/java/io/vertx/json/schema/common/UniqueItemsValidatorFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; - -import java.util.HashSet; -import java.util.List; - -import static io.vertx.json.schema.ValidationException.create; -import static io.vertx.json.schema.common.JsonUtil.unwrap; - -public class UniqueItemsValidatorFactory implements ValidatorFactory { - - private final static BaseSyncValidator UNIQUE_VALIDATOR = new BaseSyncValidator() { - @Override - public void validateSync(ValidatorContext context, final Object in) throws ValidationException, NoSyncValidationException { - Object o = unwrap(in); - if (o instanceof List) { - List arr = (List) o; - if (new HashSet<>(arr).size() != arr.size()) - throw create("array elements must be unique", "uniqueItems", in); - } - } - }; - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator validator) { - try { - Boolean unique = (Boolean) schema.getValue("uniqueItems"); - if (unique) return UNIQUE_VALIDATOR; - else return null; - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for uniqueItems keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null uniqueItems keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("uniqueItems"); - } - -} diff --git a/src/main/java/io/vertx/json/schema/common/ValidationExceptionImpl.java b/src/main/java/io/vertx/json/schema/common/ValidationExceptionImpl.java index 46a08ede..76b0bc04 100644 --- a/src/main/java/io/vertx/json/schema/common/ValidationExceptionImpl.java +++ b/src/main/java/io/vertx/json/schema/common/ValidationExceptionImpl.java @@ -1,7 +1,6 @@ package io.vertx.json.schema.common; import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.Schema; import io.vertx.json.schema.ValidationException; import java.util.Collection; @@ -22,10 +21,6 @@ public ValidationExceptionImpl(String message, Collection causes, Str super(message + ". Multiple causes: " + formatExceptions(causes), keyword, input); } - public void setSchema(Schema schema) { - this.schema = schema; - } - public void setInputScope(JsonPointer scope) { this.inputScope = scope; } diff --git a/src/main/java/io/vertx/json/schema/common/Validator.java b/src/main/java/io/vertx/json/schema/common/Validator.java deleted file mode 100644 index 696dcdb9..00000000 --- a/src/main/java/io/vertx/json/schema/common/Validator.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -public interface Validator extends PriorityGetter { - - /** - * Returns true if this validator can actually provide a synchronous validation - * - * @return - */ - boolean isSync(); - -} diff --git a/src/main/java/io/vertx/json/schema/common/ValidatorContext.java b/src/main/java/io/vertx/json/schema/common/ValidatorContext.java deleted file mode 100644 index d1c7abb1..00000000 --- a/src/main/java/io/vertx/json/schema/common/ValidatorContext.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import java.util.Set; - -/** - * Validator context is an interface used to process contextual keywords (like unevaluatedProperties, unevaluatedItems) and trace the execution - */ -public interface ValidatorContext { - - void markEvaluatedItem(int index); - - void markEvaluatedProperty(String propertyName); - - Set evaluatedItems(); - - Set evaluatedProperties(); - - ValidatorContext startRecording(); - - ValidatorContext lowerLevelContext(String key); - - ValidatorContext lowerLevelContext(int key); - - ValidatorContext parent(); - - String inputKey(); - -} diff --git a/src/main/java/io/vertx/json/schema/common/ValidatorFactory.java b/src/main/java/io/vertx/json/schema/common/ValidatorFactory.java deleted file mode 100644 index b8be9d53..00000000 --- a/src/main/java/io/vertx/json/schema/common/ValidatorFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; - -/** - * Factory for {@link Validator}. This is the entrypoint if you want to create a new custom keyword - */ -public interface ValidatorFactory { - /** - * This method consume the schema eventually creating a new {@link Validator}. The schema parser calls it during schema parsing only if {@link #canConsumeSchema(JsonObject)} returns true
- *

- * You can return any of {@link SyncValidator}, {@link AsyncValidator} or {@link MutableStateValidator} - * - * @param schema JsonObject representing the schema - * @param scope scope of the parsed schema - * @param parser caller parser - * @param parent parent of this schema - * @return the created validator. - * @throws SchemaException if the keyword(s) handled by this ValidatorFactory are invalid - */ - Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) throws SchemaException; - - /** - * Returns true if this factory can consume the provided schema, eventually returning an instance of {@link Validator} - * - * @param schema - * @return - */ - boolean canConsumeSchema(JsonObject schema); -} diff --git a/src/main/java/io/vertx/json/schema/common/ValidatorPriority.java b/src/main/java/io/vertx/json/schema/common/ValidatorPriority.java deleted file mode 100644 index 3a9a7c6c..00000000 --- a/src/main/java/io/vertx/json/schema/common/ValidatorPriority.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.codegen.annotations.VertxGen; - -import java.util.Comparator; - -@VertxGen -public enum ValidatorPriority { - MAX_PRIORITY(0), - NORMAL_PRIORITY(2), - CONTEXTUAL_VALIDATOR(Integer.MAX_VALUE); - - private final Integer priority; - - ValidatorPriority(Integer value) { - this.priority = value; - } - - public static final Comparator COMPARATOR = (v1, v2) -> { - int res = v1.getPriority().priority.compareTo(v2.getPriority().priority); - if (res == 0) return (v1.equals(v2)) ? 0 : +1; // Comparator need to be consistent with equals generic - else return res; - }; - -} diff --git a/src/main/java/io/vertx/json/schema/common/dsl/SchemaBuilder.java b/src/main/java/io/vertx/json/schema/common/dsl/SchemaBuilder.java index 738a057f..d55ff74b 100644 --- a/src/main/java/io/vertx/json/schema/common/dsl/SchemaBuilder.java +++ b/src/main/java/io/vertx/json/schema/common/dsl/SchemaBuilder.java @@ -14,8 +14,6 @@ import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaParser; import io.vertx.json.schema.common.SchemaURNId; import java.net.URI; @@ -115,13 +113,4 @@ public JsonObject toJson() { res.put("$id", id.toString()); return res; } - - /** - * @deprecated This method creates an hard link to the parser which we want to avoid - */ - @Deprecated - public final Schema build(SchemaParser parser) { - return parser.parse(toJson(), JsonPointer.fromURI(id)); - } - } diff --git a/src/main/java/io/vertx/json/schema/impl/JsonRef.java b/src/main/java/io/vertx/json/schema/impl/JsonRef.java index a884c02b..939d52c7 100644 --- a/src/main/java/io/vertx/json/schema/impl/JsonRef.java +++ b/src/main/java/io/vertx/json/schema/impl/JsonRef.java @@ -73,7 +73,7 @@ public final class JsonRef { private JsonRef(String ref, JsonObject obj, String prop, String path, String id) { this.ref = ref; this.obj = obj; - this.prop = prop; + this.prop = prop; // What's the use of prop? It's never used. this.path = path; this.id = id; } diff --git a/src/main/java/io/vertx/json/schema/openapi3/FormatValidatorFactory.java b/src/main/java/io/vertx/json/schema/openapi3/FormatValidatorFactory.java deleted file mode 100644 index d8f59af1..00000000 --- a/src/main/java/io/vertx/json/schema/openapi3/FormatValidatorFactory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.openapi3; - -import io.vertx.json.schema.common.BaseFormatValidatorFactory; -import io.vertx.json.schema.common.RegularExpressions; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; - -public class FormatValidatorFactory extends BaseFormatValidatorFactory { - - @Override - protected List initIgnoringFormats() { - List formats = new ArrayList<>(super.initIgnoringFormats()); - formats.add("password"); - return formats; - } - - @Override - public Map> initFormatsMap() { - Map> predicates = new HashMap<>(); - predicates.put("byte", createPredicateFromPattern(RegularExpressions.BASE64)); - predicates.put("date", createPredicateFromPattern(RegularExpressions.DATE)); - predicates.put("date-time", createPredicateFromPattern(RegularExpressions.DATETIME)); - predicates.put("ipv4", createPredicateFromPattern(RegularExpressions.IPV4)); - predicates.put("ipv6", createPredicateFromPattern(RegularExpressions.IPV6)); - predicates.put("hostname", createPredicateFromPattern(RegularExpressions.HOSTNAME)); - predicates.put("email", createPredicateFromPattern(RegularExpressions.EMAIL)); - predicates.put("uri", URI_VALIDATOR); - predicates.put("uriref", URI_REFERENCE_VALIDATOR); - predicates.put("uuid", UUID_VALIDATOR); - return predicates; - } -} diff --git a/src/main/java/io/vertx/json/schema/openapi3/MaximumValidatorFactory.java b/src/main/java/io/vertx/json/schema/openapi3/MaximumValidatorFactory.java deleted file mode 100644 index f3a34b89..00000000 --- a/src/main/java/io/vertx/json/schema/openapi3/MaximumValidatorFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.openapi3; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.common.*; - -public class MaximumValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number maximum = (Number) schema.getValue("maximum"); - if (schema.containsKey("exclusiveMaximum") && schema.getBoolean("exclusiveMaximum")) - return new ExclusiveMaximumValidator(maximum.doubleValue()); - return new MaximumValidator(maximum.doubleValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for maximum or exclusiveMaximum keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null maximum or exclusiveMaximum keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("maximum"); - } - -} diff --git a/src/main/java/io/vertx/json/schema/openapi3/MinimumValidatorFactory.java b/src/main/java/io/vertx/json/schema/openapi3/MinimumValidatorFactory.java deleted file mode 100644 index f7c0f2ee..00000000 --- a/src/main/java/io/vertx/json/schema/openapi3/MinimumValidatorFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.openapi3; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.common.*; - -public class MinimumValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Number maximum = (Number) schema.getValue("minimum"); - if (schema.containsKey("exclusiveMinimum") && schema.getBoolean("exclusiveMinimum")) - return new ExclusiveMinimumValidator(maximum.doubleValue()); - return new MinimumValidator(maximum.doubleValue()); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for minimum or exclusiveMinimum keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null minimum or exclusiveMinimum keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("minimum"); - } - -} diff --git a/src/main/java/io/vertx/json/schema/openapi3/NullableValidatorFactory.java b/src/main/java/io/vertx/json/schema/openapi3/NullableValidatorFactory.java deleted file mode 100644 index 00d8f7e9..00000000 --- a/src/main/java/io/vertx/json/schema/openapi3/NullableValidatorFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.openapi3; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.NoSyncValidationException; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; -import io.vertx.json.schema.common.*; - -public class NullableValidatorFactory implements ValidatorFactory { - - private final static BaseSyncValidator NULL_VALIDATOR = new BaseSyncValidator() { - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException, NoSyncValidationException { - if (in == null) throw ValidationException.create("input cannot be null", "nullable", null); - } - }; - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - Boolean nullable = (Boolean) schema.getValue("nullable"); - if (nullable == null || !nullable) return NULL_VALIDATOR; - else return null; - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for nullable keyword", e); - } catch (NullPointerException e) { - throw new SchemaException(schema, "Null nullable keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return !schema.containsKey("$ref"); - } - -} diff --git a/src/main/java/io/vertx/json/schema/openapi3/OpenAPI3SchemaParser.java b/src/main/java/io/vertx/json/schema/openapi3/OpenAPI3SchemaParser.java deleted file mode 100644 index f9099073..00000000 --- a/src/main/java/io/vertx/json/schema/openapi3/OpenAPI3SchemaParser.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.openapi3; - -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.SchemaRouter; -import io.vertx.json.schema.SchemaRouterOptions; -import io.vertx.json.schema.common.*; - -import java.net.URI; -import java.util.LinkedList; -import java.util.List; - -@Deprecated -public class OpenAPI3SchemaParser extends BaseSchemaParser { - - protected OpenAPI3SchemaParser(SchemaRouter router) { - super(router); - } - - @Override - protected List initValidatorFactories() { - List factories = new LinkedList<>(); - factories.add(new DefinitionsValidatorFactory("definitions")); - factories.add(new FormatValidatorFactory()); - factories.add(new MaximumValidatorFactory()); - factories.add(new MinimumValidatorFactory()); - factories.add(new NullableValidatorFactory()); - factories.add(new TypeValidatorFactory()); - factories.add(new AllOfValidatorFactory()); - factories.add(new AnyOfValidatorFactory()); - factories.add(new EnumValidatorFactory()); - factories.add(new ItemsValidatorFactory()); - factories.add(new MaxItemsValidatorFactory()); - factories.add(new MaxLengthValidatorFactory()); - factories.add(new MaxPropertiesValidatorFactory()); - factories.add(new MinItemsValidatorFactory()); - factories.add(new MinLengthValidatorFactory()); - factories.add(new MinPropertiesValidatorFactory()); - factories.add(new MultipleOfValidatorFactory()); - factories.add(new NotValidatorFactory()); - factories.add(new OneOfValidatorFactory()); - factories.add(new PatternValidatorFactory()); - factories.add(new PropertiesValidatorFactory()); - factories.add(new RequiredValidatorFactory()); - factories.add(new UniqueItemsValidatorFactory()); - return factories; - } - - /** - * Instantiate an OpenAPI3SchemaParser - * - * @param router router to associate to read $ref - * @return a new instance of OpenAPI3SchemaParser - */ - public static OpenAPI3SchemaParser create(SchemaRouter router) { - return new OpenAPI3SchemaParser(router); - } - - /** - * Parse an OpenAPI 3 schema - * - * @param vertx this vertx instance - * @param schema parsed json schema - * @param scope scope of json schema - * @return a new instance of Draft7SchemaParser - * @throws SchemaException if schema is invalid - */ - public static Schema parse(Vertx vertx, JsonObject schema, URI scope) { - return new OpenAPI3SchemaParser(SchemaRouter.create(vertx, new SchemaRouterOptions())).parse(schema, scope, null); - } -} diff --git a/src/main/java/io/vertx/json/schema/openapi3/TypeValidatorFactory.java b/src/main/java/io/vertx/json/schema/openapi3/TypeValidatorFactory.java deleted file mode 100644 index 25af883f..00000000 --- a/src/main/java/io/vertx/json/schema/openapi3/TypeValidatorFactory.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.openapi3; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaException; -import io.vertx.json.schema.ValidationException; -import io.vertx.json.schema.common.*; - -public class TypeValidatorFactory implements ValidatorFactory { - - @Override - public Validator createValidator(JsonObject schema, JsonPointer scope, SchemaParserInternal parser, MutableStateValidator parent) { - try { - String type = schema.getString("type"); - String format = schema.getString("format"); - if (type == null) throw new SchemaException(schema, "Null type keyword"); - return new TypeValidator(parseType(type, format, schema)); - } catch (ClassCastException e) { - throw new SchemaException(schema, "Wrong type for type/format/nullable keyword", e); - } - } - - @Override - public boolean canConsumeSchema(JsonObject schema) { - return schema.containsKey("type"); - } - - private static JsonSchemaType parseType(String type, String format, JsonObject schema) { - switch (type) { - case "integer": - return JsonSchemaType.INTEGER; - case "number": - return (format != null && (format.equals("double") || format.equals("float"))) ? JsonSchemaType.NUMBER_DECIMAL : JsonSchemaType.NUMBER; - case "boolean": - return JsonSchemaType.BOOLEAN; - case "string": - return JsonSchemaType.STRING; - case "object": - return JsonSchemaType.OBJECT; - case "array": - return JsonSchemaType.ARRAY; - default: - throw new SchemaException(schema, "Unknown type: " + type); - } - } - - static class TypeValidator extends BaseSyncValidator { - - final JsonSchemaType type; - - public TypeValidator(JsonSchemaType type) { - this.type = type; - } - - @Override - public ValidatorPriority getPriority() { - return ValidatorPriority.MAX_PRIORITY; - } - - @Override - public void validateSync(ValidatorContext context, Object in) throws ValidationException { - if (in != null) { - if (!type.checkInstance(in)) - throw ValidationException.create("input don't match type " + type.name(), "type", in); - } - } - } -} diff --git a/src/test/java/io/vertx/json/schema/BaseIntegrationTest.java b/src/test/java/io/vertx/json/schema/BaseIntegrationTest.java deleted file mode 100644 index 42321212..00000000 --- a/src/test/java/io/vertx/json/schema/BaseIntegrationTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Future; -import io.vertx.core.Handler; -import io.vertx.core.Vertx; -import io.vertx.core.http.HttpServer; -import io.vertx.core.http.HttpServerOptions; -import io.vertx.core.impl.logging.Logger; -import io.vertx.core.impl.logging.LoggerFactory; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.json.schema.common.SchemaParserInternal; -import io.vertx.json.schema.common.SchemaRouterImpl; -import io.vertx.junit5.Timeout; -import io.vertx.junit5.VertxExtension; -import io.vertx.junit5.VertxTestContext; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.AbstractMap; -import java.util.AbstractMap.SimpleImmutableEntry; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.params.provider.Arguments.arguments; - -/** - * @author Francesco Guardiani @slinkydeveloper - */ -@ExtendWith(VertxExtension.class) -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public abstract class BaseIntegrationTest { - - public static final Logger log = LoggerFactory.getLogger(BaseIntegrationTest.class); - public static final int SCHEMA_SERVER_PORT = 1234; - - private HttpServer schemaServer; - - private void startSchemaServer(Vertx vertx, Handler> completion) { - schemaServer = vertx.createHttpServer(new HttpServerOptions().setPort(SCHEMA_SERVER_PORT)) - .requestHandler(req -> { - String path = req.path().split(Pattern.quote("#"))[0]; - req.response() - .putHeader("Content-type", "application/json") - .sendFile(Paths.get(getRemotesPath().toString(), path).toString()); - }); - schemaServer.listen().onComplete(l -> completion.handle(Future.succeededFuture())); - } - - private void stopSchemaServer(Handler> completion) { - try { - schemaServer.close().onComplete((asyncResult) -> { - completion.handle(Future.succeededFuture()); - }); - } catch (IllegalStateException e) { // Server is already open - completion.handle(Future.succeededFuture()); - } - } - - @BeforeAll - public void setUp(Vertx vertx, VertxTestContext testContext) { - if (getRemotesPath() != null) { - startSchemaServer(vertx, testContext.succeedingThenComplete()); - } else { - testContext.completeNow(); - } - } - - @AfterAll - public void tearDown(VertxTestContext testContext) { - if (schemaServer != null) { - stopSchemaServer(testContext.succeedingThenComplete()); - } else { - testContext.completeNow(); - } - } - - private Map.Entry buildSchema(Vertx vertx, Object schema, String testName, String testFileName) { - try { - return buildSchemaFunction(vertx, schema, testFileName); - } catch (Exception e) { - fail("Something went wrong during schema initialization for test \"" + testName + "\"", e); - return null; - } - } - - @Timeout(value = 10, timeUnit = TimeUnit.SECONDS) - @ParameterizedTest(name = "{0}") - @MethodSource("buildParameters") - public void test(String testName, String testFileName, JsonObject testObj, Vertx vertx, VertxTestContext context) { - Map.Entry t = buildSchema(vertx, testObj.getValue("schema"), testName, testFileName); - for (Object tc : testObj.getJsonArray("tests").stream().collect(Collectors.toList())) { - JsonObject testCase = (JsonObject) tc; - if (testCase.getBoolean("valid")) - validateSuccess(t.getValue(), t.getKey(), testCase.getValue("data"), testName, testCase.getString("description"), context); - else - validateFailure(t.getValue(), t.getKey(), testCase.getValue("data"), testName, testCase.getString("description"), context); - } - } - - private void validateSuccess(Schema schema, SchemaParser parser, Object obj, String testName, String testCaseName, VertxTestContext context) { - schema.validateAsync(obj).onComplete(event -> { - if (event.failed()) - context.verify(() -> fail(String.format("\"%s\" -> \"%s\" should be valid", testName, testCaseName), event.cause())); - - if (skipSyncCheck(schema)) { - context.completeNow(); - return; - } - - ((SchemaRouterImpl) parser.getSchemaRouter()).resolveAllSchemas().onComplete(ar -> { - context.verify(() -> { - if (ar.failed()) { - fail("Failed schema refs resolving with cause", ar.cause()); - } - assertThat(schema.isSync()) - .as("Schema is sync") - .isTrue(); - assertThatCode(() -> schema.validateSync(obj)) - .as("\"%s\" -> \"%s\" should be valid", testName, testCaseName) - .doesNotThrowAnyException(); - }); - context.completeNow(); - }); - }); - } - - private void validateFailure(Schema schema, SchemaParser parser, Object obj, String testName, String testCaseName, VertxTestContext context) { - schema.validateAsync(obj).onComplete(event -> { - if (event.succeeded()) - context.verify(() -> fail(String.format("\"%s\" -> \"%s\" should be invalid", testName, testCaseName))); - else if (log.isDebugEnabled()) - log.debug(event.cause().toString()); - - if (skipSyncCheck(schema)) { - context.completeNow(); - return; - } - - ((SchemaRouterImpl) parser.getSchemaRouter()).resolveAllSchemas().onComplete(ar -> { - context.verify(() -> { - if (ar.failed()) { - fail("Failed schema refs resolving with cause", ar.cause()); - } - assertThat(schema.isSync()) - .as("Schema is sync") - .isTrue(); - assertThatExceptionOfType(ValidationException.class) - .isThrownBy(() -> schema.validateSync(obj)) - .as("\"%s\" -> \"%s\" should be invalid", testName, testCaseName); - }); - context.completeNow(); - }); - }); - } - - public Stream buildParameters() { - return getTestFiles() - .map(f -> new SimpleImmutableEntry<>(f, getTckPath().resolve(f + ".json"))) - .map(p -> { - try { - return new SimpleImmutableEntry<>(p.getKey(), String.join("", Files.readAllLines(p.getValue(), StandardCharsets.UTF_8))); - } catch (IOException e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - }) - .map(string -> new SimpleImmutableEntry<>(string.getKey(), new JsonArray(string.getValue()))) - .flatMap(t -> t.getValue() - .stream() - .map(JsonObject.class::cast) - .map(o -> arguments(t.getKey() + ": " + o.getString("description"), t.getKey(), o)) - ); - } - - public abstract Stream getTestFiles(); - - public abstract SchemaParserInternal getSchemaParser(Vertx vertx); - - protected Map.Entry buildSchemaFunction(Vertx vertx, Object schema, String testFileName) throws URISyntaxException { - SchemaParserInternal parser = getSchemaParser(vertx); - Schema s = parser.parse(schema, Paths.get(this.getTckPath() + "/" + testFileName + ".json").toAbsolutePath().toUri()); - return new AbstractMap.SimpleImmutableEntry<>(parser, s); - } - - ; - - public abstract Path getTckPath(); - - public abstract Path getRemotesPath(); - - public boolean skipSyncCheck(Schema schema) { - return false; - } -} diff --git a/src/test/java/io/vertx/json/schema/asserts/JsonAssert.java b/src/test/java/io/vertx/json/schema/asserts/JsonAssert.java deleted file mode 100644 index b8db94f2..00000000 --- a/src/test/java/io/vertx/json/schema/asserts/JsonAssert.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.asserts; - -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import org.assertj.core.api.AbstractAssert; - -import java.util.Map; -import java.util.function.Consumer; - -import static org.assertj.core.api.Assertions.assertThat; - -public class JsonAssert extends AbstractAssert { - public JsonAssert(Object actual) { - super(actual, JsonAssert.class); - } - - public JsonAssert extracting(JsonPointer pointer) { - return new JsonAssert(pointer.queryJson(actual)); - } - - public JsonAssert extractingKey(String keyName) { - isJsonObject(); - return new JsonAssert(((JsonObject) actual).getValue(keyName)); - } - - public JsonAssert removingEntry(String keyName) { - containsKey(keyName); - - JsonObject jo = ((JsonObject) actual).copy(); - jo.remove(keyName); - - return new JsonAssert(jo); - } - - public JsonAssert isJsonObject() { - assertThat(actual).isInstanceOf(JsonObject.class); - return this; - } - - public JsonAssert isJsonArray() { - assertThat(actual).isInstanceOf(JsonArray.class); - return this; - } - - public JsonAssert containsEntry(String keyword, Object value) { - isJsonObject(); - - JsonObject jo = (JsonObject) actual; - assertThat(jo.getValue(keyword)).isEqualTo(value); - - return this; - } - - public JsonAssert containsEntrySatisfying(String keyword, Consumer requirement) { - isJsonObject(); - - JsonObject jo = (JsonObject) actual; - assertThat(jo.getValue(keyword)).satisfies(requirement); - - return this; - } - - public JsonAssert containsKey(String keyword) { - isJsonObject(); - - JsonObject jo = (JsonObject) actual; - assertThat(jo.containsKey(keyword)).isTrue(); - - return this; - } - - public JsonAssert containsItem(Object value) { - isJsonArray(); - - JsonArray ja = (JsonArray) actual; - - assertThat(ja.contains(value)).isTrue(); - - return this; - - } - - public JsonAssert containsItemSatisfying(Consumer requirement) { - isJsonArray(); - - JsonArray ja = (JsonArray) actual; - - boolean found = false; - for (Object obj : ja) { - try { - requirement.accept(obj); - found = true; - } catch (AssertionError a) { - } - } - - if (!found) failWithMessage("Cannot find an element in the array satisfying the requirement"); - - return this; - - } - - @SuppressWarnings("unchecked") - public JsonAssert containsAllAndOnlyEntries(Map.Entry... entries) { - isJsonObject(); - - JsonObject jo = (JsonObject) actual; - assertThat(jo.size()).isEqualTo(entries.length); - for (Map.Entry e : entries) { - assertThat(jo.getValue(e.getKey())).isEqualTo(e.getValue()); - } - - return this; - } - - public JsonAssert containsAllAndOnlyItems(Object... items) { - isJsonArray(); - - JsonArray ja = (JsonArray) actual; - assertThat(ja.size()).isEqualTo(items.length); - for (Object i : items) { - assertThat(ja.contains(i)).isTrue(); - } - - return this; - } - -} diff --git a/src/test/java/io/vertx/json/schema/asserts/MyAssertions.java b/src/test/java/io/vertx/json/schema/asserts/MyAssertions.java deleted file mode 100644 index a0612543..00000000 --- a/src/test/java/io/vertx/json/schema/asserts/MyAssertions.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.asserts; - -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaRouter; - -public class MyAssertions { - - public static SchemaAssert assertThat(Schema actual) { - return new SchemaAssert(actual); - } - - public static SchemaRouterAssert assertThat(SchemaRouter actual) { - return new SchemaRouterAssert(actual); - } - - public static JsonAssert assertThat(JsonObject actual) { - return new JsonAssert(actual); - } - - public static JsonAssert assertThat(JsonArray actual) { - return new JsonAssert(actual); - } - - public static JsonAssert assertThatJson(Object actual) { - return new JsonAssert(actual); - } - -} diff --git a/src/test/java/io/vertx/json/schema/asserts/SchemaAssert.java b/src/test/java/io/vertx/json/schema/asserts/SchemaAssert.java deleted file mode 100644 index 080f86fd..00000000 --- a/src/test/java/io/vertx/json/schema/asserts/SchemaAssert.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.asserts; - -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.ValidationException; -import io.vertx.json.schema.common.SchemaImpl; -import org.assertj.core.api.AbstractAssert; -import org.assertj.core.api.AbstractThrowableAssert; -import org.assertj.core.api.StringAssert; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicReference; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -public class SchemaAssert extends AbstractAssert { - - public SchemaAssert(Schema actual) { - super(actual, SchemaAssert.class); - } - - public StringAssert hasXId() { - isNotNull(); - - if (!(actual instanceof SchemaImpl)) - failWithMessage("Schema <%s> must be a SchemaImpl instance", actual.toString()); - - return new StringAssert(((SchemaImpl) actual).getJson().getString("x-id")); - } - - public SchemaAssert hasXIdEqualsTo(String expectedXId) { - hasXId().isEqualTo(expectedXId); - return this; - } - - public SchemaAssert isSync() { - assertThat(actual.isSync()).isTrue(); - return this; - } - - public SchemaAssert isAsync() { - assertThat(actual.isSync()).isFalse(); - return this; - } - - public SchemaAssert validateAsyncSuccess(Object in) { - CountDownLatch latch = new CountDownLatch(1); - AtomicReference ex = new AtomicReference<>(); - actual.validateAsync(in).onComplete(ar -> { - ex.set(ar.cause()); - latch.countDown(); - }); - try { - latch.await(); - } catch (InterruptedException e) { - fail("Failure while waiting for schema to validate", e); - } - assertThat(ex.get()) - .isNull(); - return this; - } - - public AbstractThrowableAssert validateAsyncFailure(Object in) { - CountDownLatch latch = new CountDownLatch(1); - AtomicReference ex = new AtomicReference<>(); - actual.validateAsync(in).onComplete(ar -> { - ex.set(ar.cause()); - latch.countDown(); - }); - try { - latch.await(); - } catch (InterruptedException e) { - fail("Failure while waiting for schema to validate", e); - } - assertThat(ex.get()) - .withFailMessage("Expecting schema to validate with a failure") - .isNotNull(); - return (AbstractThrowableAssert) assertThat((ValidationException) ex.get()); - } - -} diff --git a/src/test/java/io/vertx/json/schema/asserts/SchemaRouterAssert.java b/src/test/java/io/vertx/json/schema/asserts/SchemaRouterAssert.java deleted file mode 100644 index 3e9606e8..00000000 --- a/src/test/java/io/vertx/json/schema/asserts/SchemaRouterAssert.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.asserts; - -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaParser; -import io.vertx.json.schema.SchemaRouter; -import io.vertx.json.schema.common.SchemaImpl; -import io.vertx.json.schema.common.URIUtils; -import org.assertj.core.api.AbstractAssert; -import org.assertj.core.api.Condition; - -import java.net.URI; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -public class SchemaRouterAssert extends AbstractAssert { - - public SchemaRouterAssert(SchemaRouter actual) { - super(actual, SchemaRouterAssert.class); - } - - public SchemaAssert canResolveSchema(String uri, JsonPointer scope, SchemaParser parser) { - return canResolveSchema(URIUtils.createJsonPointerFromURI(URI.create(uri)), scope, parser); - } - - public SchemaAssert canResolveSchema(JsonPointer jp, JsonPointer scope, SchemaParser parser) { - isNotNull(); - - try { - Schema s = actual.resolveCachedSchema(jp, scope, parser); - assertThat(s) - .withFailMessage("Cannot resolve schema with pointer '%s' from scope '%s'", jp.toURI(), scope.toURI()) - .isNotNull(); - return new SchemaAssert(actual.resolveCachedSchema(jp, scope, parser)); - } catch (Exception e) { - fail(String.format("Cannot resolve schema with pointer '%s' from scope '%s'", jp.toURI(), scope.toURI()), e); - return new SchemaAssert(null); - } - } - - public SchemaRouterAssert cannotResolveSchema(String uri, JsonPointer scope, SchemaParser parser) { - return cannotResolveSchema(URIUtils.createJsonPointerFromURI(URI.create(uri)), scope, parser); - } - - public SchemaRouterAssert cannotResolveSchema(JsonPointer jp, JsonPointer scope, SchemaParser parser) { - isNotNull(); - assertThat(actual.resolveCachedSchema(jp, scope, parser)).isNull(); - return this; - } - - public SchemaRouterAssert containsOnlyOneCachedSchemaWithXId(String expectedXId) { - isNotNull(); - - assertThat(actual.registeredSchemas()) - .isNotNull(); - - assertThat(actual.registeredSchemas()) - .filteredOn(s -> s instanceof SchemaImpl) - .extracting(s -> ((SchemaImpl) s).getJson()) - .extracting(j -> j.getString("x-id")) - .areExactly(1, new Condition<>(expectedXId::equals, "Expected id {}", expectedXId)); - - - return this; - } - - public SchemaRouterAssert containsCachedSchemasWithXIds(String... expectedXIds) { - for (String id : expectedXIds) { - containsOnlyOneCachedSchemaWithXId(id); - } - - return this; - } - -} diff --git a/src/test/java/io/vertx/json/schema/common/SchemaRouterIdTest.java b/src/test/java/io/vertx/json/schema/common/SchemaRouterIdTest.java deleted file mode 100644 index 683c353d..00000000 --- a/src/test/java/io/vertx/json/schema/common/SchemaRouterIdTest.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.SchemaRouter; -import io.vertx.json.schema.SchemaRouterOptions; -import io.vertx.json.schema.asserts.MyAssertions; -import io.vertx.json.schema.openapi3.OpenAPI3SchemaParser; -import io.vertx.junit5.VertxExtension; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.net.URI; - -import static io.vertx.json.schema.TestUtils.buildBaseUri; -import static io.vertx.json.schema.TestUtils.loadJson; -import static io.vertx.json.schema.common.URIUtils.createJsonPointerFromURI; - -@ExtendWith(VertxExtension.class) -@TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class SchemaRouterIdTest { - - public SchemaParserInternal parser; - public SchemaRouter schemaRouter; - - @BeforeAll - public void setUp(Vertx vertx) { - schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - parser = OpenAPI3SchemaParser.create(schemaRouter); - } - - @Test - public void testNoIdKeyword() throws Exception { - URI baseURI = buildBaseUri("id_test", "no_id_keyword.json"); - JsonPointer basePointer = JsonPointer.fromURI(baseURI); - JsonObject baseSchemaJson = loadJson(baseURI); - parser.parse(baseSchemaJson, baseURI); - - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create(), basePointer, parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create(), basePointer, parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(basePointer, basePointer, parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("allOf").append("0"), basePointer, parser).hasXIdEqualsTo("allOf_0"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("allOf").append("1"), basePointer, parser).hasXIdEqualsTo("allOf_1"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("anyOf").append("0"), basePointer, parser).hasXIdEqualsTo("anyOf_0"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("anyOf").append("1"), basePointer, parser).hasXIdEqualsTo("anyOf_1"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("oneOf").append("0"), basePointer, parser).hasXIdEqualsTo("oneOf_0"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("oneOf").append("1"), basePointer, parser).hasXIdEqualsTo("oneOf_1"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("not"), basePointer, parser).hasXIdEqualsTo("not"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("properties").append("prop_1"), basePointer, parser).hasXIdEqualsTo("prop_1"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("properties").append("prop_2"), basePointer, parser).hasXIdEqualsTo("prop_2"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("patternProperties").append("^a"), basePointer, parser).hasXIdEqualsTo("pattern_prop_1"); - MyAssertions.assertThat(schemaRouter).canResolveSchema(JsonPointer.create().append("additionalProperties"), basePointer, parser).hasXIdEqualsTo("additional_prop"); - } - - @Test - public void testIdURNKeywordFromBaseScope() throws Exception { - URI baseURI = buildBaseUri("id_test", "id_urn_keyword.json"); - JsonPointer basePointer = JsonPointer.fromURI(baseURI); - JsonObject baseSchemaJson = loadJson(baseURI); - parser.parse(baseSchemaJson, baseURI); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(basePointer.copy().append("properties").append("prop_1"), basePointer, parser) - .hasXIdEqualsTo("prop_1"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("urn:uuid:590e34ae-8e3d-4bdf-a748-beff72654d0e", basePointer, parser) - .hasXIdEqualsTo("prop_1"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(basePointer.copy().append("properties").append("prop_2"), basePointer, parser) - .hasXIdEqualsTo("prop_2"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("urn:uuid:77ed19ca-1127-42dd-8194-3e48661ce672", basePointer, parser) - .hasXIdEqualsTo("prop_2"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(basePointer.copy().append("properties").append("prop_2").append("not"), basePointer, parser) - .hasXIdEqualsTo("not"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(createJsonPointerFromURI(URI.create("urn:uuid:77ed19ca-1127-42dd-8194-3e48661ce672")).append("not"), basePointer, parser) - .hasXIdEqualsTo("not"); - } - - @Test - public void testIdURNKeywordFromInnerScope() throws Exception { - URI baseURI = buildBaseUri("id_test", "id_urn_keyword.json"); - JsonObject baseSchemaJson = loadJson(baseURI); - parser.parse(baseSchemaJson, baseURI); - JsonPointer scope = schemaRouter.resolveCachedSchema(createJsonPointerFromURI(URI.create("urn:uuid:77ed19ca-1127-42dd-8194-3e48661ce672")), createJsonPointerFromURI(baseURI), parser).getScope(); - - MyAssertions.assertThat(schemaRouter).canResolveSchema(createJsonPointerFromURI(URI.create("urn:uuid:77ed19ca-1127-42dd-8194-3e48661ce672")).append("not"), scope, parser).hasXIdEqualsTo("not"); - } - - /* - - # (document root) - http://example.com/root.json - http://example.com/root.json# - - #/definitions/A - http://example.com/root.json#foo - http://example.com/root.json#/definitions/A - - #/definitions/B - http://example.com/other.json - http://example.com/other.json# - http://example.com/root.json#/definitions/B - - #/definitions/B/definitions/X - http://example.com/other.json#bar - http://example.com/other.json#/definitions/X - http://example.com/root.json#/definitions/B/definitions/X - - #/definitions/B/definitions/Y - http://example.com/t/inner.json - http://example.com/t/inner.json# - http://example.com/other.json#/definitions/Y - http://example.com/root.json#/definitions/B/definitions/Y - - #/definitions/C - urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f - urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f# - http://example.com/root.json#/definitions/C - */ - - @Test - public void testRFCIDKeywordFromBaseScope() throws Exception { - URI baseURI = buildBaseUri("id_test", "rfc_id_keyword.json"); - JsonPointer basePointer = JsonPointer.fromURI(baseURI); - JsonObject baseSchemaJson = loadJson(baseURI); - parser.parse(baseSchemaJson, baseURI); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create(), basePointer, parser) - .hasXIdEqualsTo("main"); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create().append("properties").append("A"), basePointer, parser) - .hasXIdEqualsTo("A"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("#foo", basePointer, parser) - .hasXIdEqualsTo("A"); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create().append("properties").append("B"), basePointer, parser) - .hasXIdEqualsTo("B"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("http://example.com/other.json", basePointer, parser) - .hasXIdEqualsTo("B"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create(), JsonPointer.fromURI(URI.create("http://example.com/other.json")), parser) - .hasXIdEqualsTo("B"); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create().append("properties").append("B").append("properties").append("X"), basePointer, parser) - .hasXIdEqualsTo("X"); - MyAssertions.assertThat(schemaRouter) - .cannotResolveSchema("#bar", basePointer, parser); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("http://example.com/other.json#bar", basePointer, parser) - .hasXIdEqualsTo("X"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("#bar", JsonPointer.fromURI(URI.create("http://example.com/other.json")), parser) - .hasXIdEqualsTo("X"); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create().append("properties").append("B").append("properties").append("Y"), basePointer, parser) - .hasXIdEqualsTo("Y"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("http://example.com/t/inner.json", basePointer, parser) - .hasXIdEqualsTo("Y"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(createJsonPointerFromURI(URI.create("http://example.com/other.json")).append("properties").append("Y"), basePointer, parser) - .hasXIdEqualsTo("Y"); - - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create().append("properties").append("C"), basePointer, parser) - .hasXIdEqualsTo("C"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(createJsonPointerFromURI(URI.create("http://example.com/root.json")).append("properties").append("C"), basePointer, parser) - .hasXIdEqualsTo("C"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("urn:uuid:ee564b8a-7a87-4125-8c96-e9f123d6766f", basePointer, parser) - .hasXIdEqualsTo("C"); - - } - - @Test - public void testRFCIDKeywordFromInnerScope() throws Exception { - URI baseURI = buildBaseUri("id_test", "rfc_id_keyword.json"); - JsonObject baseSchemaJson = loadJson(baseURI); - parser.parse(baseSchemaJson, baseURI); - JsonPointer scope = JsonPointer.fromURI(URI.create("http://example.com/other.json")); - - MyAssertions.assertThat(schemaRouter) - .cannotResolveSchema("#foo", scope, parser); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("#bar", scope, parser).hasXIdEqualsTo("X"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema(JsonPointer.create().append("properties").append("Y"), scope, parser) - .hasXIdEqualsTo("Y"); - MyAssertions.assertThat(schemaRouter) - .canResolveSchema("t/inner.json", scope, parser) - .hasXIdEqualsTo("Y"); - } - -} diff --git a/src/test/java/io/vertx/json/schema/common/SchemaRouterImplTest.java b/src/test/java/io/vertx/json/schema/common/SchemaRouterImplTest.java deleted file mode 100644 index 2161df23..00000000 --- a/src/test/java/io/vertx/json/schema/common/SchemaRouterImplTest.java +++ /dev/null @@ -1,196 +0,0 @@ -package io.vertx.json.schema.common; - -import io.vertx.core.Vertx; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaParser; -import io.vertx.json.schema.SchemaRouter; -import io.vertx.json.schema.SchemaRouterOptions; -import io.vertx.json.schema.asserts.MyAssertions; -import io.vertx.junit5.VertxExtension; -import io.vertx.junit5.VertxTestContext; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.net.URI; - -import static io.vertx.json.schema.TestUtils.buildBaseUri; -import static io.vertx.json.schema.TestUtils.loadJson; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; - -@ExtendWith(VertxExtension.class) -public class SchemaRouterImplTest { - - @Test - public void resolveCachedSchemaInJsonContainingSchemasWithRelativeRef(Vertx vertx) throws Exception { - final URI baseJsonUri = buildBaseUri("openapi.json"); - SchemaRouter schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - SchemaParser schemaParser = SchemaParser.createOpenAPI3SchemaParser(schemaRouter); - - schemaRouter.addJson(baseJsonUri, loadJson(baseJsonUri)); - - Schema schema = schemaRouter.resolveCachedSchema( - JsonPointer.from("/components/schemas/TrafficLight"), - JsonPointer.fromURI(baseJsonUri), - schemaParser - ); - - MyAssertions.assertThat(schema) - .isNotNull(); - assertThat(schema.getJson()) - .isInstanceOf(JsonObject.class); - - MyAssertions.assertThat((JsonObject) schema.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for TrafficLight"); - } - - @Test - public void resolveCachedSchemaInJsonContainingSchemasWithAbsoluteRef(Vertx vertx) throws Exception { - final URI baseJsonUri = buildBaseUri("openapi.json"); - SchemaRouter schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - SchemaParser schemaParser = SchemaParser.createOpenAPI3SchemaParser(schemaRouter); - - schemaRouter.addJson(baseJsonUri, loadJson(baseJsonUri)); - - Schema schema = schemaRouter.resolveCachedSchema( - JsonPointer.fromURI(URIUtils.replaceFragment(baseJsonUri, "/components/schemas/TrafficLight")), - JsonPointer.create(), - schemaParser - ); - - MyAssertions.assertThat(schema) - .isNotNull(); - assertThat(schema.getJson()) - .isInstanceOf(JsonObject.class); - - MyAssertions.assertThat((JsonObject) schema.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for TrafficLight"); - } - - @Test - public void resolveMultipleCachedSchemaInJsonContainingSchemasWithRelativeRef(Vertx vertx) throws Exception { - final URI baseJsonUri = buildBaseUri("openapi.json"); - SchemaRouter schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - SchemaParser schemaParser = SchemaParser.createOpenAPI3SchemaParser(schemaRouter); - - schemaRouter.addJson(baseJsonUri, loadJson(baseJsonUri)); - - Schema trafficLight = schemaRouter.resolveCachedSchema( - JsonPointer.from("/components/schemas/TrafficLight"), - JsonPointer.fromURI(baseJsonUri), - schemaParser - ); - - MyAssertions.assertThat(trafficLight) - .isNotNull(); - assertThat(trafficLight.getJson()) - .isInstanceOf(JsonObject.class); - MyAssertions.assertThat((JsonObject) trafficLight.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for TrafficLight"); - - Schema roadLayout = schemaRouter.resolveCachedSchema( - JsonPointer.from("/components/schemas/RoadLayout"), - JsonPointer.fromURI(baseJsonUri), - schemaParser - ); - MyAssertions.assertThat(roadLayout) - .isNotNull(); - assertThat(roadLayout.getJson()) - .isInstanceOf(JsonObject.class); - MyAssertions.assertThat((JsonObject) roadLayout.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for RoadLayout"); - } - - @Test - public void resolveMultipleCachedSchemaInJsonContainingSchemasWithAbsoluteRef(Vertx vertx) throws Exception { - final URI baseJsonUri = buildBaseUri("openapi.json"); - SchemaRouter schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - SchemaParser schemaParser = SchemaParser.createOpenAPI3SchemaParser(schemaRouter); - - schemaRouter.addJson(baseJsonUri, loadJson(baseJsonUri)); - - Schema trafficLight = schemaRouter.resolveCachedSchema( - JsonPointer.fromURI(URIUtils.replaceFragment(baseJsonUri, "/components/schemas/TrafficLight")), - JsonPointer.create(), - schemaParser - ); - MyAssertions.assertThat(trafficLight) - .isNotNull(); - assertThat(trafficLight.getJson()) - .isInstanceOf(JsonObject.class); - MyAssertions.assertThat((JsonObject) trafficLight.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for TrafficLight"); - - Schema roadLayout = schemaRouter.resolveCachedSchema( - JsonPointer.fromURI(URIUtils.replaceFragment(baseJsonUri, "/components/schemas/RoadLayout")), - JsonPointer.create(), - schemaParser - ); - MyAssertions.assertThat(roadLayout) - .isNotNull(); - assertThat(roadLayout.getJson()) - .isInstanceOf(JsonObject.class); - MyAssertions.assertThat((JsonObject) roadLayout.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for RoadLayout"); - } - - @Test - public void resolveRefInJsonContainingSchemasWithRelativeRef(Vertx vertx, VertxTestContext testContext) throws Exception { - final URI baseJsonUri = buildBaseUri("openapi.json"); - SchemaRouter schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - SchemaParser schemaParser = SchemaParser.createOpenAPI3SchemaParser(schemaRouter); - - schemaRouter.resolveRef( - JsonPointer.from("/components/schemas/TrafficLight"), - JsonPointer.fromURI(baseJsonUri), - schemaParser - ) - .onFailure(testContext::failNow) - .onSuccess(schema -> { - testContext.verify(() -> { - MyAssertions.assertThat(schema) - .isNotNull(); - assertThat(schema.getJson()) - .isInstanceOf(JsonObject.class); - MyAssertions.assertThat((JsonObject) schema.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for TrafficLight"); - }); - testContext.completeNow(); - }); - } - - @Test - public void resolveRefInJsonContainingSchemasWithAbsoluteRef(Vertx vertx, VertxTestContext testContext) throws Exception { - final URI baseJsonUri = buildBaseUri("openapi.json"); - SchemaRouter schemaRouter = SchemaRouter.create(vertx, new SchemaRouterOptions()); - SchemaParser schemaParser = SchemaParser.createOpenAPI3SchemaParser(schemaRouter); - - schemaRouter.resolveRef( - JsonPointer.fromURI(URIUtils.replaceFragment(baseJsonUri, "/components/schemas/TrafficLight")), - JsonPointer.create(), - schemaParser - ) - .onFailure(testContext::failNow) - .onSuccess(schema -> { - testContext.verify(() -> { - MyAssertions.assertThat(schema) - .isNotNull(); - assertThat(schema.getJson()) - .isInstanceOf(JsonObject.class); - MyAssertions.assertThat((JsonObject) schema.getJson()) - .extractingKey("title") - .isEqualTo("Root Type for TrafficLight"); - }); - testContext.completeNow(); - }); - } - -} diff --git a/src/test/java/io/vertx/json/schema/common/SchemaRouterLocalRefTest.java b/src/test/java/io/vertx/json/schema/common/SchemaRouterLocalRefTest.java deleted file mode 100644 index e69d5a13..00000000 --- a/src/test/java/io/vertx/json/schema/common/SchemaRouterLocalRefTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.common; - -import io.vertx.core.Vertx; -import io.vertx.core.impl.VertxInternal; -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.pointer.JsonPointer; -import io.vertx.json.schema.Schema; -import io.vertx.json.schema.SchemaRouter; -import io.vertx.json.schema.SchemaRouterOptions; -import io.vertx.json.schema.asserts.MyAssertions; -import io.vertx.json.schema.openapi3.OpenAPI3SchemaParser; -import io.vertx.junit5.Checkpoint; -import io.vertx.junit5.VertxExtension; -import io.vertx.junit5.VertxTestContext; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import java.net.URI; -import java.net.URISyntaxException; -import java.nio.file.Paths; - -import static io.vertx.json.schema.TestUtils.buildBaseUri; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; - -@ExtendWith(VertxExtension.class) -public class SchemaRouterLocalRefTest { - - private VertxInternal vertx; - - public SchemaParserInternal parser; - public SchemaRouter router; - - @BeforeEach - public void setUp(Vertx vertx) { - this.vertx = (VertxInternal) vertx; - router = SchemaRouter.create(vertx, new SchemaRouterOptions()); - parser = OpenAPI3SchemaParser.create(router); - } - - @Test - public void absoluteLocalRef(VertxTestContext context) { - URI sampleURI = buildBaseUri("ref_test", "sample.json"); - JsonObject mainSchemaUnparsed = new JsonObject().put("$ref", sampleURI.toString()); - Schema mainSchema = parser.parse(mainSchemaUnparsed, buildBaseUri("ref_test", "test_1.json")); - mainSchema.validateAsync("").onComplete(context.succeeding(o -> { // Trigger validation to start solve refs - context.verify(() -> { - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI), mainSchema.getScope(), parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI).append("definitions").append("sub1"), mainSchema.getScope(), parser).hasXIdEqualsTo("sub1"); - }); - context.completeNow(); - })); - } - - @Test - public void relativeLocalRef(VertxTestContext context) { - URI sampleURI = URI.create("./sample.json"); - JsonObject mainSchemaUnparsed = new JsonObject().put("$ref", sampleURI.toString()); - Schema mainSchema = parser.parse(mainSchemaUnparsed, Paths.get(".", "src", "test", "resources", "ref_test", "test_2.json").toUri()); - mainSchema.validateAsync("").onComplete(context.succeeding(o -> { // Trigger validation to start solve refs - context.verify(() -> { - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI), mainSchema.getScope(), parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI).append("definitions").append("sub1"), mainSchema.getScope(), parser).hasXIdEqualsTo("sub1"); - }); - context.completeNow(); - })); - } - - @Test - public void relativeLocalRefFromResources(VertxTestContext context) { - URI sampleURI = vertx.resolveFile("ref_test/sample.json").toURI(); - JsonObject mainSchemaUnparsed = new JsonObject().put("$ref", sampleURI.toString()); - Schema mainSchema = parser.parse(mainSchemaUnparsed, sampleURI.resolve("test_1.json")); - mainSchema.validateAsync("").onComplete(context.succeeding(o -> { // Trigger validation to start solve refs - context.verify(() -> { - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI), mainSchema.getScope(), parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI).append("definitions").append("sub1"), mainSchema.getScope(), parser).hasXIdEqualsTo("sub1"); - }); - context.completeNow(); - })); - } - - @Test - public void jarURIRelativization(VertxTestContext context) { - URI sampleURI = vertx.resolveFile("sample_in_jar.json").toURI(); - URI replaced1 = URIUtils.resolvePath(sampleURI, "empty_in_jar.json"); - URI replaced2 = URIUtils.resolvePath(sampleURI, "./empty_in_jar.json"); - context.verify(() -> { - assertThat(vertx.resolveFile("empty_in_jar.json").toURI()).isEqualTo(replaced1); - assertThat(vertx.resolveFile("empty_in_jar.json").toURI()).isEqualTo(replaced2); - }); - context.completeNow(); - } - - @Test - public void relativeLocalRefFromClassLoader(VertxTestContext context) { - URI sampleURI = vertx.resolveFile("sample_in_jar.json").toURI(); - JsonObject mainSchemaUnparsed = new JsonObject().put("$ref", sampleURI.toString()); - Schema mainSchema = parser.parse(mainSchemaUnparsed, URIUtils.resolvePath(sampleURI, "test_1.json")); - mainSchema.validateAsync("").onComplete(context.succeeding(o -> { // Trigger validation to start solve refs - context.verify(() -> { - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI), mainSchema.getScope(), parser).hasXIdEqualsTo("main"); - MyAssertions.assertThat(router).canResolveSchema(JsonPointer.fromURI(sampleURI).append("definitions").append("sub1"), mainSchema.getScope(), parser).hasXIdEqualsTo("sub1"); - }); - context.completeNow(); - })); - } - - @Test - public void localRecursiveRef(VertxTestContext context) { - Checkpoint check = context.checkpoint(2); - - URI sampleURI = buildBaseUri("ref_test", "person_recursive.json"); - JsonObject mainSchemaUnparsed = new JsonObject().put("$ref", sampleURI.toString()); - Schema mainSchema = parser.parse(mainSchemaUnparsed, buildBaseUri("ref_test", "test_1.json")); - mainSchema.validateAsync(new JsonObject() - .put("name", "Francesco") - .put("surname", "Guardiani") - .put("id_card", "ABC") - .put("father", new JsonObject() - .put("name", "Pietro") - .put("surname", "Guardiani") - .put("id_card", "XYZ") - ) - ).onComplete(context.succeeding(o -> check.flag())); - mainSchema.validateAsync(new JsonObject() - .put("name", "Francesco") - .put("surname", "Guardiani") - .put("id_card", "ABC") - .put("father", new JsonObject() - .put("name", "Pietro") - .put("surname", "Guardiani") // No id card! - ) - ).onComplete(context.failing(o -> check.flag())); - } - -} diff --git a/src/test/java/io/vertx/json/schema/oas3/OAS3IntegrationTest.java b/src/test/java/io/vertx/json/schema/oas3/OAS3IntegrationTest.java deleted file mode 100644 index 91267811..00000000 --- a/src/test/java/io/vertx/json/schema/oas3/OAS3IntegrationTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011-2020 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 - * which is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 - */ -package io.vertx.json.schema.oas3; - -import io.vertx.core.Vertx; -import io.vertx.json.schema.BaseIntegrationTest; -import io.vertx.json.schema.SchemaRouterOptions; -import io.vertx.json.schema.common.SchemaParserInternal; -import io.vertx.json.schema.common.SchemaRouterImpl; -import io.vertx.json.schema.openapi3.OpenAPI3SchemaParser; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.stream.Stream; - -/** - * @author Francesco Guardiani @slinkydeveloper - */ -public class OAS3IntegrationTest extends BaseIntegrationTest { - - @Override - public Stream getTestFiles() { - return Stream.of( - "additionalProperties", - "allOf", - "anyOf", -// "discriminator", - "enum", - "exclusiveMaximum", - "exclusiveMinimum", - "format", - "items", - "maximum", - "maxItems", - "maxLength", - "maxProperties", - "minimum", - "minItems", - "minLength", - "minProperties", - "multipleOf", - "not", - "nullable", - "oneOf", - "pattern", - "properties", - "ref", - "refRemote", - "required", - "type", - "uniqueItems" - ); - } - - @Override - public SchemaParserInternal getSchemaParser(Vertx vertx) { - return OpenAPI3SchemaParser.create(new SchemaRouterImpl(vertx, vertx.createHttpClient(), vertx.fileSystem(), new SchemaRouterOptions())); - } - - @Override - public Path getTckPath() { - return Paths.get("src", "test", "resources", "tck", "openapi3"); - } - - @Override - public Path getRemotesPath() { - return Paths.get("src", "test", "resources", "tck", "openapi3", "remotes"); - } -} diff --git a/src/test/resources/tck/draft2019-09/additionalItems.json b/src/test/resources/tck/draft2019-09/additionalItems.json deleted file mode 100644 index fa34ca4f..00000000 --- a/src/test/resources/tck/draft2019-09/additionalItems.json +++ /dev/null @@ -1,216 +0,0 @@ -[ - { - "description": "additionalItems as schema", - "schema": { - "items": [ - {} - ], - "additionalItems": { - "type": "integer" - } - }, - "tests": [ - { - "description": "additional items match schema", - "data": [ - null, - 2, - 3, - 4 - ], - "valid": true - }, - { - "description": "additional items do not match schema", - "data": [ - null, - 2, - 3, - "foo" - ], - "valid": false - } - ] - }, - { - "description": "items is schema, no additionalItems", - "schema": { - "items": {}, - "additionalItems": false - }, - "tests": [ - { - "description": "all items match schema", - "data": [ - 1, - 2, - 3, - 4, - 5 - ], - "valid": true - } - ] - }, - { - "description": "array of items with no additionalItems", - "schema": { - "items": [ - {}, - {}, - {} - ], - "additionalItems": false - }, - "tests": [ - { - "description": "empty array", - "data": [], - "valid": true - }, - { - "description": "fewer number of items present (1)", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "fewer number of items present (2)", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "equal number of items present", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "additional items are not permitted", - "data": [ - 1, - 2, - 3, - 4 - ], - "valid": false - } - ] - }, - { - "description": "additionalItems as false without items", - "schema": { - "additionalItems": false - }, - "tests": [ - { - "description": "items defaults to empty schema so everything is valid", - "data": [ - 1, - 2, - 3, - 4, - 5 - ], - "valid": true - }, - { - "description": "ignores non-arrays", - "data": { - "foo": "bar" - }, - "valid": true - } - ] - }, - { - "description": "additionalItems are allowed by default", - "schema": { - "items": [ - { - "type": "integer" - } - ] - }, - "tests": [ - { - "description": "only the first item is validated", - "data": [ - 1, - "foo", - false - ], - "valid": true - } - ] - }, - { - "description": "additionalItems should not look in applicators, valid case", - "schema": { - "allOf": [ - { - "items": [ - { - "type": "integer" - } - ] - } - ], - "additionalItems": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "items defined in allOf are not examined", - "data": [ - 1, - null - ], - "valid": true - } - ] - }, - { - "description": "additionalItems should not look in applicators, invalid case", - "schema": { - "allOf": [ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - ], - "items": [ - { - "type": "integer" - } - ], - "additionalItems": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "items defined in allOf are not examined", - "data": [ - 1, - "hello" - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/additionalProperties.json b/src/test/resources/tck/draft2019-09/additionalProperties.json deleted file mode 100644 index 33406893..00000000 --- a/src/test/resources/tck/draft2019-09/additionalProperties.json +++ /dev/null @@ -1,193 +0,0 @@ -[ - { - "description": "additionalProperties being false does not allow other properties", - "schema": { - "properties": { - "foo": {}, - "bar": {} - }, - "patternProperties": { - "^v": {} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "no additional properties is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "an additional property is invalid", - "data": { - "foo": 1, - "bar": 2, - "quux": "boom" - }, - "valid": false - }, - { - "description": "ignores arrays", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobarbaz", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - }, - { - "description": "patternProperties are not additional properties", - "data": { - "foo": 1, - "vroom": 2 - }, - "valid": true - } - ] - }, - { - "description": "non-ASCII pattern with additionalProperties", - "schema": { - "patternProperties": { - "^á": {} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "matching the pattern is valid", - "data": { - "ármányos": 2 - }, - "valid": true - }, - { - "description": "not matching the pattern is invalid", - "data": { - "élmény": 2 - }, - "valid": false - } - ] - }, - { - "description": "additionalProperties allows a schema which should validate", - "schema": { - "properties": { - "foo": {}, - "bar": {} - }, - "additionalProperties": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "no additional properties is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "an additional valid property is valid", - "data": { - "foo": 1, - "bar": 2, - "quux": true - }, - "valid": true - }, - { - "description": "an additional invalid property is invalid", - "data": { - "foo": 1, - "bar": 2, - "quux": 12 - }, - "valid": false - } - ] - }, - { - "description": "additionalProperties can exist by itself", - "schema": { - "additionalProperties": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "an additional valid property is valid", - "data": { - "foo": true - }, - "valid": true - }, - { - "description": "an additional invalid property is invalid", - "data": { - "foo": 1 - }, - "valid": false - } - ] - }, - { - "description": "additionalProperties are allowed by default", - "schema": { - "properties": { - "foo": {}, - "bar": {} - } - }, - "tests": [ - { - "description": "additional properties are allowed", - "data": { - "foo": 1, - "bar": 2, - "quux": true - }, - "valid": true - } - ] - }, - { - "description": "additionalProperties should not look in applicators", - "schema": { - "allOf": [ - { - "properties": { - "foo": {} - } - } - ], - "additionalProperties": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "properties defined in allOf are not examined", - "data": { - "foo": 1, - "bar": true - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/allOf.json b/src/test/resources/tck/draft2019-09/allOf.json deleted file mode 100644 index cc0076b3..00000000 --- a/src/test/resources/tck/draft2019-09/allOf.json +++ /dev/null @@ -1,376 +0,0 @@ -[ - { - "description": "allOf", - "schema": { - "allOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - }, - "tests": [ - { - "description": "allOf", - "data": { - "foo": "baz", - "bar": 2 - }, - "valid": true - }, - { - "description": "mismatch second", - "data": { - "foo": "baz" - }, - "valid": false - }, - { - "description": "mismatch first", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "wrong type", - "data": { - "foo": "baz", - "bar": "quux" - }, - "valid": false - } - ] - }, - { - "description": "allOf with base schema", - "schema": { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ], - "allOf": [ - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - }, - { - "properties": { - "baz": { - "type": "null" - } - }, - "required": [ - "baz" - ] - } - ] - }, - "tests": [ - { - "description": "valid", - "data": { - "foo": "quux", - "bar": 2, - "baz": null - }, - "valid": true - }, - { - "description": "mismatch base schema", - "data": { - "foo": "quux", - "baz": null - }, - "valid": false - }, - { - "description": "mismatch first allOf", - "data": { - "bar": 2, - "baz": null - }, - "valid": false - }, - { - "description": "mismatch second allOf", - "data": { - "foo": "quux", - "bar": 2 - }, - "valid": false - }, - { - "description": "mismatch both", - "data": { - "bar": 2 - }, - "valid": false - } - ] - }, - { - "description": "allOf simple types", - "schema": { - "allOf": [ - { - "maximum": 30 - }, - { - "minimum": 20 - } - ] - }, - "tests": [ - { - "description": "valid", - "data": 25, - "valid": true - }, - { - "description": "mismatch one", - "data": 35, - "valid": false - } - ] - }, - { - "description": "allOf with boolean schemas, all true", - "schema": { - "allOf": [ - true, - true - ] - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "allOf with boolean schemas, some false", - "schema": { - "allOf": [ - true, - false - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "allOf with boolean schemas, all false", - "schema": { - "allOf": [ - false, - false - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "allOf with one empty schema", - "schema": { - "allOf": [ - {} - ] - }, - "tests": [ - { - "description": "any data is valid", - "data": 1, - "valid": true - } - ] - }, - { - "description": "allOf with two empty schemas", - "schema": { - "allOf": [ - {}, - {} - ] - }, - "tests": [ - { - "description": "any data is valid", - "data": 1, - "valid": true - } - ] - }, - { - "description": "allOf with the first empty schema", - "schema": { - "allOf": [ - {}, - { - "type": "number" - } - ] - }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "allOf with the last empty schema", - "schema": { - "allOf": [ - { - "type": "number" - }, - {} - ] - }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "nested allOf, to check validation semantics", - "schema": { - "allOf": [ - { - "allOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "allOf combined with anyOf, oneOf", - "schema": { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - }, - "tests": [ - { - "description": "allOf: false, anyOf: false, oneOf: false", - "data": 1, - "valid": false - }, - { - "description": "allOf: false, anyOf: false, oneOf: true", - "data": 5, - "valid": false - }, - { - "description": "allOf: false, anyOf: true, oneOf: false", - "data": 3, - "valid": false - }, - { - "description": "allOf: false, anyOf: true, oneOf: true", - "data": 15, - "valid": false - }, - { - "description": "allOf: true, anyOf: false, oneOf: false", - "data": 2, - "valid": false - }, - { - "description": "allOf: true, anyOf: false, oneOf: true", - "data": 10, - "valid": false - }, - { - "description": "allOf: true, anyOf: true, oneOf: false", - "data": 6, - "valid": false - }, - { - "description": "allOf: true, anyOf: true, oneOf: true", - "data": 30, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/anchor.json b/src/test/resources/tck/draft2019-09/anchor.json deleted file mode 100644 index 629aebec..00000000 --- a/src/test/resources/tck/draft2019-09/anchor.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "description": "Location-independent identifier", - "schema": { - "$ref": "#foo", - "$defs": { - "A": { - "$anchor": "foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "Location-independent identifier with absolute URI", - "schema": { - "$ref": "http://localhost:1234/bar#foo", - "$defs": { - "A": { - "$id": "http://localhost:1234/bar", - "$anchor": "foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "Location-independent identifier with base URI change in subschema", - "schema": { - "$id": "http://localhost:1234/root", - "$ref": "http://localhost:1234/nested.json#foo", - "$defs": { - "A": { - "$id": "nested.json", - "$defs": { - "B": { - "$anchor": "foo", - "type": "integer" - } - } - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/anyOf.json b/src/test/resources/tck/draft2019-09/anyOf.json deleted file mode 100644 index f35e2194..00000000 --- a/src/test/resources/tck/draft2019-09/anyOf.json +++ /dev/null @@ -1,224 +0,0 @@ -[ - { - "description": "anyOf", - "schema": { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - }, - "tests": [ - { - "description": "first anyOf valid", - "data": 1, - "valid": true - }, - { - "description": "second anyOf valid", - "data": 2.5, - "valid": true - }, - { - "description": "both anyOf valid", - "data": 3, - "valid": true - }, - { - "description": "neither anyOf valid", - "data": 1.5, - "valid": false - } - ] - }, - { - "description": "anyOf with base schema", - "schema": { - "type": "string", - "anyOf": [ - { - "maxLength": 2 - }, - { - "minLength": 4 - } - ] - }, - "tests": [ - { - "description": "mismatch base schema", - "data": 3, - "valid": false - }, - { - "description": "one anyOf valid", - "data": "foobar", - "valid": true - }, - { - "description": "both anyOf invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "anyOf with boolean schemas, all true", - "schema": { - "anyOf": [ - true, - true - ] - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "anyOf with boolean schemas, some true", - "schema": { - "anyOf": [ - true, - false - ] - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "anyOf with boolean schemas, all false", - "schema": { - "anyOf": [ - false, - false - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "anyOf complex types", - "schema": { - "anyOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - }, - "tests": [ - { - "description": "first anyOf valid (complex)", - "data": { - "bar": 2 - }, - "valid": true - }, - { - "description": "second anyOf valid (complex)", - "data": { - "foo": "baz" - }, - "valid": true - }, - { - "description": "both anyOf valid (complex)", - "data": { - "foo": "baz", - "bar": 2 - }, - "valid": true - }, - { - "description": "neither anyOf valid (complex)", - "data": { - "foo": 2, - "bar": "quux" - }, - "valid": false - } - ] - }, - { - "description": "anyOf with one empty schema", - "schema": { - "anyOf": [ - { - "type": "number" - }, - {} - ] - }, - "tests": [ - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "number is valid", - "data": 123, - "valid": true - } - ] - }, - { - "description": "nested anyOf, to check validation semantics", - "schema": { - "anyOf": [ - { - "anyOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/boolean_schema.json b/src/test/resources/tck/draft2019-09/boolean_schema.json deleted file mode 100644 index ee241ef9..00000000 --- a/src/test/resources/tck/draft2019-09/boolean_schema.json +++ /dev/null @@ -1,112 +0,0 @@ -[ - { - "description": "boolean schema 'true'", - "schema": true, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "boolean true is valid", - "data": true, - "valid": true - }, - { - "description": "boolean false is valid", - "data": false, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "object is valid", - "data": { - "foo": "bar" - }, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "array is valid", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "boolean schema 'false'", - "schema": false, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": { - "foo": "bar" - }, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": [ - "foo" - ], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/const.json b/src/test/resources/tck/draft2019-09/const.json deleted file mode 100644 index 0e23a71c..00000000 --- a/src/test/resources/tck/draft2019-09/const.json +++ /dev/null @@ -1,308 +0,0 @@ -[ - { - "description": "const validation", - "schema": { - "const": 2 - }, - "tests": [ - { - "description": "same value is valid", - "data": 2, - "valid": true - }, - { - "description": "another value is invalid", - "data": 5, - "valid": false - }, - { - "description": "another type is invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "const with object", - "schema": { - "const": { - "foo": "bar", - "baz": "bax" - } - }, - "tests": [ - { - "description": "same object is valid", - "data": { - "foo": "bar", - "baz": "bax" - }, - "valid": true - }, - { - "description": "same object with different property order is valid", - "data": { - "baz": "bax", - "foo": "bar" - }, - "valid": true - }, - { - "description": "another object is invalid", - "data": { - "foo": "bar" - }, - "valid": false - }, - { - "description": "another type is invalid", - "data": [ - 1, - 2 - ], - "valid": false - } - ] - }, - { - "description": "const with array", - "schema": { - "const": [ - { - "foo": "bar" - } - ] - }, - "tests": [ - { - "description": "same array is valid", - "data": [ - { - "foo": "bar" - } - ], - "valid": true - }, - { - "description": "another array item is invalid", - "data": [ - 2 - ], - "valid": false - }, - { - "description": "array with additional items is invalid", - "data": [ - 1, - 2, - 3 - ], - "valid": false - } - ] - }, - { - "description": "const with null", - "schema": { - "const": null - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "not null is invalid", - "data": 0, - "valid": false - } - ] - }, - { - "description": "const with false does not match 0", - "schema": { - "const": false - }, - "tests": [ - { - "description": "false is valid", - "data": false, - "valid": true - }, - { - "description": "integer zero is invalid", - "data": 0, - "valid": false - }, - { - "description": "float zero is invalid", - "data": 0.0, - "valid": false - } - ] - }, - { - "description": "const with true does not match 1", - "schema": { - "const": true - }, - "tests": [ - { - "description": "true is valid", - "data": true, - "valid": true - }, - { - "description": "integer one is invalid", - "data": 1, - "valid": false - }, - { - "description": "float one is invalid", - "data": 1.0, - "valid": false - } - ] - }, - { - "description": "const with 0 does not match other zero-like types", - "schema": { - "const": 0 - }, - "tests": [ - { - "description": "false is invalid", - "data": false, - "valid": false - }, - { - "description": "integer zero is valid", - "data": 0, - "valid": true - }, - { - "description": "float zero is valid", - "data": 0.0, - "valid": true - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - }, - { - "description": "empty string is invalid", - "data": "", - "valid": false - } - ] - }, - { - "description": "const with 1 does not match true", - "schema": { - "const": 1 - }, - "tests": [ - { - "description": "true is invalid", - "data": true, - "valid": false - }, - { - "description": "integer one is valid", - "data": 1, - "valid": true - }, - { - "description": "float one is valid", - "data": 1.0, - "valid": true - } - ] - }, - { - "description": "const with -2.0 matches integer and float types", - "schema": { - "const": -2.0 - }, - "tests": [ - { - "description": "integer -2 is valid", - "data": -2, - "valid": true - }, - { - "description": "integer 2 is invalid", - "data": 2, - "valid": false - }, - { - "description": "float -2.0 is valid", - "data": -2.0, - "valid": true - }, - { - "description": "float 2.0 is invalid", - "data": 2.0, - "valid": false - }, - { - "description": "float -2.00001 is invalid", - "data": -2.00001, - "valid": false - } - ] - }, - { - "description": "float and integers are equal up to 64-bit representation limits", - "schema": { - "const": 9007199254740992 - }, - "tests": [ - { - "description": "integer is valid", - "data": 9007199254740992, - "valid": true - }, - { - "description": "integer minus one is invalid", - "data": 9007199254740991, - "valid": false - }, - { - "description": "float is valid", - "data": 9007199254740992.0, - "valid": true - }, - { - "description": "float minus one is invalid", - "data": 9007199254740991.0, - "valid": false - } - ] - }, - { - "description": "nul characters in strings", - "schema": { - "const": "hello\u0000there" - }, - "tests": [ - { - "description": "match string with nul", - "data": "hello\u0000there", - "valid": true - }, - { - "description": "do not match string lacking nul", - "data": "hellothere", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/contains.json b/src/test/resources/tck/draft2019-09/contains.json deleted file mode 100644 index 191b2460..00000000 --- a/src/test/resources/tck/draft2019-09/contains.json +++ /dev/null @@ -1,190 +0,0 @@ -[ - { - "description": "contains keyword validation", - "schema": { - "contains": { - "minimum": 5 - } - }, - "tests": [ - { - "description": "array with item matching schema (5) is valid", - "data": [ - 3, - 4, - 5 - ], - "valid": true - }, - { - "description": "array with item matching schema (6) is valid", - "data": [ - 3, - 4, - 6 - ], - "valid": true - }, - { - "description": "array with two items matching schema (5, 6) is valid", - "data": [ - 3, - 4, - 5, - 6 - ], - "valid": true - }, - { - "description": "array without items matching schema is invalid", - "data": [ - 2, - 3, - 4 - ], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - }, - { - "description": "not array is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "contains keyword with const keyword", - "schema": { - "contains": { - "const": 5 - } - }, - "tests": [ - { - "description": "array with item 5 is valid", - "data": [ - 3, - 4, - 5 - ], - "valid": true - }, - { - "description": "array with two items 5 is valid", - "data": [ - 3, - 4, - 5, - 5 - ], - "valid": true - }, - { - "description": "array without item 5 is invalid", - "data": [ - 1, - 2, - 3, - 4 - ], - "valid": false - } - ] - }, - { - "description": "contains keyword with boolean schema true", - "schema": { - "contains": true - }, - "tests": [ - { - "description": "any non-empty array is valid", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "contains keyword with boolean schema false", - "schema": { - "contains": false - }, - "tests": [ - { - "description": "any non-empty array is invalid", - "data": [ - "foo" - ], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - }, - { - "description": "non-arrays are valid", - "data": "contains does not apply to strings", - "valid": true - } - ] - }, - { - "description": "items + contains", - "schema": { - "items": { - "multipleOf": 2 - }, - "contains": { - "multipleOf": 3 - } - }, - "tests": [ - { - "description": "matches items, does not match contains", - "data": [ - 2, - 4, - 8 - ], - "valid": false - }, - { - "description": "does not match items, matches contains", - "data": [ - 3, - 6, - 9 - ], - "valid": false - }, - { - "description": "matches both items and contains", - "data": [ - 6, - 12 - ], - "valid": true - }, - { - "description": "matches neither items nor contains", - "data": [ - 1, - 5 - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/default.json b/src/test/resources/tck/draft2019-09/default.json deleted file mode 100644 index 98371339..00000000 --- a/src/test/resources/tck/draft2019-09/default.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "description": "invalid type for default", - "schema": { - "properties": { - "foo": { - "type": "integer", - "default": [] - } - } - }, - "tests": [ - { - "description": "valid when property is specified", - "data": { - "foo": 13 - }, - "valid": true - }, - { - "description": "still valid when the invalid default is used", - "data": {}, - "valid": true - } - ] - }, - { - "description": "invalid string value for default", - "schema": { - "properties": { - "bar": { - "type": "string", - "minLength": 4, - "default": "bad" - } - } - }, - "tests": [ - { - "description": "valid when property is specified", - "data": { - "bar": "good" - }, - "valid": true - }, - { - "description": "still valid when the invalid default is used", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/defs.json b/src/test/resources/tck/draft2019-09/defs.json deleted file mode 100644 index c3c4cee4..00000000 --- a/src/test/resources/tck/draft2019-09/defs.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "description": "valid definition", - "schema": { - "$ref": "https://json-schema.org/draft/2019-09/schema" - }, - "tests": [ - { - "description": "valid definition schema", - "data": { - "$defs": { - "foo": { - "type": "integer" - } - } - }, - "valid": true - } - ] - }, - { - "description": "invalid definition", - "schema": { - "$ref": "https://json-schema.org/draft/2019-09/schema" - }, - "tests": [ - { - "description": "invalid definition schema", - "data": { - "$defs": { - "foo": { - "type": 1 - } - } - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/dependentRequired.json b/src/test/resources/tck/draft2019-09/dependentRequired.json deleted file mode 100644 index f86a2875..00000000 --- a/src/test/resources/tck/draft2019-09/dependentRequired.json +++ /dev/null @@ -1,189 +0,0 @@ -[ - { - "description": "single dependency", - "schema": { - "dependentRequired": { - "bar": [ - "foo" - ] - } - }, - "tests": [ - { - "description": "neither", - "data": {}, - "valid": true - }, - { - "description": "nondependant", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "with dependency", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "missing dependency", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "ignores arrays", - "data": [ - "bar" - ], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "empty dependents", - "schema": { - "dependentRequired": { - "bar": [] - } - }, - "tests": [ - { - "description": "empty object", - "data": {}, - "valid": true - }, - { - "description": "object with one property", - "data": { - "bar": 2 - }, - "valid": true - }, - { - "description": "non-object is valid", - "data": 1, - "valid": true - } - ] - }, - { - "description": "multiple dependents required", - "schema": { - "dependentRequired": { - "quux": [ - "foo", - "bar" - ] - } - }, - "tests": [ - { - "description": "neither", - "data": {}, - "valid": true - }, - { - "description": "nondependants", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "with dependencies", - "data": { - "foo": 1, - "bar": 2, - "quux": 3 - }, - "valid": true - }, - { - "description": "missing dependency", - "data": { - "foo": 1, - "quux": 2 - }, - "valid": false - }, - { - "description": "missing other dependency", - "data": { - "bar": 1, - "quux": 2 - }, - "valid": false - }, - { - "description": "missing both dependencies", - "data": { - "quux": 1 - }, - "valid": false - } - ] - }, - { - "description": "dependencies with escaped characters", - "schema": { - "dependentRequired": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\"bar": [ - "foo'bar" - ] - } - }, - "tests": [ - { - "description": "CRLF", - "data": { - "foo\nbar": 1, - "foo\rbar": 2 - }, - "valid": true - }, - { - "description": "quoted quotes", - "data": { - "foo'bar": 1, - "foo\"bar": 2 - }, - "valid": true - }, - { - "description": "CRLF missing dependent", - "data": { - "foo\nbar": 1, - "foo": 2 - }, - "valid": false - }, - { - "description": "quoted quotes missing dependent", - "data": { - "foo\"bar": 2 - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/dependentSchemas.json b/src/test/resources/tck/draft2019-09/dependentSchemas.json deleted file mode 100644 index 532ccc97..00000000 --- a/src/test/resources/tck/draft2019-09/dependentSchemas.json +++ /dev/null @@ -1,149 +0,0 @@ -[ - { - "description": "single dependency", - "schema": { - "dependentSchemas": { - "bar": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "integer" - } - } - } - } - }, - "tests": [ - { - "description": "valid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "no dependency", - "data": { - "foo": "quux" - }, - "valid": true - }, - { - "description": "wrong type", - "data": { - "foo": "quux", - "bar": 2 - }, - "valid": false - }, - { - "description": "wrong type other", - "data": { - "foo": 2, - "bar": "quux" - }, - "valid": false - }, - { - "description": "wrong type both", - "data": { - "foo": "quux", - "bar": "quux" - }, - "valid": false - } - ] - }, - { - "description": "boolean subschemas", - "schema": { - "dependentSchemas": { - "foo": true, - "bar": false - } - }, - "tests": [ - { - "description": "object with property having schema true is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "object with property having schema false is invalid", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "object with both properties is invalid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "dependencies with escaped characters", - "schema": { - "dependentSchemas": { - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - } - } - }, - "tests": [ - { - "description": "quoted tab", - "data": { - "foo\tbar": 1, - "a": 2, - "b": 3, - "c": 4 - }, - "valid": true - }, - { - "description": "quoted quote", - "data": { - "foo'bar": { - "foo\"bar": 1 - } - }, - "valid": false - }, - { - "description": "quoted tab invalid under dependent schema", - "data": { - "foo\tbar": 1, - "a": 2 - }, - "valid": false - }, - { - "description": "quoted quote invalid under dependent schema", - "data": { - "foo'bar": 1 - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/enum.json b/src/test/resources/tck/draft2019-09/enum.json deleted file mode 100644 index 6d39ef48..00000000 --- a/src/test/resources/tck/draft2019-09/enum.json +++ /dev/null @@ -1,295 +0,0 @@ -[ - { - "description": "simple enum validation", - "schema": { - "enum": [ - 1, - 2, - 3 - ] - }, - "tests": [ - { - "description": "one of the enum is valid", - "data": 1, - "valid": true - }, - { - "description": "something else is invalid", - "data": 4, - "valid": false - } - ] - }, - { - "description": "heterogeneous enum validation", - "schema": { - "enum": [ - 6, - "foo", - [], - true, - { - "foo": 12 - } - ] - }, - "tests": [ - { - "description": "one of the enum is valid", - "data": [], - "valid": true - }, - { - "description": "something else is invalid", - "data": null, - "valid": false - }, - { - "description": "objects are deep compared", - "data": { - "foo": false - }, - "valid": false - } - ] - }, - { - "description": "heterogeneous enum-with-null validation", - "schema": { - "enum": [ - 6, - null - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "number is valid", - "data": 6, - "valid": true - }, - { - "description": "something else is invalid", - "data": "test", - "valid": false - } - ] - }, - { - "description": "enums in properties", - "schema": { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": { - "enum": [ - "bar" - ] - } - }, - "required": [ - "bar" - ] - }, - "tests": [ - { - "description": "both properties are valid", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "wrong foo value", - "data": { - "foo": "foot", - "bar": "bar" - }, - "valid": false - }, - { - "description": "wrong bar value", - "data": { - "foo": "foo", - "bar": "bart" - }, - "valid": false - }, - { - "description": "missing optional property is valid", - "data": { - "bar": "bar" - }, - "valid": true - }, - { - "description": "missing required property is invalid", - "data": { - "foo": "foo" - }, - "valid": false - }, - { - "description": "missing all properties is invalid", - "data": {}, - "valid": false - } - ] - }, - { - "description": "enum with escaped characters", - "schema": { - "enum": [ - "foo\nbar", - "foo\rbar" - ] - }, - "tests": [ - { - "description": "member 1 is valid", - "data": "foo\nbar", - "valid": true - }, - { - "description": "member 2 is valid", - "data": "foo\rbar", - "valid": true - }, - { - "description": "another string is invalid", - "data": "abc", - "valid": false - } - ] - }, - { - "description": "enum with false does not match 0", - "schema": { - "enum": [ - false - ] - }, - "tests": [ - { - "description": "false is valid", - "data": false, - "valid": true - }, - { - "description": "integer zero is invalid", - "data": 0, - "valid": false - }, - { - "description": "float zero is invalid", - "data": 0.0, - "valid": false - } - ] - }, - { - "description": "enum with true does not match 1", - "schema": { - "enum": [ - true - ] - }, - "tests": [ - { - "description": "true is valid", - "data": true, - "valid": true - }, - { - "description": "integer one is invalid", - "data": 1, - "valid": false - }, - { - "description": "float one is invalid", - "data": 1.0, - "valid": false - } - ] - }, - { - "description": "enum with 0 does not match false", - "schema": { - "enum": [ - 0 - ] - }, - "tests": [ - { - "description": "false is invalid", - "data": false, - "valid": false - }, - { - "description": "integer zero is valid", - "data": 0, - "valid": true - }, - { - "description": "float zero is valid", - "data": 0.0, - "valid": true - } - ] - }, - { - "description": "enum with 1 does not match true", - "schema": { - "enum": [ - 1 - ] - }, - "tests": [ - { - "description": "true is invalid", - "data": true, - "valid": false - }, - { - "description": "integer one is valid", - "data": 1, - "valid": true - }, - { - "description": "float one is valid", - "data": 1.0, - "valid": true - } - ] - }, - { - "description": "nul characters in strings", - "schema": { - "enum": [ - "hello\u0000there" - ] - }, - "tests": [ - { - "description": "match string with nul", - "data": "hello\u0000there", - "valid": true - }, - { - "description": "do not match string lacking nul", - "data": "hellothere", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/exclusiveMaximum.json b/src/test/resources/tck/draft2019-09/exclusiveMaximum.json deleted file mode 100644 index fc8c4bb4..00000000 --- a/src/test/resources/tck/draft2019-09/exclusiveMaximum.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "exclusiveMaximum validation", - "schema": { - "exclusiveMaximum": 3.0 - }, - "tests": [ - { - "description": "below the exclusiveMaximum is valid", - "data": 2.2, - "valid": true - }, - { - "description": "boundary point is invalid", - "data": 3.0, - "valid": false - }, - { - "description": "above the exclusiveMaximum is invalid", - "data": 3.5, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/exclusiveMinimum.json b/src/test/resources/tck/draft2019-09/exclusiveMinimum.json deleted file mode 100644 index 815d8fbe..00000000 --- a/src/test/resources/tck/draft2019-09/exclusiveMinimum.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "exclusiveMinimum validation", - "schema": { - "exclusiveMinimum": 1.1 - }, - "tests": [ - { - "description": "above the exclusiveMinimum is valid", - "data": 1.2, - "valid": true - }, - { - "description": "boundary point is invalid", - "data": 1.1, - "valid": false - }, - { - "description": "below the exclusiveMinimum is invalid", - "data": 0.6, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/format.json b/src/test/resources/tck/draft2019-09/format.json deleted file mode 100644 index 57dea665..00000000 --- a/src/test/resources/tck/draft2019-09/format.json +++ /dev/null @@ -1,686 +0,0 @@ -[ - { - "description": "validation of e-mail addresses", - "schema": { - "format": "email" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IDN e-mail addresses", - "schema": { - "format": "idn-email" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of regexes", - "schema": { - "format": "regex" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IP addresses", - "schema": { - "format": "ipv4" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IPv6 addresses", - "schema": { - "format": "ipv6" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IDN hostnames", - "schema": { - "format": "idn-hostname" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of hostnames", - "schema": { - "format": "hostname" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of date strings", - "schema": { - "format": "date" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of date-time strings", - "schema": { - "format": "date-time" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of time strings", - "schema": { - "format": "time" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of JSON pointers", - "schema": { - "format": "json-pointer" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of relative JSON pointers", - "schema": { - "format": "relative-json-pointer" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IRIs", - "schema": { - "format": "iri" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IRI references", - "schema": { - "format": "iri-reference" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of URIs", - "schema": { - "format": "uri" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of URI references", - "schema": { - "format": "uri-reference" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of URI templates", - "schema": { - "format": "uri-template" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of UUIDs", - "schema": { - "format": "uuid" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/id.json b/src/test/resources/tck/draft2019-09/id.json deleted file mode 100644 index 337bf26c..00000000 --- a/src/test/resources/tck/draft2019-09/id.json +++ /dev/null @@ -1,210 +0,0 @@ -[ - { - "description": "Invalid use of fragments in location-independent $id", - "schema": { - "$ref": "https://json-schema.org/draft/2019-09/schema" - }, - "tests": [ - { - "description": "Identifier name", - "data": { - "$ref": "#foo", - "$defs": { - "A": { - "$id": "#foo", - "type": "integer" - } - } - }, - "valid": false - }, - { - "description": "Identifier name and no ref", - "data": { - "$defs": { - "A": { - "$id": "#foo" - } - } - }, - "valid": false - }, - { - "description": "Identifier path", - "data": { - "$ref": "#/a/b", - "$defs": { - "A": { - "$id": "#/a/b", - "type": "integer" - } - } - }, - "valid": false - }, - { - "description": "Identifier name with absolute URI", - "data": { - "$ref": "http://localhost:1234/bar#foo", - "$defs": { - "A": { - "$id": "http://localhost:1234/bar#foo", - "type": "integer" - } - } - }, - "valid": false - }, - { - "description": "Identifier path with absolute URI", - "data": { - "$ref": "http://localhost:1234/bar#/a/b", - "$defs": { - "A": { - "$id": "http://localhost:1234/bar#/a/b", - "type": "integer" - } - } - }, - "valid": false - }, - { - "description": "Identifier name with base URI change in subschema", - "data": { - "$id": "http://localhost:1234/root", - "$ref": "http://localhost:1234/nested.json#foo", - "$defs": { - "A": { - "$id": "nested.json", - "$defs": { - "B": { - "$id": "#foo", - "type": "integer" - } - } - } - } - }, - "valid": false - }, - { - "description": "Identifier path with base URI change in subschema", - "data": { - "$id": "http://localhost:1234/root", - "$ref": "http://localhost:1234/nested.json#/a/b", - "$defs": { - "A": { - "$id": "nested.json", - "$defs": { - "B": { - "$id": "#/a/b", - "type": "integer" - } - } - } - } - }, - "valid": false - } - ] - }, - { - "description": "Valid use of empty fragments in location-independent $id", - "comment": "These are allowed but discouraged", - "schema": { - "$ref": "https://json-schema.org/draft/2019-09/schema" - }, - "tests": [ - { - "description": "Identifier name with absolute URI", - "data": { - "$ref": "http://localhost:1234/bar", - "$defs": { - "A": { - "$id": "http://localhost:1234/bar#", - "type": "integer" - } - } - }, - "valid": true - }, - { - "description": "Identifier name with base URI change in subschema", - "data": { - "$id": "http://localhost:1234/root", - "$ref": "http://localhost:1234/nested.json#/$defs/B", - "$defs": { - "A": { - "$id": "nested.json", - "$defs": { - "B": { - "$id": "#", - "type": "integer" - } - } - } - } - }, - "valid": true - } - ] - }, - { - "description": "Unnormalized $ids are allowed but discouraged", - "schema": { - "$ref": "https://json-schema.org/draft/2019-09/schema" - }, - "tests": [ - { - "description": "Unnormalized identifier", - "data": { - "$ref": "http://localhost:1234/foo/baz", - "$defs": { - "A": { - "$id": "http://localhost:1234/foo/bar/../baz", - "type": "integer" - } - } - }, - "valid": true - }, - { - "description": "Unnormalized identifier and no ref", - "data": { - "$defs": { - "A": { - "$id": "http://localhost:1234/foo/bar/../baz", - "type": "integer" - } - } - }, - "valid": true - }, - { - "description": "Unnormalized identifier with empty fragment", - "data": { - "$ref": "http://localhost:1234/foo/baz", - "$defs": { - "A": { - "$id": "http://localhost:1234/foo/bar/../baz#", - "type": "integer" - } - } - }, - "valid": true - }, - { - "description": "Unnormalized identifier with empty fragment and no ref", - "data": { - "$defs": { - "A": { - "$id": "http://localhost:1234/foo/bar/../baz#", - "type": "integer" - } - } - }, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/if-then-else.json b/src/test/resources/tck/draft2019-09/if-then-else.json deleted file mode 100644 index 485367bb..00000000 --- a/src/test/resources/tck/draft2019-09/if-then-else.json +++ /dev/null @@ -1,236 +0,0 @@ -[ - { - "description": "ignore if without then or else", - "schema": { - "if": { - "const": 0 - } - }, - "tests": [ - { - "description": "valid when valid against lone if", - "data": 0, - "valid": true - }, - { - "description": "valid when invalid against lone if", - "data": "hello", - "valid": true - } - ] - }, - { - "description": "ignore then without if", - "schema": { - "then": { - "const": 0 - } - }, - "tests": [ - { - "description": "valid when valid against lone then", - "data": 0, - "valid": true - }, - { - "description": "valid when invalid against lone then", - "data": "hello", - "valid": true - } - ] - }, - { - "description": "ignore else without if", - "schema": { - "else": { - "const": 0 - } - }, - "tests": [ - { - "description": "valid when valid against lone else", - "data": 0, - "valid": true - }, - { - "description": "valid when invalid against lone else", - "data": "hello", - "valid": true - } - ] - }, - { - "description": "if and then without else", - "schema": { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - } - }, - "tests": [ - { - "description": "valid through then", - "data": -1, - "valid": true - }, - { - "description": "invalid through then", - "data": -100, - "valid": false - }, - { - "description": "valid when if test fails", - "data": 3, - "valid": true - } - ] - }, - { - "description": "if and else without then", - "schema": { - "if": { - "exclusiveMaximum": 0 - }, - "else": { - "multipleOf": 2 - } - }, - "tests": [ - { - "description": "valid when if test passes", - "data": -1, - "valid": true - }, - { - "description": "valid through else", - "data": 4, - "valid": true - }, - { - "description": "invalid through else", - "data": 3, - "valid": false - } - ] - }, - { - "description": "validate against correct branch, then vs else", - "schema": { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - }, - "else": { - "multipleOf": 2 - } - }, - "tests": [ - { - "description": "valid through then", - "data": -1, - "valid": true - }, - { - "description": "invalid through then", - "data": -100, - "valid": false - }, - { - "description": "valid through else", - "data": 4, - "valid": true - }, - { - "description": "invalid through else", - "data": 3, - "valid": false - } - ] - }, - { - "description": "non-interference across combined schemas", - "schema": { - "allOf": [ - { - "if": { - "exclusiveMaximum": 0 - } - }, - { - "then": { - "minimum": -10 - } - }, - { - "else": { - "multipleOf": 2 - } - } - ] - }, - "tests": [ - { - "description": "valid, but would have been invalid through then", - "data": -100, - "valid": true - }, - { - "description": "valid, but would have been invalid through else", - "data": 3, - "valid": true - } - ] - }, - { - "description": "if with boolean schema true", - "schema": { - "if": true, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - }, - "tests": [ - { - "description": "boolean schema true in if always chooses the then path (valid)", - "data": "then", - "valid": true - }, - { - "description": "boolean schema true in if always chooses the then path (invalid)", - "data": "else", - "valid": false - } - ] - }, - { - "description": "if with boolean schema false", - "schema": { - "if": false, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - }, - "tests": [ - { - "description": "boolean schema false in if always chooses the else path (invalid)", - "data": "then", - "valid": false - }, - { - "description": "boolean schema false in if always chooses the else path (valid)", - "data": "else", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/items.json b/src/test/resources/tck/draft2019-09/items.json deleted file mode 100644 index b84adac5..00000000 --- a/src/test/resources/tck/draft2019-09/items.json +++ /dev/null @@ -1,506 +0,0 @@ -[ - { - "description": "a schema given for items", - "schema": { - "items": { - "type": "integer" - } - }, - "tests": [ - { - "description": "valid items", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "wrong type of items", - "data": [ - 1, - "x" - ], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": { - "foo": "bar" - }, - "valid": true - }, - { - "description": "JavaScript pseudo-array is valid", - "data": { - "0": "invalid", - "length": 1 - }, - "valid": true - } - ] - }, - { - "description": "an array of schemas for items", - "schema": { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - }, - "tests": [ - { - "description": "correct types", - "data": [ - 1, - "foo" - ], - "valid": true - }, - { - "description": "wrong types", - "data": [ - "foo", - 1 - ], - "valid": false - }, - { - "description": "incomplete array of items", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "array with additional items", - "data": [ - 1, - "foo", - true - ], - "valid": true - }, - { - "description": "empty array", - "data": [], - "valid": true - }, - { - "description": "JavaScript pseudo-array is valid", - "data": { - "0": "invalid", - "1": "valid", - "length": 2 - }, - "valid": true - } - ] - }, - { - "description": "items with boolean schema (true)", - "schema": { - "items": true - }, - "tests": [ - { - "description": "any array is valid", - "data": [ - 1, - "foo", - true - ], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "items with boolean schema (false)", - "schema": { - "items": false - }, - "tests": [ - { - "description": "any non-empty array is invalid", - "data": [ - 1, - "foo", - true - ], - "valid": false - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "items with boolean schemas", - "schema": { - "items": [ - true, - false - ] - }, - "tests": [ - { - "description": "array with one item is valid", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "array with two items is invalid", - "data": [ - 1, - "foo" - ], - "valid": false - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "items and subitems", - "schema": { - "$defs": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "$ref": "#/$defs/sub-item" - }, - { - "$ref": "#/$defs/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "$ref": "#/$defs/item" - }, - { - "$ref": "#/$defs/item" - }, - { - "$ref": "#/$defs/item" - } - ] - }, - "tests": [ - { - "description": "valid items", - "data": [ - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": true - }, - { - "description": "too many items", - "data": [ - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "too many sub-items", - "data": [ - [ - { - "foo": null - }, - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "wrong item", - "data": [ - { - "foo": null - }, - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "wrong sub-item", - "data": [ - [ - {}, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "fewer items is valid", - "data": [ - [ - { - "foo": null - } - ], - [ - { - "foo": null - } - ] - ], - "valid": true - } - ] - }, - { - "description": "nested items", - "schema": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "number" - } - } - } - } - }, - "tests": [ - { - "description": "valid nested array", - "data": [ - [ - [ - [ - 1 - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - [ - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - ], - "valid": true - }, - { - "description": "nested array with invalid type", - "data": [ - [ - [ - [ - "1" - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - [ - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - ], - "valid": false - }, - { - "description": "not deep enough", - "data": [ - [ - [ - 1 - ], - [ - 2 - ], - [ - 3 - ] - ], - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/maxContains.json b/src/test/resources/tck/draft2019-09/maxContains.json deleted file mode 100644 index a7821d5a..00000000 --- a/src/test/resources/tck/draft2019-09/maxContains.json +++ /dev/null @@ -1,108 +0,0 @@ -[ - { - "description": "maxContains without contains is ignored", - "schema": { - "maxContains": 1 - }, - "tests": [ - { - "description": "one item valid against lone maxContains", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "two items still valid against lone maxContains", - "data": [ - 1, - 2 - ], - "valid": true - } - ] - }, - { - "description": "maxContains with contains", - "schema": { - "contains": { - "const": 1 - }, - "maxContains": 1 - }, - "tests": [ - { - "description": "empty data", - "data": [], - "valid": false - }, - { - "description": "all elements match, valid maxContains", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "all elements match, invalid maxContains", - "data": [ - 1, - 1 - ], - "valid": false - }, - { - "description": "some elements match, valid maxContains", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "some elements match, invalid maxContains", - "data": [ - 1, - 2, - 1 - ], - "valid": false - } - ] - }, - { - "description": "minContains < maxContains", - "schema": { - "contains": { - "const": 1 - }, - "minContains": 1, - "maxContains": 3 - }, - "tests": [ - { - "description": "actual < minContains < maxContains", - "data": [], - "valid": false - }, - { - "description": "minContains < actual < maxContains", - "data": [ - 1, - 1 - ], - "valid": true - }, - { - "description": "minContains < maxContains < actual", - "data": [ - 1, - 1, - 1, - 1 - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/maxItems.json b/src/test/resources/tck/draft2019-09/maxItems.json deleted file mode 100644 index 52f0f2a8..00000000 --- a/src/test/resources/tck/draft2019-09/maxItems.json +++ /dev/null @@ -1,39 +0,0 @@ -[ - { - "description": "maxItems validation", - "schema": { - "maxItems": 2 - }, - "tests": [ - { - "description": "shorter is valid", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "exact length is valid", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "too long is invalid", - "data": [ - 1, - 2, - 3 - ], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": "foobar", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/maxLength.json b/src/test/resources/tck/draft2019-09/maxLength.json deleted file mode 100644 index f297da02..00000000 --- a/src/test/resources/tck/draft2019-09/maxLength.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - { - "description": "maxLength validation", - "schema": { - "maxLength": 2 - }, - "tests": [ - { - "description": "shorter is valid", - "data": "f", - "valid": true - }, - { - "description": "exact length is valid", - "data": "fo", - "valid": true - }, - { - "description": "too long is invalid", - "data": "foo", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - }, - { - "description": "two supplementary Unicode code points is long enough", - "data": "\uD83D\uDCA9\uD83D\uDCA9", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/maxProperties.json b/src/test/resources/tck/draft2019-09/maxProperties.json deleted file mode 100644 index 13b79b48..00000000 --- a/src/test/resources/tck/draft2019-09/maxProperties.json +++ /dev/null @@ -1,73 +0,0 @@ -[ - { - "description": "maxProperties validation", - "schema": { - "maxProperties": 2 - }, - "tests": [ - { - "description": "shorter is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "exact length is valid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "too long is invalid", - "data": { - "foo": 1, - "bar": 2, - "baz": 3 - }, - "valid": false - }, - { - "description": "ignores arrays", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "maxProperties = 0 means the object is empty", - "schema": { - "maxProperties": 0 - }, - "tests": [ - { - "description": "no properties is valid", - "data": {}, - "valid": true - }, - { - "description": "one property is invalid", - "data": { - "foo": 1 - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/maximum.json b/src/test/resources/tck/draft2019-09/maximum.json deleted file mode 100644 index 65df7aec..00000000 --- a/src/test/resources/tck/draft2019-09/maximum.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "description": "maximum validation", - "schema": { - "maximum": 3.0 - }, - "tests": [ - { - "description": "below the maximum is valid", - "data": 2.6, - "valid": true - }, - { - "description": "boundary point is valid", - "data": 3.0, - "valid": true - }, - { - "description": "above the maximum is invalid", - "data": 3.5, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - }, - { - "description": "maximum validation with unsigned integer", - "schema": { - "maximum": 300 - }, - "tests": [ - { - "description": "below the maximum is invalid", - "data": 299.97, - "valid": true - }, - { - "description": "boundary point integer is valid", - "data": 300, - "valid": true - }, - { - "description": "boundary point float is valid", - "data": 300.00, - "valid": true - }, - { - "description": "above the maximum is invalid", - "data": 300.5, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/minContains.json b/src/test/resources/tck/draft2019-09/minContains.json deleted file mode 100644 index 1b006a59..00000000 --- a/src/test/resources/tck/draft2019-09/minContains.json +++ /dev/null @@ -1,230 +0,0 @@ -[ - { - "description": "minContains without contains is ignored", - "schema": { - "minContains": 1 - }, - "tests": [ - { - "description": "one item valid against lone minContains", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "zero items still valid against lone minContains", - "data": [], - "valid": true - } - ] - }, - { - "description": "minContains=1 with contains", - "schema": { - "contains": { - "const": 1 - }, - "minContains": 1 - }, - "tests": [ - { - "description": "empty data", - "data": [], - "valid": false - }, - { - "description": "no elements match", - "data": [ - 2 - ], - "valid": false - }, - { - "description": "single element matches, valid minContains", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "some elements match, valid minContains", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "all elements match, valid minContains", - "data": [ - 1, - 1 - ], - "valid": true - } - ] - }, - { - "description": "minContains=2 with contains", - "schema": { - "contains": { - "const": 1 - }, - "minContains": 2 - }, - "tests": [ - { - "description": "empty data", - "data": [], - "valid": false - }, - { - "description": "all elements match, invalid minContains", - "data": [ - 1 - ], - "valid": false - }, - { - "description": "some elements match, invalid minContains", - "data": [ - 1, - 2 - ], - "valid": false - }, - { - "description": "all elements match, valid minContains (exactly as needed)", - "data": [ - 1, - 1 - ], - "valid": true - }, - { - "description": "all elements match, valid minContains (more than needed)", - "data": [ - 1, - 1, - 1 - ], - "valid": true - }, - { - "description": "some elements match, valid minContains", - "data": [ - 1, - 2, - 1 - ], - "valid": true - } - ] - }, - { - "description": "maxContains = minContains", - "schema": { - "contains": { - "const": 1 - }, - "maxContains": 2, - "minContains": 2 - }, - "tests": [ - { - "description": "empty data", - "data": [], - "valid": false - }, - { - "description": "all elements match, invalid minContains", - "data": [ - 1 - ], - "valid": false - }, - { - "description": "all elements match, invalid maxContains", - "data": [ - 1, - 1, - 1 - ], - "valid": false - }, - { - "description": "all elements match, valid maxContains and minContains", - "data": [ - 1, - 1 - ], - "valid": true - } - ] - }, - { - "description": "maxContains < minContains", - "schema": { - "contains": { - "const": 1 - }, - "maxContains": 1, - "minContains": 3 - }, - "tests": [ - { - "description": "empty data", - "data": [], - "valid": false - }, - { - "description": "invalid minContains", - "data": [ - 1 - ], - "valid": false - }, - { - "description": "invalid maxContains", - "data": [ - 1, - 1, - 1 - ], - "valid": false - }, - { - "description": "invalid maxContains and minContains", - "data": [ - 1, - 1 - ], - "valid": false - } - ] - }, - { - "description": "minContains = 0", - "schema": { - "contains": { - "const": 1 - }, - "minContains": 0 - }, - "tests": [ - { - "description": "empty data", - "data": [], - "valid": true - }, - { - "description": "minContains = 0 makes contains always pass", - "data": [ - 2 - ], - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/minItems.json b/src/test/resources/tck/draft2019-09/minItems.json deleted file mode 100644 index 8a89e7ae..00000000 --- a/src/test/resources/tck/draft2019-09/minItems.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - { - "description": "minItems validation", - "schema": { - "minItems": 1 - }, - "tests": [ - { - "description": "longer is valid", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "exact length is valid", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "too short is invalid", - "data": [], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": "", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/minLength.json b/src/test/resources/tck/draft2019-09/minLength.json deleted file mode 100644 index ee310f82..00000000 --- a/src/test/resources/tck/draft2019-09/minLength.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - { - "description": "minLength validation", - "schema": { - "minLength": 2 - }, - "tests": [ - { - "description": "longer is valid", - "data": "foo", - "valid": true - }, - { - "description": "exact length is valid", - "data": "fo", - "valid": true - }, - { - "description": "too short is invalid", - "data": "f", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 1, - "valid": true - }, - { - "description": "one supplementary Unicode code point is not long enough", - "data": "\uD83D\uDCA9", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/minProperties.json b/src/test/resources/tck/draft2019-09/minProperties.json deleted file mode 100644 index c700fe42..00000000 --- a/src/test/resources/tck/draft2019-09/minProperties.json +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "description": "minProperties validation", - "schema": { - "minProperties": 1 - }, - "tests": [ - { - "description": "longer is valid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "exact length is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "too short is invalid", - "data": {}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores strings", - "data": "", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/minimum.json b/src/test/resources/tck/draft2019-09/minimum.json deleted file mode 100644 index 3e04adc3..00000000 --- a/src/test/resources/tck/draft2019-09/minimum.json +++ /dev/null @@ -1,73 +0,0 @@ -[ - { - "description": "minimum validation", - "schema": { - "minimum": 1.1 - }, - "tests": [ - { - "description": "above the minimum is valid", - "data": 2.6, - "valid": true - }, - { - "description": "boundary point is valid", - "data": 1.1, - "valid": true - }, - { - "description": "below the minimum is invalid", - "data": 0.6, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - }, - { - "description": "minimum validation with signed integer", - "schema": { - "minimum": -2 - }, - "tests": [ - { - "description": "negative above the minimum is valid", - "data": -1, - "valid": true - }, - { - "description": "positive above the minimum is valid", - "data": 0, - "valid": true - }, - { - "description": "boundary point is valid", - "data": -2, - "valid": true - }, - { - "description": "boundary point with float is valid", - "data": -2.0, - "valid": true - }, - { - "description": "float below the minimum is invalid", - "data": -2.0001, - "valid": false - }, - { - "description": "int below the minimum is invalid", - "data": -3, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/multipleOf.json b/src/test/resources/tck/draft2019-09/multipleOf.json deleted file mode 100644 index 656d30f1..00000000 --- a/src/test/resources/tck/draft2019-09/multipleOf.json +++ /dev/null @@ -1,48 +0,0 @@ -[ - { - "description": "by int", - "schema": { - "multipleOf": 2 - }, - "tests": [ - { - "description": "int by int", - "data": 10, - "valid": true - }, - { - "description": "int by int fail", - "data": 7, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "by number", - "schema": { - "multipleOf": 1.5 - }, - "tests": [ - { - "description": "zero is multiple of anything", - "data": 0, - "valid": true - }, - { - "description": "4.5 is multiple of 1.5", - "data": 4.5, - "valid": true - }, - { - "description": "35 is not multiple of 1.5", - "data": 35, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/not.json b/src/test/resources/tck/draft2019-09/not.json deleted file mode 100644 index c2d2e411..00000000 --- a/src/test/resources/tck/draft2019-09/not.json +++ /dev/null @@ -1,138 +0,0 @@ -[ - { - "description": "not", - "schema": { - "not": { - "type": "integer" - } - }, - "tests": [ - { - "description": "allowed", - "data": "foo", - "valid": true - }, - { - "description": "disallowed", - "data": 1, - "valid": false - } - ] - }, - { - "description": "not multiple types", - "schema": { - "not": { - "type": [ - "integer", - "boolean" - ] - } - }, - "tests": [ - { - "description": "valid", - "data": "foo", - "valid": true - }, - { - "description": "mismatch", - "data": 1, - "valid": false - }, - { - "description": "other mismatch", - "data": true, - "valid": false - } - ] - }, - { - "description": "not more complex schema", - "schema": { - "not": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - }, - "tests": [ - { - "description": "match", - "data": 1, - "valid": true - }, - { - "description": "other match", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "mismatch", - "data": { - "foo": "bar" - }, - "valid": false - } - ] - }, - { - "description": "forbidden property", - "schema": { - "properties": { - "foo": { - "not": {} - } - } - }, - "tests": [ - { - "description": "property present", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": false - }, - { - "description": "property absent", - "data": { - "bar": 1, - "baz": 2 - }, - "valid": true - } - ] - }, - { - "description": "not with boolean schema true", - "schema": { - "not": true - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "not with boolean schema false", - "schema": { - "not": false - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/oneOf.json b/src/test/resources/tck/draft2019-09/oneOf.json deleted file mode 100644 index a3f1e1d2..00000000 --- a/src/test/resources/tck/draft2019-09/oneOf.json +++ /dev/null @@ -1,353 +0,0 @@ -[ - { - "description": "oneOf", - "schema": { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - }, - "tests": [ - { - "description": "first oneOf valid", - "data": 1, - "valid": true - }, - { - "description": "second oneOf valid", - "data": 2.5, - "valid": true - }, - { - "description": "both oneOf valid", - "data": 3, - "valid": false - }, - { - "description": "neither oneOf valid", - "data": 1.5, - "valid": false - } - ] - }, - { - "description": "oneOf with base schema", - "schema": { - "type": "string", - "oneOf": [ - { - "minLength": 2 - }, - { - "maxLength": 4 - } - ] - }, - "tests": [ - { - "description": "mismatch base schema", - "data": 3, - "valid": false - }, - { - "description": "one oneOf valid", - "data": "foobar", - "valid": true - }, - { - "description": "both oneOf valid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf with boolean schemas, all true", - "schema": { - "oneOf": [ - true, - true, - true - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf with boolean schemas, one true", - "schema": { - "oneOf": [ - true, - false, - false - ] - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "oneOf with boolean schemas, more than one true", - "schema": { - "oneOf": [ - true, - true, - false - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf with boolean schemas, all false", - "schema": { - "oneOf": [ - false, - false, - false - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf complex types", - "schema": { - "oneOf": [ - { - "properties": { - "bar": { - "type": "integer" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": { - "type": "string" - } - }, - "required": [ - "foo" - ] - } - ] - }, - "tests": [ - { - "description": "first oneOf valid (complex)", - "data": { - "bar": 2 - }, - "valid": true - }, - { - "description": "second oneOf valid (complex)", - "data": { - "foo": "baz" - }, - "valid": true - }, - { - "description": "both oneOf valid (complex)", - "data": { - "foo": "baz", - "bar": 2 - }, - "valid": false - }, - { - "description": "neither oneOf valid (complex)", - "data": { - "foo": 2, - "bar": "quux" - }, - "valid": false - } - ] - }, - { - "description": "oneOf with empty schema", - "schema": { - "oneOf": [ - { - "type": "number" - }, - {} - ] - }, - "tests": [ - { - "description": "one valid - valid", - "data": "foo", - "valid": true - }, - { - "description": "both valid - invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "oneOf with required", - "schema": { - "type": "object", - "oneOf": [ - { - "required": [ - "foo", - "bar" - ] - }, - { - "required": [ - "foo", - "baz" - ] - } - ] - }, - "tests": [ - { - "description": "both invalid - invalid", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "first valid - valid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "second valid - valid", - "data": { - "foo": 1, - "baz": 3 - }, - "valid": true - }, - { - "description": "both valid - invalid", - "data": { - "foo": 1, - "bar": 2, - "baz": 3 - }, - "valid": false - } - ] - }, - { - "description": "oneOf with missing optional property", - "schema": { - "oneOf": [ - { - "properties": { - "bar": true, - "baz": true - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": true - }, - "required": [ - "foo" - ] - } - ] - }, - "tests": [ - { - "description": "first oneOf valid", - "data": { - "bar": 8 - }, - "valid": true - }, - { - "description": "second oneOf valid", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "both oneOf valid", - "data": { - "foo": "foo", - "bar": 8 - }, - "valid": false - }, - { - "description": "neither oneOf valid", - "data": { - "baz": "quux" - }, - "valid": false - } - ] - }, - { - "description": "nested oneOf, to check validation semantics", - "schema": { - "oneOf": [ - { - "oneOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/bignum.json b/src/test/resources/tck/draft2019-09/optional/bignum.json deleted file mode 100644 index 4e5bafdf..00000000 --- a/src/test/resources/tck/draft2019-09/optional/bignum.json +++ /dev/null @@ -1,119 +0,0 @@ -[ - { - "description": "integer", - "schema": { - "type": "integer" - }, - "tests": [ - { - "description": "a bignum is an integer", - "data": 12345678910111213141516171819202122232425262728293031, - "valid": true - } - ] - }, - { - "description": "number", - "schema": { - "type": "number" - }, - "tests": [ - { - "description": "a bignum is a number", - "data": 98249283749234923498293171823948729348710298301928331, - "valid": true - } - ] - }, - { - "description": "integer", - "schema": { - "type": "integer" - }, - "tests": [ - { - "description": "a negative bignum is an integer", - "data": -12345678910111213141516171819202122232425262728293031, - "valid": true - } - ] - }, - { - "description": "number", - "schema": { - "type": "number" - }, - "tests": [ - { - "description": "a negative bignum is a number", - "data": -98249283749234923498293171823948729348710298301928331, - "valid": true - } - ] - }, - { - "description": "string", - "schema": { - "type": "string" - }, - "tests": [ - { - "description": "a bignum is not a string", - "data": 98249283749234923498293171823948729348710298301928331, - "valid": false - } - ] - }, - { - "description": "integer comparison", - "schema": { - "maximum": 18446744073709551615 - }, - "tests": [ - { - "description": "comparison works for high numbers", - "data": 18446744073709551600, - "valid": true - } - ] - }, - { - "description": "float comparison with high precision", - "schema": { - "exclusiveMaximum": 972783798187987123879878123.18878137 - }, - "tests": [ - { - "description": "comparison works for high numbers", - "data": 972783798187987123879878123.188781371, - "valid": false - } - ] - }, - { - "description": "integer comparison", - "schema": { - "minimum": -18446744073709551615 - }, - "tests": [ - { - "description": "comparison works for very negative numbers", - "data": -18446744073709551600, - "valid": true - } - ] - }, - { - "description": "float comparison with high precision on negative numbers", - "schema": { - "exclusiveMinimum": -972783798187987123879878123.18878137 - }, - "tests": [ - { - "description": "comparison works for very negative numbers", - "data": -972783798187987123879878123.188781371, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/content.json b/src/test/resources/tck/draft2019-09/optional/content.json deleted file mode 100644 index 0efc737a..00000000 --- a/src/test/resources/tck/draft2019-09/optional/content.json +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "description": "validation of string-encoded content based on media type", - "schema": { - "contentMediaType": "application/json" - }, - "tests": [ - { - "description": "a valid JSON document", - "data": "{\"foo\": \"bar\"}", - "valid": true - }, - { - "description": "an invalid JSON document", - "data": "{:}", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - } - ] - }, - { - "description": "validation of binary string-encoding", - "schema": { - "contentEncoding": "base64" - }, - "tests": [ - { - "description": "a valid base64 string", - "data": "eyJmb28iOiAiYmFyIn0K", - "valid": true - }, - { - "description": "an invalid base64 string (% is not a valid character)", - "data": "eyJmb28iOi%iYmFyIn0K", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - } - ] - }, - { - "description": "validation of binary-encoded media type documents", - "schema": { - "contentMediaType": "application/json", - "contentEncoding": "base64" - }, - "tests": [ - { - "description": "a valid base64-encoded JSON document", - "data": "eyJmb28iOiAiYmFyIn0K", - "valid": true - }, - { - "description": "a validly-encoded invalid JSON document", - "data": "ezp9Cg==", - "valid": false - }, - { - "description": "an invalid base64 string that is valid JSON", - "data": "{}", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/ecmascript-regex.json b/src/test/resources/tck/draft2019-09/optional/ecmascript-regex.json deleted file mode 100644 index f1a5150f..00000000 --- a/src/test/resources/tck/draft2019-09/optional/ecmascript-regex.json +++ /dev/null @@ -1,305 +0,0 @@ -[ - { - "description": "ECMA 262 regex non-compliance", - "schema": { - "format": "regex" - }, - "tests": [ - { - "description": "ECMA 262 has no support for \\Z anchor from .NET", - "data": "^\\S(|(.|\\n)*\\S)\\Z", - "valid": false - } - ] - }, - { - "description": "ECMA 262 regex $ does not match trailing newline", - "schema": { - "type": "string", - "pattern": "^abc$" - }, - "tests": [ - { - "description": "matches in Python, but should not in jsonschema", - "data": "abc\n", - "valid": false - }, - { - "description": "should match", - "data": "abc", - "valid": true - } - ] - }, - { - "description": "ECMA 262 regex converts \\t to horizontal tab", - "schema": { - "type": "string", - "pattern": "^\\t$" - }, - "tests": [ - { - "description": "does not match", - "data": "\\t", - "valid": false - }, - { - "description": "matches", - "data": "\u0009", - "valid": true - } - ] - }, - { - "description": "ECMA 262 regex escapes control codes with \\c and upper letter", - "schema": { - "type": "string", - "pattern": "^\\cC$" - }, - "tests": [ - { - "description": "does not match", - "data": "\\cC", - "valid": false - }, - { - "description": "matches", - "data": "\u0003", - "valid": true - } - ] - }, - { - "description": "ECMA 262 regex escapes control codes with \\c and lower letter", - "schema": { - "type": "string", - "pattern": "^\\cc$" - }, - "tests": [ - { - "description": "does not match", - "data": "\\cc", - "valid": false - }, - { - "description": "matches", - "data": "\u0003", - "valid": true - } - ] - }, - { - "description": "ECMA 262 \\d matches ascii digits only", - "schema": { - "type": "string", - "pattern": "^\\d$" - }, - "tests": [ - { - "description": "ASCII zero matches", - "data": "0", - "valid": true - }, - { - "description": "NKO DIGIT ZERO does not match (unlike e.g. Python)", - "data": "߀", - "valid": false - }, - { - "description": "NKO DIGIT ZERO (as \\u escape) does not match", - "data": "\u07c0", - "valid": false - } - ] - }, - { - "description": "ECMA 262 \\D matches everything but ascii digits", - "schema": { - "type": "string", - "pattern": "^\\D$" - }, - "tests": [ - { - "description": "ASCII zero does not match", - "data": "0", - "valid": false - }, - { - "description": "NKO DIGIT ZERO matches (unlike e.g. Python)", - "data": "߀", - "valid": true - }, - { - "description": "NKO DIGIT ZERO (as \\u escape) matches", - "data": "\u07c0", - "valid": true - } - ] - }, - { - "description": "ECMA 262 \\w matches ascii letters only", - "schema": { - "type": "string", - "pattern": "^\\w$" - }, - "tests": [ - { - "description": "ASCII 'a' matches", - "data": "a", - "valid": true - }, - { - "description": "latin-1 e-acute does not match (unlike e.g. Python)", - "data": "é", - "valid": false - } - ] - }, - { - "description": "ECMA 262 \\W matches everything but ascii letters", - "schema": { - "type": "string", - "pattern": "^\\W$" - }, - "tests": [ - { - "description": "ASCII 'a' does not match", - "data": "a", - "valid": false - }, - { - "description": "latin-1 e-acute matches (unlike e.g. Python)", - "data": "é", - "valid": true - } - ] - }, - { - "description": "ECMA 262 \\s matches whitespace", - "schema": { - "type": "string", - "pattern": "^\\s$" - }, - "tests": [ - { - "description": "ASCII space matches", - "data": " ", - "valid": true - }, - { - "description": "Character tabulation matches", - "data": "\t", - "valid": true - }, - { - "description": "Line tabulation matches", - "data": "\u000b", - "valid": true - }, - { - "description": "Form feed matches", - "data": "\u000c", - "valid": true - }, - { - "description": "latin-1 non-breaking-space matches", - "data": "\u00a0", - "valid": true - }, - { - "description": "zero-width whitespace matches", - "data": "\ufeff", - "valid": true - }, - { - "description": "line feed matches (line terminator)", - "data": "\u000a", - "valid": true - }, - { - "description": "paragraph separator matches (line terminator)", - "data": "\u2029", - "valid": true - }, - { - "description": "EM SPACE matches (Space_Separator)", - "data": "\u2003", - "valid": true - }, - { - "description": "Non-whitespace control does not match", - "data": "\u0001", - "valid": false - }, - { - "description": "Non-whitespace does not match", - "data": "\u2013", - "valid": false - } - ] - }, - { - "description": "ECMA 262 \\S matches everything but whitespace", - "schema": { - "type": "string", - "pattern": "^\\S$" - }, - "tests": [ - { - "description": "ASCII space does not match", - "data": " ", - "valid": false - }, - { - "description": "Character tabulation does not match", - "data": "\t", - "valid": false - }, - { - "description": "Line tabulation does not match", - "data": "\u000b", - "valid": false - }, - { - "description": "Form feed does not match", - "data": "\u000c", - "valid": false - }, - { - "description": "latin-1 non-breaking-space does not match", - "data": "\u00a0", - "valid": false - }, - { - "description": "zero-width whitespace does not match", - "data": "\ufeff", - "valid": false - }, - { - "description": "line feed does not match (line terminator)", - "data": "\u000a", - "valid": false - }, - { - "description": "paragraph separator does not match (line terminator)", - "data": "\u2029", - "valid": false - }, - { - "description": "EM SPACE does not match (Space_Separator)", - "data": "\u2003", - "valid": false - }, - { - "description": "Non-whitespace control matches", - "data": "\u0001", - "valid": true - }, - { - "description": "Non-whitespace matches", - "data": "\u2013", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/date-time.json b/src/test/resources/tck/draft2019-09/optional/format/date-time.json deleted file mode 100644 index b5c89636..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/date-time.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "description": "validation of date-time strings", - "schema": { - "format": "date-time" - }, - "tests": [ - { - "description": "a valid date-time string", - "data": "1963-06-19T08:30:06.283185Z", - "valid": true - }, - { - "description": "a valid date-time string without second fraction", - "data": "1963-06-19T08:30:06Z", - "valid": true - }, - { - "description": "a valid date-time string with plus offset", - "data": "1937-01-01T12:00:27.87+00:20", - "valid": true - }, - { - "description": "a valid date-time string with minus offset", - "data": "1990-12-31T15:59:50.123-08:00", - "valid": true - }, - { - "description": "a invalid day in date-time string", - "data": "1990-02-31T15:59:60.123-08:00", - "valid": false - }, - { - "description": "an invalid offset in date-time string", - "data": "1990-12-31T15:59:60-24:00", - "valid": false - }, - { - "description": "an invalid date-time string", - "data": "06/19/1963 08:30:06 PST", - "valid": false - }, - { - "description": "case-insensitive T and Z", - "data": "1963-06-19t08:30:06.283185z", - "valid": true - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "2013-350T01:01:01", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/date.json b/src/test/resources/tck/draft2019-09/optional/format/date.json deleted file mode 100644 index 39c66593..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/date.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "description": "validation of date strings", - "schema": { - "format": "date" - }, - "tests": [ - { - "description": "a valid date string", - "data": "1963-06-19", - "valid": true - }, - { - "description": "an invalid date-time string", - "data": "06/19/1963", - "valid": false - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "2013-350", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/duration.json b/src/test/resources/tck/draft2019-09/optional/format/duration.json deleted file mode 100644 index a547a2d1..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/duration.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "description": "validation of duration strings", - "schema": { - "format": "duration" - }, - "tests": [ - { - "description": "a valid duration string", - "data": "P4DT12H30M5S", - "valid": true - }, - { - "description": "an invalid duration string", - "data": "PT1D", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/email.json b/src/test/resources/tck/draft2019-09/optional/format/email.json deleted file mode 100644 index bc592528..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/email.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "description": "validation of e-mail addresses", - "schema": { - "format": "email" - }, - "tests": [ - { - "description": "a valid e-mail address", - "data": "joe.bloggs@example.com", - "valid": true - }, - { - "description": "an invalid e-mail address", - "data": "2962", - "valid": false - }, - { - "description": "tilde in local part is valid", - "data": "te~st@example.com", - "valid": true - }, - { - "description": "tilde before local part is valid", - "data": "~test@example.com", - "valid": true - }, - { - "description": "tilde after local part is valid", - "data": "test~@example.com", - "valid": true - }, - { - "description": "dot before local part is not valid", - "data": ".test@example.com", - "valid": false - }, - { - "description": "dot after local part is not valid", - "data": "test.@example.com", - "valid": false - }, - { - "description": "two separated dots inside local part are valid", - "data": "te.s.t@example.com", - "valid": true - }, - { - "description": "two subsequent dots inside local part are not valid", - "data": "te..st@example.com", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/hostname.json b/src/test/resources/tck/draft2019-09/optional/format/hostname.json deleted file mode 100644 index 6ab500c5..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/hostname.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "description": "validation of host names", - "schema": { - "format": "hostname" - }, - "tests": [ - { - "description": "a valid host name", - "data": "www.example.com", - "valid": true - }, - { - "description": "a valid punycoded IDN hostname", - "data": "xn--4gbwdl.xn--wgbh1c", - "valid": true - }, - { - "description": "a host name starting with an illegal character", - "data": "-a-host-name-that-starts-with--", - "valid": false - }, - { - "description": "a host name containing illegal characters", - "data": "not_a_valid_host_name", - "valid": false - }, - { - "description": "a host name with a component too long", - "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", - "valid": false - }, - { - "description": "starts with hyphen", - "data": "-hostname", - "valid": false - }, - { - "description": "ends with hyphen", - "data": "hostname-", - "valid": false - }, - { - "description": "starts with underscore", - "data": "_hostname", - "valid": false - }, - { - "description": "ends with underscore", - "data": "hostname_", - "valid": false - }, - { - "description": "contains underscore", - "data": "host_name", - "valid": false - }, - { - "description": "maximum label length", - "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com", - "valid": true - }, - { - "description": "exceeds maximum label length", - "data": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl.com", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/idn-email.json b/src/test/resources/tck/draft2019-09/optional/format/idn-email.json deleted file mode 100644 index e8727fb6..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/idn-email.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "validation of an internationalized e-mail addresses", - "schema": { - "format": "idn-email" - }, - "tests": [ - { - "description": "a valid idn e-mail (example@example.test in Hangul)", - "data": "실례@실례.테스트", - "valid": true - }, - { - "description": "an invalid idn e-mail address", - "data": "2962", - "valid": false - }, - { - "description": "a valid e-mail address", - "data": "joe.bloggs@example.com", - "valid": true - }, - { - "description": "an invalid e-mail address", - "data": "2962", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/idn-hostname.json b/src/test/resources/tck/draft2019-09/optional/format/idn-hostname.json deleted file mode 100644 index 6ad898c6..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/idn-hostname.json +++ /dev/null @@ -1,276 +0,0 @@ -[ - { - "description": "validation of internationalized host names", - "schema": { - "format": "idn-hostname" - }, - "tests": [ - { - "description": "a valid host name (example.test in Hangul)", - "data": "실례.테스트", - "valid": true - }, - { - "description": "illegal first char U+302E Hangul single dot tone mark", - "data": "〮실례.테스트", - "valid": false - }, - { - "description": "contains illegal char U+302E Hangul single dot tone mark", - "data": "실〮례.테스트", - "valid": false - }, - { - "description": "a host name with a component too long", - "data": "실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실례례테스트례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례테스트례례실례.테스트", - "valid": false - }, - { - "description": "invalid label, correct Punycode", - "comment": "https://tools.ietf.org/html/rfc5890#section-2.3.2.1 https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc3492#section-7.1", - "data": "-> $1.00 <--", - "valid": false - }, - { - "description": "valid Chinese Punycode", - "comment": "https://tools.ietf.org/html/rfc5890#section-2.3.2.1 https://tools.ietf.org/html/rfc5891#section-4.4", - "data": "xn--ihqwcrb4cv8a8dqg056pqjye", - "valid": true - }, - { - "description": "invalid Punycode", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.4 https://tools.ietf.org/html/rfc5890#section-2.3.2.1", - "data": "xn--X", - "valid": false - }, - { - "description": "U-label contains \"--\" in the 3rd and 4th position", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1 https://tools.ietf.org/html/rfc5890#section-2.3.2.1", - "data": "XN--aa---o47jg78q", - "valid": false - }, - { - "description": "U-label starts with a dash", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1", - "data": "-hello", - "valid": false - }, - { - "description": "U-label ends with a dash", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1", - "data": "hello-", - "valid": false - }, - { - "description": "U-label starts and ends with a dash", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.1", - "data": "-hello-", - "valid": false - }, - { - "description": "Begins with a Spacing Combining Mark", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2", - "data": "\u0903hello", - "valid": false - }, - { - "description": "Begins with a Nonspacing Mark", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2", - "data": "\u0300hello", - "valid": false - }, - { - "description": "Begins with an Enclosing Mark", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.2", - "data": "\u0488hello", - "valid": false - }, - { - "description": "Exceptions that are PVALID, left-to-right chars", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6", - "data": "\u00df\u03c2\u0f0b\u3007", - "valid": true - }, - { - "description": "Exceptions that are PVALID, right-to-left chars", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6", - "data": "\u06fd\u06fe", - "valid": true - }, - { - "description": "Exceptions that are DISALLOWED, right-to-left chars", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6", - "data": "\u0640\u07fa", - "valid": false - }, - { - "description": "Exceptions that are DISALLOWED, left-to-right chars", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.2 https://tools.ietf.org/html/rfc5892#section-2.6 Note: The two combining marks (U+302E and U+302F) are in the middle and not at the start", - "data": "\u3031\u3032\u3033\u3034\u3035\u302e\u302f\u303b", - "valid": false - }, - { - "description": "MIDDLE DOT with no preceding 'l'", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3", - "data": "a\u00b7l", - "valid": false - }, - { - "description": "MIDDLE DOT with nothing preceding", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3", - "data": "\u00b7l", - "valid": false - }, - { - "description": "MIDDLE DOT with no following 'l'", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3", - "data": "l\u00b7a", - "valid": false - }, - { - "description": "MIDDLE DOT with nothing following", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3", - "data": "l\u00b7", - "valid": false - }, - { - "description": "MIDDLE DOT with surrounding 'l's", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.3", - "data": "l\u00b7l", - "valid": true - }, - { - "description": "Greek KERAIA not followed by Greek", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.4", - "data": "\u03b1\u0375S", - "valid": false - }, - { - "description": "Greek KERAIA not followed by anything", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.4", - "data": "\u03b1\u0375", - "valid": false - }, - { - "description": "Greek KERAIA followed by Greek", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.4", - "data": "\u03b1\u0375\u03b2", - "valid": true - }, - { - "description": "Hebrew GERESH not preceded by Hebrew", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.5", - "data": "A\u05f3\u05d1", - "valid": false - }, - { - "description": "Hebrew GERESH not preceded by anything", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.5", - "data": "\u05f3\u05d1", - "valid": false - }, - { - "description": "Hebrew GERESH preceded by Hebrew", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.5", - "data": "\u05d0\u05f3\u05d1", - "valid": true - }, - { - "description": "Hebrew GERSHAYIM not preceded by Hebrew", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.6", - "data": "A\u05f4\u05d1", - "valid": false - }, - { - "description": "Hebrew GERSHAYIM not preceded by anything", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.6", - "data": "\u05f4\u05d1", - "valid": false - }, - { - "description": "Hebrew GERSHAYIM preceded by Hebrew", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.6", - "data": "\u05d0\u05f4\u05d1", - "valid": true - }, - { - "description": "KATAKANA MIDDLE DOT with no Hiragana, Katakana, or Han", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7", - "data": "def\u30fbabc", - "valid": false - }, - { - "description": "KATAKANA MIDDLE DOT with no other characters", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7", - "data": "\u30fb", - "valid": false - }, - { - "description": "KATAKANA MIDDLE DOT with Hiragana", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7", - "data": "\u30fb\u3041", - "valid": true - }, - { - "description": "KATAKANA MIDDLE DOT with Katakana", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7", - "data": "\u30fb\u30a1", - "valid": true - }, - { - "description": "KATAKANA MIDDLE DOT with Han", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.7", - "data": "\u30fb\u4e08", - "valid": true - }, - { - "description": "Arabic-Indic digits mixed with Extended Arabic-Indic digits", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8", - "data": "\u0660\u06f0", - "valid": false - }, - { - "description": "Arabic-Indic digits not mixed with Extended Arabic-Indic digits", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.8", - "data": "\u0628\u0660\u0628", - "valid": true - }, - { - "description": "Extended Arabic-Indic digits not mixed with Arabic-Indic digits", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.9", - "data": "\u06f00", - "valid": true - }, - { - "description": "ZERO WIDTH JOINER not preceded by Virama", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.2 https://www.unicode.org/review/pr-37.pdf", - "data": "\u0915\u200d\u0937", - "valid": false - }, - { - "description": "ZERO WIDTH JOINER not preceded by anything", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.2 https://www.unicode.org/review/pr-37.pdf", - "data": "\u200d\u0937", - "valid": false - }, - { - "description": "ZERO WIDTH JOINER preceded by Virama", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.2 https://www.unicode.org/review/pr-37.pdf", - "data": "\u0915\u094d\u200d\u0937", - "valid": true - }, - { - "description": "ZERO WIDTH NON-JOINER preceded by Virama", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1", - "data": "\u0915\u094d\u200c\u0937", - "valid": true - }, - { - "description": "ZERO WIDTH NON-JOINER not preceded by Virama but matches regexp", - "comment": "https://tools.ietf.org/html/rfc5891#section-4.2.3.3 https://tools.ietf.org/html/rfc5892#appendix-A.1 https://www.w3.org/TR/alreq/#h_disjoining_enforcement", - "data": "\u0628\u064a\u200c\u0628\u064a", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/ipv4.json b/src/test/resources/tck/draft2019-09/optional/format/ipv4.json deleted file mode 100644 index e6317bae..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/ipv4.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "description": "validation of IP addresses", - "schema": { - "format": "ipv4" - }, - "tests": [ - { - "description": "a valid IP address", - "data": "192.168.0.1", - "valid": true - }, - { - "description": "an IP address with too many components", - "data": "127.0.0.0.1", - "valid": false - }, - { - "description": "an IP address with out-of-range values", - "data": "256.256.256.256", - "valid": false - }, - { - "description": "an IP address without 4 components", - "data": "127.0", - "valid": false - }, - { - "description": "an IP address as an integer", - "data": "0x7f000001", - "valid": false - }, - { - "description": "an IP address as an integer (decimal)", - "data": "2130706433", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/ipv6.json b/src/test/resources/tck/draft2019-09/optional/format/ipv6.json deleted file mode 100644 index 015ea9b1..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/ipv6.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "description": "validation of IPv6 addresses", - "schema": { - "format": "ipv6" - }, - "tests": [ - { - "description": "a valid IPv6 address", - "data": "::1", - "valid": true - }, - { - "description": "an IPv6 address with out-of-range values", - "data": "12345::", - "valid": false - }, - { - "description": "an IPv6 address with too many components", - "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", - "valid": false - }, - { - "description": "an IPv6 address containing illegal characters", - "data": "::laptop", - "valid": false - }, - { - "description": "no digits is valid", - "data": "::", - "valid": true - }, - { - "description": "leading colons is valid", - "data": "::42:ff:1", - "valid": true - }, - { - "description": "trailing colons is valid", - "data": "d6::", - "valid": true - }, - { - "description": "two sets of double colons is invalid", - "data": "1::d6::42", - "valid": false - }, - { - "description": "mixed format with the ipv4 section as decimal octets", - "data": "1::d6:192.168.0.1", - "valid": true - }, - { - "description": "mixed format with double colons between the sections", - "data": "1:2::192.168.0.1", - "valid": true - }, - { - "description": "mixed format with ipv4 section with octet out of range", - "data": "1::2:192.168.256.1", - "valid": false - }, - { - "description": "mixed format with ipv4 section with a hex octet", - "data": "1::2:192.168.ff.1", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/iri-reference.json b/src/test/resources/tck/draft2019-09/optional/format/iri-reference.json deleted file mode 100644 index a82de638..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/iri-reference.json +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "description": "validation of IRI References", - "schema": { - "format": "iri-reference" - }, - "tests": [ - { - "description": "a valid IRI", - "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", - "valid": true - }, - { - "description": "a valid protocol-relative IRI Reference", - "data": "//ƒøø.ßår/?∂éœ=πîx#πîüx", - "valid": true - }, - { - "description": "a valid relative IRI Reference", - "data": "/âππ", - "valid": true - }, - { - "description": "an invalid IRI Reference", - "data": "\\\\WINDOWS\\filëßåré", - "valid": false - }, - { - "description": "a valid IRI Reference", - "data": "âππ", - "valid": true - }, - { - "description": "a valid IRI fragment", - "data": "#ƒrägmênt", - "valid": true - }, - { - "description": "an invalid IRI fragment", - "data": "#ƒräg\\mênt", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/iri.json b/src/test/resources/tck/draft2019-09/optional/format/iri.json deleted file mode 100644 index e0e182ad..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/iri.json +++ /dev/null @@ -1,55 +0,0 @@ -[ - { - "description": "validation of IRIs", - "schema": { - "format": "iri" - }, - "tests": [ - { - "description": "a valid IRI with anchor tag", - "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", - "valid": true - }, - { - "description": "a valid IRI with anchor tag and parantheses", - "data": "http://ƒøø.com/blah_(wîkïpédiå)_blah#ßité-1", - "valid": true - }, - { - "description": "a valid IRI with URL-encoded stuff", - "data": "http://ƒøø.ßår/?q=Test%20URL-encoded%20stuff", - "valid": true - }, - { - "description": "a valid IRI with many special characters", - "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", - "valid": true - }, - { - "description": "a valid IRI based on IPv6", - "data": "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]", - "valid": true - }, - { - "description": "an invalid IRI based on IPv6", - "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "valid": false - }, - { - "description": "an invalid relative IRI Reference", - "data": "/abc", - "valid": false - }, - { - "description": "an invalid IRI", - "data": "\\\\WINDOWS\\filëßåré", - "valid": false - }, - { - "description": "an invalid IRI though valid IRI reference", - "data": "âππ", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/json-pointer.json b/src/test/resources/tck/draft2019-09/optional/format/json-pointer.json deleted file mode 100644 index da3c341e..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/json-pointer.json +++ /dev/null @@ -1,170 +0,0 @@ -[ - { - "description": "validation of JSON-pointers (JSON String Representation)", - "schema": { - "format": "json-pointer" - }, - "tests": [ - { - "description": "a valid JSON-pointer", - "data": "/foo/bar~0/baz~1/%a", - "valid": true - }, - { - "description": "not a valid JSON-pointer (~ not escaped)", - "data": "/foo/bar~", - "valid": false - }, - { - "description": "valid JSON-pointer with empty segment", - "data": "/foo//bar", - "valid": true - }, - { - "description": "valid JSON-pointer with the last empty segment", - "data": "/foo/bar/", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #1", - "data": "", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #2", - "data": "/foo", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #3", - "data": "/foo/0", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #4", - "data": "/", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #5", - "data": "/a~1b", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #6", - "data": "/c%d", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #7", - "data": "/e^f", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #8", - "data": "/g|h", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #9", - "data": "/i\\j", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #10", - "data": "/k\"l", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #11", - "data": "/ ", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #12", - "data": "/m~0n", - "valid": true - }, - { - "description": "valid JSON-pointer used adding to the last array position", - "data": "/foo/-", - "valid": true - }, - { - "description": "valid JSON-pointer (- used as object member name)", - "data": "/foo/-/bar", - "valid": true - }, - { - "description": "valid JSON-pointer (multiple escaped characters)", - "data": "/~1~0~0~1~1", - "valid": true - }, - { - "description": "valid JSON-pointer (escaped with fraction part) #1", - "data": "/~1.1", - "valid": true - }, - { - "description": "valid JSON-pointer (escaped with fraction part) #2", - "data": "/~0.1", - "valid": true - }, - { - "description": "not a valid JSON-pointer (URI Fragment Identifier) #1", - "data": "#", - "valid": false - }, - { - "description": "not a valid JSON-pointer (URI Fragment Identifier) #2", - "data": "#/", - "valid": false - }, - { - "description": "not a valid JSON-pointer (URI Fragment Identifier) #3", - "data": "#a", - "valid": false - }, - { - "description": "not a valid JSON-pointer (some escaped, but not all) #1", - "data": "/~0~", - "valid": false - }, - { - "description": "not a valid JSON-pointer (some escaped, but not all) #2", - "data": "/~0/~", - "valid": false - }, - { - "description": "not a valid JSON-pointer (wrong escape character) #1", - "data": "/~2", - "valid": false - }, - { - "description": "not a valid JSON-pointer (wrong escape character) #2", - "data": "/~-1", - "valid": false - }, - { - "description": "not a valid JSON-pointer (multiple characters not escaped)", - "data": "/~~", - "valid": false - }, - { - "description": "not a valid JSON-pointer (isn't empty nor starts with /) #1", - "data": "a", - "valid": false - }, - { - "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2", - "data": "0", - "valid": false - }, - { - "description": "not a valid JSON-pointer (isn't empty nor starts with /) #3", - "data": "a/a", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/regex.json b/src/test/resources/tck/draft2019-09/optional/format/regex.json deleted file mode 100644 index 7907f6a9..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/regex.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "description": "validation of regular expressions", - "schema": { - "format": "regex" - }, - "tests": [ - { - "description": "a valid regular expression", - "data": "([abc])+\\s+$", - "valid": true - }, - { - "description": "a regular expression with unclosed parens is invalid", - "data": "^(abc]", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/relative-json-pointer.json b/src/test/resources/tck/draft2019-09/optional/format/relative-json-pointer.json deleted file mode 100644 index bf3ec2d8..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/relative-json-pointer.json +++ /dev/null @@ -1,40 +0,0 @@ -[ - { - "description": "validation of Relative JSON Pointers (RJP)", - "schema": { - "format": "relative-json-pointer" - }, - "tests": [ - { - "description": "a valid upwards RJP", - "data": "1", - "valid": true - }, - { - "description": "a valid downwards RJP", - "data": "0/foo/bar", - "valid": true - }, - { - "description": "a valid up and then down RJP, with array index", - "data": "2/0/baz/1/zip", - "valid": true - }, - { - "description": "a valid RJP taking the member or index name", - "data": "0#", - "valid": true - }, - { - "description": "an invalid RJP that is a valid JSON Pointer", - "data": "/foo/bar", - "valid": false - }, - { - "description": "negative prefix", - "data": "-1/foo/bar", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/time.json b/src/test/resources/tck/draft2019-09/optional/format/time.json deleted file mode 100644 index 87ad9097..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/time.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "description": "validation of time strings", - "schema": { - "format": "time" - }, - "tests": [ - { - "description": "a valid time string", - "data": "08:30:06.283185Z", - "valid": true - }, - { - "description": "an invalid time string", - "data": "08:30:06 PST", - "valid": false - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "01:01:01,1111", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/uri-reference.json b/src/test/resources/tck/draft2019-09/optional/format/uri-reference.json deleted file mode 100644 index 89756d60..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/uri-reference.json +++ /dev/null @@ -1,45 +0,0 @@ -[ - { - "description": "validation of URI References", - "schema": { - "format": "uri-reference" - }, - "tests": [ - { - "description": "a valid URI", - "data": "http://foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid protocol-relative URI Reference", - "data": "//foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid relative URI Reference", - "data": "/abc", - "valid": true - }, - { - "description": "an invalid URI Reference", - "data": "\\\\WINDOWS\\fileshare", - "valid": false - }, - { - "description": "a valid URI Reference", - "data": "abc", - "valid": true - }, - { - "description": "a valid URI fragment", - "data": "#fragment", - "valid": true - }, - { - "description": "an invalid URI fragment", - "data": "#frag\\ment", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/uri-template.json b/src/test/resources/tck/draft2019-09/optional/format/uri-template.json deleted file mode 100644 index 58e20b42..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/uri-template.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "format: uri-template", - "schema": { - "format": "uri-template" - }, - "tests": [ - { - "description": "a valid uri-template", - "data": "http://example.com/dictionary/{term:1}/{term}", - "valid": true - }, - { - "description": "an invalid uri-template", - "data": "http://example.com/dictionary/{term:1}/{term", - "valid": false - }, - { - "description": "a valid uri-template without variables", - "data": "http://example.com/dictionary", - "valid": true - }, - { - "description": "a valid relative uri-template", - "data": "dictionary/{term:1}/{term}", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/uri.json b/src/test/resources/tck/draft2019-09/optional/format/uri.json deleted file mode 100644 index 1937a0da..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/uri.json +++ /dev/null @@ -1,105 +0,0 @@ -[ - { - "description": "validation of URIs", - "schema": { - "format": "uri" - }, - "tests": [ - { - "description": "a valid URL with anchor tag", - "data": "http://foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid URL with anchor tag and parantheses", - "data": "http://foo.com/blah_(wikipedia)_blah#cite-1", - "valid": true - }, - { - "description": "a valid URL with URL-encoded stuff", - "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff", - "valid": true - }, - { - "description": "a valid puny-coded URL ", - "data": "http://xn--nw2a.xn--j6w193g/", - "valid": true - }, - { - "description": "a valid URL with many special characters", - "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", - "valid": true - }, - { - "description": "a valid URL based on IPv4", - "data": "http://223.255.255.254", - "valid": true - }, - { - "description": "a valid URL with ftp scheme", - "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt", - "valid": true - }, - { - "description": "a valid URL for a simple text file", - "data": "http://www.ietf.org/rfc/rfc2396.txt", - "valid": true - }, - { - "description": "a valid URL ", - "data": "ldap://[2001:db8::7]/c=GB?objectClass?one", - "valid": true - }, - { - "description": "a valid mailto URI", - "data": "mailto:John.Doe@example.com", - "valid": true - }, - { - "description": "a valid newsgroup URI", - "data": "news:comp.infosystems.www.servers.unix", - "valid": true - }, - { - "description": "a valid tel URI", - "data": "tel:+1-816-555-1212", - "valid": true - }, - { - "description": "a valid URN", - "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", - "valid": true - }, - { - "description": "an invalid protocol-relative URI Reference", - "data": "//foo.bar/?baz=qux#quux", - "valid": false - }, - { - "description": "an invalid relative URI Reference", - "data": "/abc", - "valid": false - }, - { - "description": "an invalid URI", - "data": "\\\\WINDOWS\\fileshare", - "valid": false - }, - { - "description": "an invalid URI though valid URI reference", - "data": "abc", - "valid": false - }, - { - "description": "an invalid URI with spaces", - "data": "http:// shouldfail.com", - "valid": false - }, - { - "description": "an invalid URI with spaces and missing scheme", - "data": ":// should fail", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/format/uuid.json b/src/test/resources/tck/draft2019-09/optional/format/uuid.json deleted file mode 100644 index b3be9bad..00000000 --- a/src/test/resources/tck/draft2019-09/optional/format/uuid.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "description": "uuid format", - "schema": { - "format": "uuid" - }, - "tests": [ - { - "description": "all upper-case", - "data": "2EB8AA08-AA98-11EA-B4AA-73B441D16380", - "valid": true - }, - { - "description": "all lower-case", - "data": "2eb8aa08-aa98-11ea-b4aa-73b441d16380", - "valid": true - }, - { - "description": "mixed case", - "data": "2eb8aa08-AA98-11ea-B4Aa-73B441D16380", - "valid": true - }, - { - "description": "all zeroes is valid", - "data": "00000000-0000-0000-0000-000000000000", - "valid": true - }, - { - "description": "wrong length", - "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638", - "valid": false - }, - { - "description": "missing section", - "data": "2eb8aa08-aa98-11ea-73b441d16380", - "valid": false - }, - { - "description": "bad characters (not hex)", - "data": "2eb8aa08-aa98-11ea-b4ga-73b441d16380", - "valid": false - }, - { - "description": "no dashes", - "data": "2eb8aa08aa9811eab4aa73b441d16380", - "valid": false - }, - { - "description": "valid version 4", - "data": "98d80576-482e-427f-8434-7f86890ab222", - "valid": true - }, - { - "description": "valid version 5", - "data": "99c17cbb-656f-564a-940f-1a4568f03487", - "valid": true - }, - { - "description": "hypothetical version 6", - "data": "99c17cbb-656f-664a-940f-1a4568f03487", - "valid": true - }, - { - "description": "hypothetical version 15", - "data": "99c17cbb-656f-f64a-940f-1a4568f03487", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/non-bmp-regex.json b/src/test/resources/tck/draft2019-09/optional/non-bmp-regex.json deleted file mode 100644 index ab53c6e2..00000000 --- a/src/test/resources/tck/draft2019-09/optional/non-bmp-regex.json +++ /dev/null @@ -1,94 +0,0 @@ -[ - { - "description": "Proper UTF-16 surrogate pair handling: pattern", - "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", - "schema": { - "pattern": "^🐲*$" - }, - "tests": [ - { - "description": "matches empty", - "data": "", - "valid": true - }, - { - "description": "matches single", - "data": "🐲", - "valid": true - }, - { - "description": "matches two", - "data": "🐲🐲", - "valid": true - }, - { - "description": "doesn't match one", - "data": "🐉", - "valid": false - }, - { - "description": "doesn't match two", - "data": "🐉🐉", - "valid": false - }, - { - "description": "doesn't match one ASCII", - "data": "D", - "valid": false - }, - { - "description": "doesn't match two ASCII", - "data": "DD", - "valid": false - } - ] - }, - { - "description": "Proper UTF-16 surrogate pair handling: patternProperties", - "comment": "Optional because .Net doesn't correctly handle 32-bit Unicode characters", - "schema": { - "patternProperties": { - "^🐲*$": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "matches empty", - "data": { - "": 1 - }, - "valid": true - }, - { - "description": "matches single", - "data": { - "🐲": 1 - }, - "valid": true - }, - { - "description": "matches two", - "data": { - "🐲🐲": 1 - }, - "valid": true - }, - { - "description": "doesn't match one", - "data": { - "🐲": "hello" - }, - "valid": false - }, - { - "description": "doesn't match two", - "data": { - "🐲🐲": "hello" - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/optional/refOfUnknownKeyword.json b/src/test/resources/tck/draft2019-09/optional/refOfUnknownKeyword.json deleted file mode 100644 index ee85515a..00000000 --- a/src/test/resources/tck/draft2019-09/optional/refOfUnknownKeyword.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "description": "reference of a root arbitrary keyword ", - "schema": { - "unknown-keyword": { - "type": "integer" - }, - "properties": { - "bar": { - "$ref": "#/unknown-keyword" - } - } - }, - "tests": [ - { - "description": "match", - "data": { - "bar": 3 - }, - "valid": true - }, - { - "description": "mismatch", - "data": { - "bar": true - }, - "valid": false - } - ] - }, - { - "description": "reference of an arbitrary keyword of a sub-schema", - "schema": { - "properties": { - "foo": { - "unknown-keyword": { - "type": "integer" - } - }, - "bar": { - "$ref": "#/properties/foo/unknown-keyword" - } - } - }, - "tests": [ - { - "description": "match", - "data": { - "bar": 3 - }, - "valid": true - }, - { - "description": "mismatch", - "data": { - "bar": true - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/pattern.json b/src/test/resources/tck/draft2019-09/pattern.json deleted file mode 100644 index 4fa383d1..00000000 --- a/src/test/resources/tck/draft2019-09/pattern.json +++ /dev/null @@ -1,63 +0,0 @@ -[ - { - "description": "pattern validation", - "schema": { - "pattern": "^a*$" - }, - "tests": [ - { - "description": "a matching pattern is valid", - "data": "aaa", - "valid": true - }, - { - "description": "a non-matching pattern is invalid", - "data": "abc", - "valid": false - }, - { - "description": "ignores booleans", - "data": true, - "valid": true - }, - { - "description": "ignores integers", - "data": 123, - "valid": true - }, - { - "description": "ignores floats", - "data": 1.0, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "pattern is not anchored", - "schema": { - "pattern": "a+" - }, - "tests": [ - { - "description": "matches a substring", - "data": "xxaayy", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/patternProperties.json b/src/test/resources/tck/draft2019-09/patternProperties.json deleted file mode 100644 index 8823ed97..00000000 --- a/src/test/resources/tck/draft2019-09/patternProperties.json +++ /dev/null @@ -1,202 +0,0 @@ -[ - { - "description": "patternProperties validates properties matching a regex", - "schema": { - "patternProperties": { - "f.*o": { - "type": "integer" - } - } - }, - "tests": [ - { - "description": "a single valid match is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "multiple valid matches is valid", - "data": { - "foo": 1, - "foooooo": 2 - }, - "valid": true - }, - { - "description": "a single invalid match is invalid", - "data": { - "foo": "bar", - "fooooo": 2 - }, - "valid": false - }, - { - "description": "multiple invalid matches is invalid", - "data": { - "foo": "bar", - "foooooo": "baz" - }, - "valid": false - }, - { - "description": "ignores arrays", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "ignores strings", - "data": "foo", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "multiple simultaneous patternProperties are validated", - "schema": { - "patternProperties": { - "a*": { - "type": "integer" - }, - "aaa*": { - "maximum": 20 - } - } - }, - "tests": [ - { - "description": "a single valid match is valid", - "data": { - "a": 21 - }, - "valid": true - }, - { - "description": "a simultaneous match is valid", - "data": { - "aaaa": 18 - }, - "valid": true - }, - { - "description": "multiple matches is valid", - "data": { - "a": 21, - "aaaa": 18 - }, - "valid": true - }, - { - "description": "an invalid due to one is invalid", - "data": { - "a": "bar" - }, - "valid": false - }, - { - "description": "an invalid due to the other is invalid", - "data": { - "aaaa": 31 - }, - "valid": false - }, - { - "description": "an invalid due to both is invalid", - "data": { - "aaa": "foo", - "aaaa": 31 - }, - "valid": false - } - ] - }, - { - "description": "regexes are not anchored by default and are case sensitive", - "schema": { - "patternProperties": { - "[0-9]{2,}": { - "type": "boolean" - }, - "X_": { - "type": "string" - } - } - }, - "tests": [ - { - "description": "non recognized members are ignored", - "data": { - "answer 1": "42" - }, - "valid": true - }, - { - "description": "recognized members are accounted for", - "data": { - "a31b": null - }, - "valid": false - }, - { - "description": "regexes are case sensitive", - "data": { - "a_x_3": 3 - }, - "valid": true - }, - { - "description": "regexes are case sensitive, 2", - "data": { - "a_X_3": 3 - }, - "valid": false - } - ] - }, - { - "description": "patternProperties with boolean schemas", - "schema": { - "patternProperties": { - "f.*": true, - "b.*": false - } - }, - "tests": [ - { - "description": "object with property matching schema true is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "object with property matching schema false is invalid", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "object with both properties is invalid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/properties.json b/src/test/resources/tck/draft2019-09/properties.json deleted file mode 100644 index daf6708f..00000000 --- a/src/test/resources/tck/draft2019-09/properties.json +++ /dev/null @@ -1,238 +0,0 @@ -[ - { - "description": "object properties validation", - "schema": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "type": "string" - } - } - }, - "tests": [ - { - "description": "both properties present and valid is valid", - "data": { - "foo": 1, - "bar": "baz" - }, - "valid": true - }, - { - "description": "one property invalid is invalid", - "data": { - "foo": 1, - "bar": {} - }, - "valid": false - }, - { - "description": "both properties invalid is invalid", - "data": { - "foo": [], - "bar": {} - }, - "valid": false - }, - { - "description": "doesn't invalidate other properties", - "data": { - "quux": [] - }, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "properties, patternProperties, additionalProperties interaction", - "schema": { - "properties": { - "foo": { - "type": "array", - "maxItems": 3 - }, - "bar": { - "type": "array" - } - }, - "patternProperties": { - "f.o": { - "minItems": 2 - } - }, - "additionalProperties": { - "type": "integer" - } - }, - "tests": [ - { - "description": "property validates property", - "data": { - "foo": [ - 1, - 2 - ] - }, - "valid": true - }, - { - "description": "property invalidates property", - "data": { - "foo": [ - 1, - 2, - 3, - 4 - ] - }, - "valid": false - }, - { - "description": "patternProperty invalidates property", - "data": { - "foo": [] - }, - "valid": false - }, - { - "description": "patternProperty validates nonproperty", - "data": { - "fxo": [ - 1, - 2 - ] - }, - "valid": true - }, - { - "description": "patternProperty invalidates nonproperty", - "data": { - "fxo": [] - }, - "valid": false - }, - { - "description": "additionalProperty ignores property", - "data": { - "bar": [] - }, - "valid": true - }, - { - "description": "additionalProperty validates others", - "data": { - "quux": 3 - }, - "valid": true - }, - { - "description": "additionalProperty invalidates others", - "data": { - "quux": "foo" - }, - "valid": false - } - ] - }, - { - "description": "properties with boolean schema", - "schema": { - "properties": { - "foo": true, - "bar": false - } - }, - "tests": [ - { - "description": "no property present is valid", - "data": {}, - "valid": true - }, - { - "description": "only 'true' property present is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "only 'false' property present is invalid", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "both properties present is invalid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": false - } - ] - }, - { - "description": "properties with escaped characters", - "schema": { - "properties": { - "foo\nbar": { - "type": "number" - }, - "foo\"bar": { - "type": "number" - }, - "foo\\bar": { - "type": "number" - }, - "foo\rbar": { - "type": "number" - }, - "foo\tbar": { - "type": "number" - }, - "foo\fbar": { - "type": "number" - } - } - }, - "tests": [ - { - "description": "object with all numbers is valid", - "data": { - "foo\nbar": 1, - "foo\"bar": 1, - "foo\\bar": 1, - "foo\rbar": 1, - "foo\tbar": 1, - "foo\fbar": 1 - }, - "valid": true - }, - { - "description": "object with strings is invalid", - "data": { - "foo\nbar": "1", - "foo\"bar": "1", - "foo\\bar": "1", - "foo\rbar": "1", - "foo\tbar": "1", - "foo\fbar": "1" - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/propertyNames.json b/src/test/resources/tck/draft2019-09/propertyNames.json deleted file mode 100644 index 1a78a408..00000000 --- a/src/test/resources/tck/draft2019-09/propertyNames.json +++ /dev/null @@ -1,93 +0,0 @@ -[ - { - "description": "propertyNames validation", - "schema": { - "propertyNames": { - "maxLength": 3 - } - }, - "tests": [ - { - "description": "all property names valid", - "data": { - "f": {}, - "foo": {} - }, - "valid": true - }, - { - "description": "some property names invalid", - "data": { - "foo": {}, - "foobar": {} - }, - "valid": false - }, - { - "description": "object without properties is valid", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [ - 1, - 2, - 3, - 4 - ], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "propertyNames with boolean schema true", - "schema": { - "propertyNames": true - }, - "tests": [ - { - "description": "object with any properties is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "propertyNames with boolean schema false", - "schema": { - "propertyNames": false - }, - "tests": [ - { - "description": "object with any properties is invalid", - "data": { - "foo": 1 - }, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/ref.json b/src/test/resources/tck/draft2019-09/ref.json deleted file mode 100644 index 5d26ac9d..00000000 --- a/src/test/resources/tck/draft2019-09/ref.json +++ /dev/null @@ -1,534 +0,0 @@ -[ - { - "description": "root pointer ref", - "schema": { - "properties": { - "foo": { - "$ref": "#" - } - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "match", - "data": { - "foo": false - }, - "valid": true - }, - { - "description": "recursive match", - "data": { - "foo": { - "foo": false - } - }, - "valid": true - }, - { - "description": "mismatch", - "data": { - "bar": false - }, - "valid": false - }, - { - "description": "recursive mismatch", - "data": { - "foo": { - "bar": false - } - }, - "valid": false - } - ] - }, - { - "description": "relative pointer ref to object", - "schema": { - "properties": { - "foo": { - "type": "integer" - }, - "bar": { - "$ref": "#/properties/foo" - } - } - }, - "tests": [ - { - "description": "match", - "data": { - "bar": 3 - }, - "valid": true - }, - { - "description": "mismatch", - "data": { - "bar": true - }, - "valid": false - } - ] - }, - { - "description": "relative pointer ref to array", - "schema": { - "items": [ - { - "type": "integer" - }, - { - "$ref": "#/items/0" - } - ] - }, - "tests": [ - { - "description": "match array", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "mismatch array", - "data": [ - 1, - "foo" - ], - "valid": false - } - ] - }, - { - "description": "escaped pointer ref", - "schema": { - "$defs": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - } - }, - "properties": { - "tilde": { - "$ref": "#/$defs/tilde~0field" - }, - "slash": { - "$ref": "#/$defs/slash~1field" - }, - "percent": { - "$ref": "#/$defs/percent%25field" - } - } - }, - "tests": [ - { - "description": "slash invalid", - "data": { - "slash": "aoeu" - }, - "valid": false - }, - { - "description": "tilde invalid", - "data": { - "tilde": "aoeu" - }, - "valid": false - }, - { - "description": "percent invalid", - "data": { - "percent": "aoeu" - }, - "valid": false - }, - { - "description": "slash valid", - "data": { - "slash": 123 - }, - "valid": true - }, - { - "description": "tilde valid", - "data": { - "tilde": 123 - }, - "valid": true - }, - { - "description": "percent valid", - "data": { - "percent": 123 - }, - "valid": true - } - ] - }, - { - "description": "nested refs", - "schema": { - "$defs": { - "a": { - "type": "integer" - }, - "b": { - "$ref": "#/$defs/a" - }, - "c": { - "$ref": "#/$defs/b" - } - }, - "$ref": "#/$defs/c" - }, - "tests": [ - { - "description": "nested ref valid", - "data": 5, - "valid": true - }, - { - "description": "nested ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref applies alongside sibling keywords", - "schema": { - "$defs": { - "reffed": { - "type": "array" - } - }, - "properties": { - "foo": { - "$ref": "#/$defs/reffed", - "maxItems": 2 - } - } - }, - "tests": [ - { - "description": "ref valid, maxItems valid", - "data": { - "foo": [] - }, - "valid": true - }, - { - "description": "ref valid, maxItems invalid", - "data": { - "foo": [ - 1, - 2, - 3 - ] - }, - "valid": false - }, - { - "description": "ref invalid", - "data": { - "foo": "string" - }, - "valid": false - } - ] - }, - { - "description": "remote ref, containing refs itself", - "schema": { - "$ref": "https://json-schema.org/draft/2019-09/schema" - }, - "tests": [ - { - "description": "remote ref valid", - "data": { - "minLength": 1 - }, - "valid": true - }, - { - "description": "remote ref invalid", - "data": { - "minLength": -1 - }, - "valid": false - } - ] - }, - { - "description": "property named $ref that is not a reference", - "schema": { - "properties": { - "$ref": { - "type": "string" - } - } - }, - "tests": [ - { - "description": "property named $ref valid", - "data": { - "$ref": "a" - }, - "valid": true - }, - { - "description": "property named $ref invalid", - "data": { - "$ref": 2 - }, - "valid": false - } - ] - }, - { - "description": "property named $ref, containing an actual $ref", - "schema": { - "properties": { - "$ref": { - "$ref": "#/$defs/is-string" - } - }, - "$defs": { - "is-string": { - "type": "string" - } - } - }, - "tests": [ - { - "description": "property named $ref valid", - "data": { - "$ref": "a" - }, - "valid": true - }, - { - "description": "property named $ref invalid", - "data": { - "$ref": 2 - }, - "valid": false - } - ] - }, - { - "description": "$ref to boolean schema true", - "schema": { - "$ref": "#/$defs/bool", - "$defs": { - "bool": true - } - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "$ref to boolean schema false", - "schema": { - "$ref": "#/$defs/bool", - "$defs": { - "bool": false - } - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "Recursive references between schemas", - "schema": { - "$id": "http://localhost:1234/tree", - "description": "tree of nodes", - "type": "object", - "properties": { - "meta": { - "type": "string" - }, - "nodes": { - "type": "array", - "items": { - "$ref": "node" - } - } - }, - "required": [ - "meta", - "nodes" - ], - "$defs": { - "node": { - "$id": "http://localhost:1234/node", - "description": "node", - "type": "object", - "properties": { - "value": { - "type": "number" - }, - "subtree": { - "$ref": "tree" - } - }, - "required": [ - "value" - ] - } - } - }, - "tests": [ - { - "description": "valid tree", - "data": { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 1.1 - }, - { - "value": 1.2 - } - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 2.1 - }, - { - "value": 2.2 - } - ] - } - } - ] - }, - "valid": true - }, - { - "description": "invalid tree", - "data": { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": "string is invalid" - }, - { - "value": 1.2 - } - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 2.1 - }, - { - "value": 2.2 - } - ] - } - } - ] - }, - "valid": false - } - ] - }, - { - "description": "refs with quote", - "schema": { - "properties": { - "foo\"bar": { - "$ref": "#/$defs/foo%22bar" - } - }, - "$defs": { - "foo\"bar": { - "type": "number" - } - } - }, - "tests": [ - { - "description": "object with numbers is valid", - "data": { - "foo\"bar": 1 - }, - "valid": true - }, - { - "description": "object with strings is invalid", - "data": { - "foo\"bar": "1" - }, - "valid": false - } - ] - }, - { - "description": "ref creates new scope when adjacent to keywords", - "schema": { - "$defs": { - "A": { - "unevaluatedProperties": false - } - }, - "properties": { - "prop1": { - "type": "string" - } - }, - "$ref": "#/$defs/A" - }, - "tests": [ - { - "description": "referenced subschema doesn't see annotations from properties", - "data": { - "prop1": "match" - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/refRemote.json b/src/test/resources/tck/draft2019-09/refRemote.json deleted file mode 100644 index d69e0c3a..00000000 --- a/src/test/resources/tck/draft2019-09/refRemote.json +++ /dev/null @@ -1,211 +0,0 @@ -[ - { - "description": "remote ref", - "schema": { - "$ref": "http://localhost:1234/integer.json" - }, - "tests": [ - { - "description": "remote ref valid", - "data": 1, - "valid": true - }, - { - "description": "remote ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "fragment within remote ref", - "schema": { - "$ref": "http://localhost:1234/subSchemas-defs.json#/$defs/integer" - }, - "tests": [ - { - "description": "remote fragment valid", - "data": 1, - "valid": true - }, - { - "description": "remote fragment invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref within remote ref", - "schema": { - "$ref": "http://localhost:1234/subSchemas-defs.json#/$defs/refToInteger" - }, - "tests": [ - { - "description": "ref within ref valid", - "data": 1, - "valid": true - }, - { - "description": "ref within ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "base URI change", - "schema": { - "$id": "http://localhost:1234/", - "items": { - "$id": "folder/", - "items": { - "$ref": "folderInteger.json" - } - } - }, - "tests": [ - { - "description": "base URI change ref valid", - "data": [ - [ - 1 - ] - ], - "valid": true - }, - { - "description": "base URI change ref invalid", - "data": [ - [ - "a" - ] - ], - "valid": false - } - ] - }, - { - "description": "base URI change - change folder", - "schema": { - "$id": "http://localhost:1234/scope_change_defs1.json", - "type": "object", - "properties": { - "list": { - "$ref": "folder/" - } - }, - "$defs": { - "baz": { - "$id": "folder/", - "type": "array", - "items": { - "$ref": "folderInteger.json" - } - } - } - }, - "tests": [ - { - "description": "number is valid", - "data": { - "list": [ - 1 - ] - }, - "valid": true - }, - { - "description": "string is invalid", - "data": { - "list": [ - "a" - ] - }, - "valid": false - } - ] - }, - { - "description": "base URI change - change folder in subschema", - "schema": { - "$id": "http://localhost:1234/scope_change_defs2.json", - "type": "object", - "properties": { - "list": { - "$ref": "folder/#/$defs/bar" - } - }, - "$defs": { - "baz": { - "$id": "folder/", - "$defs": { - "bar": { - "type": "array", - "items": { - "$ref": "folderInteger.json" - } - } - } - } - } - }, - "tests": [ - { - "description": "number is valid", - "data": { - "list": [ - 1 - ] - }, - "valid": true - }, - { - "description": "string is invalid", - "data": { - "list": [ - "a" - ] - }, - "valid": false - } - ] - }, - { - "description": "root ref in remote ref", - "schema": { - "$id": "http://localhost:1234/object", - "type": "object", - "properties": { - "name": { - "$ref": "name-defs.json#/$defs/orNull" - } - } - }, - "tests": [ - { - "description": "string is valid", - "data": { - "name": "foo" - }, - "valid": true - }, - { - "description": "null is valid", - "data": { - "name": null - }, - "valid": true - }, - { - "description": "object is invalid", - "data": { - "name": { - "name": null - } - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/remotes/folder/folderInteger.json b/src/test/resources/tck/draft2019-09/remotes/folder/folderInteger.json deleted file mode 100644 index 782f2003..00000000 --- a/src/test/resources/tck/draft2019-09/remotes/folder/folderInteger.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "integer" -} diff --git a/src/test/resources/tck/draft2019-09/remotes/integer.json b/src/test/resources/tck/draft2019-09/remotes/integer.json deleted file mode 100644 index 782f2003..00000000 --- a/src/test/resources/tck/draft2019-09/remotes/integer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "integer" -} diff --git a/src/test/resources/tck/draft2019-09/remotes/name-defs.json b/src/test/resources/tck/draft2019-09/remotes/name-defs.json deleted file mode 100644 index 6b5479d3..00000000 --- a/src/test/resources/tck/draft2019-09/remotes/name-defs.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$defs": { - "orNull": { - "anyOf": [ - { - "type": "null" - }, - { - "$ref": "#" - } - ] - } - }, - "type": "string" -} diff --git a/src/test/resources/tck/draft2019-09/remotes/name.json b/src/test/resources/tck/draft2019-09/remotes/name.json deleted file mode 100644 index 746a27e7..00000000 --- a/src/test/resources/tck/draft2019-09/remotes/name.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "definitions": { - "orNull": { - "anyOf": [ - { - "type": "null" - }, - { - "$ref": "#" - } - ] - } - }, - "type": "string" -} diff --git a/src/test/resources/tck/draft2019-09/remotes/subSchemas-defs.json b/src/test/resources/tck/draft2019-09/remotes/subSchemas-defs.json deleted file mode 100644 index ffbe9e9c..00000000 --- a/src/test/resources/tck/draft2019-09/remotes/subSchemas-defs.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "$defs": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/$defs/integer" - } - } -} diff --git a/src/test/resources/tck/draft2019-09/remotes/subSchemas.json b/src/test/resources/tck/draft2019-09/remotes/subSchemas.json deleted file mode 100644 index f5577e77..00000000 --- a/src/test/resources/tck/draft2019-09/remotes/subSchemas.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/integer" - } -} diff --git a/src/test/resources/tck/draft2019-09/required.json b/src/test/resources/tck/draft2019-09/required.json deleted file mode 100644 index 6358d4e1..00000000 --- a/src/test/resources/tck/draft2019-09/required.json +++ /dev/null @@ -1,111 +0,0 @@ -[ - { - "description": "required validation", - "schema": { - "properties": { - "foo": {}, - "bar": {} - }, - "required": [ - "foo" - ] - }, - "tests": [ - { - "description": "present required property is valid", - "data": { - "foo": 1 - }, - "valid": true - }, - { - "description": "non-present required property is invalid", - "data": { - "bar": 1 - }, - "valid": false - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores strings", - "data": "", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "required default validation", - "schema": { - "properties": { - "foo": {} - } - }, - "tests": [ - { - "description": "not required by default", - "data": {}, - "valid": true - } - ] - }, - { - "description": "required with empty array", - "schema": { - "properties": { - "foo": {} - }, - "required": [] - }, - "tests": [ - { - "description": "property not required", - "data": {}, - "valid": true - } - ] - }, - { - "description": "required with escaped characters", - "schema": { - "required": [ - "foo\nbar", - "foo\"bar", - "foo\\bar", - "foo\rbar", - "foo\tbar", - "foo\fbar" - ] - }, - "tests": [ - { - "description": "object with all properties present is valid", - "data": { - "foo\nbar": 1, - "foo\"bar": 1, - "foo\\bar": 1, - "foo\rbar": 1, - "foo\tbar": 1, - "foo\fbar": 1 - }, - "valid": true - }, - { - "description": "object with some properties missing is invalid", - "data": { - "foo\nbar": "1", - "foo\"bar": "1" - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/type.json b/src/test/resources/tck/draft2019-09/type.json deleted file mode 100644 index 770a92d6..00000000 --- a/src/test/resources/tck/draft2019-09/type.json +++ /dev/null @@ -1,514 +0,0 @@ -[ - { - "description": "integer type matches integers", - "schema": { - "type": "integer" - }, - "tests": [ - { - "description": "an integer is an integer", - "data": 1, - "valid": true - }, - { - "description": "a float with zero fractional part is an integer", - "data": 1.0, - "valid": true - }, - { - "description": "a float is not an integer", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an integer", - "data": "foo", - "valid": false - }, - { - "description": "a string is still not an integer, even if it looks like one", - "data": "1", - "valid": false - }, - { - "description": "an object is not an integer", - "data": {}, - "valid": false - }, - { - "description": "an array is not an integer", - "data": [], - "valid": false - }, - { - "description": "a boolean is not an integer", - "data": true, - "valid": false - }, - { - "description": "null is not an integer", - "data": null, - "valid": false - } - ] - }, - { - "description": "number type matches numbers", - "schema": { - "type": "number" - }, - "tests": [ - { - "description": "an integer is a number", - "data": 1, - "valid": true - }, - { - "description": "a float with zero fractional part is a number (and an integer)", - "data": 1.0, - "valid": true - }, - { - "description": "a float is a number", - "data": 1.1, - "valid": true - }, - { - "description": "a string is not a number", - "data": "foo", - "valid": false - }, - { - "description": "a string is still not a number, even if it looks like one", - "data": "1", - "valid": false - }, - { - "description": "an object is not a number", - "data": {}, - "valid": false - }, - { - "description": "an array is not a number", - "data": [], - "valid": false - }, - { - "description": "a boolean is not a number", - "data": true, - "valid": false - }, - { - "description": "null is not a number", - "data": null, - "valid": false - } - ] - }, - { - "description": "string type matches strings", - "schema": { - "type": "string" - }, - "tests": [ - { - "description": "1 is not a string", - "data": 1, - "valid": false - }, - { - "description": "a float is not a string", - "data": 1.1, - "valid": false - }, - { - "description": "a string is a string", - "data": "foo", - "valid": true - }, - { - "description": "a string is still a string, even if it looks like a number", - "data": "1", - "valid": true - }, - { - "description": "an empty string is still a string", - "data": "", - "valid": true - }, - { - "description": "an object is not a string", - "data": {}, - "valid": false - }, - { - "description": "an array is not a string", - "data": [], - "valid": false - }, - { - "description": "a boolean is not a string", - "data": true, - "valid": false - }, - { - "description": "null is not a string", - "data": null, - "valid": false - } - ] - }, - { - "description": "object type matches objects", - "schema": { - "type": "object" - }, - "tests": [ - { - "description": "an integer is not an object", - "data": 1, - "valid": false - }, - { - "description": "a float is not an object", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an object", - "data": "foo", - "valid": false - }, - { - "description": "an object is an object", - "data": {}, - "valid": true - }, - { - "description": "an array is not an object", - "data": [], - "valid": false - }, - { - "description": "a boolean is not an object", - "data": true, - "valid": false - }, - { - "description": "null is not an object", - "data": null, - "valid": false - } - ] - }, - { - "description": "array type matches arrays", - "schema": { - "type": "array" - }, - "tests": [ - { - "description": "an integer is not an array", - "data": 1, - "valid": false - }, - { - "description": "a float is not an array", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an array", - "data": "foo", - "valid": false - }, - { - "description": "an object is not an array", - "data": {}, - "valid": false - }, - { - "description": "an array is an array", - "data": [], - "valid": true - }, - { - "description": "a boolean is not an array", - "data": true, - "valid": false - }, - { - "description": "null is not an array", - "data": null, - "valid": false - } - ] - }, - { - "description": "boolean type matches booleans", - "schema": { - "type": "boolean" - }, - "tests": [ - { - "description": "an integer is not a boolean", - "data": 1, - "valid": false - }, - { - "description": "zero is not a boolean", - "data": 0, - "valid": false - }, - { - "description": "a float is not a boolean", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not a boolean", - "data": "foo", - "valid": false - }, - { - "description": "an empty string is not a boolean", - "data": "", - "valid": false - }, - { - "description": "an object is not a boolean", - "data": {}, - "valid": false - }, - { - "description": "an array is not a boolean", - "data": [], - "valid": false - }, - { - "description": "true is a boolean", - "data": true, - "valid": true - }, - { - "description": "false is a boolean", - "data": false, - "valid": true - }, - { - "description": "null is not a boolean", - "data": null, - "valid": false - } - ] - }, - { - "description": "null type matches only the null object", - "schema": { - "type": "null" - }, - "tests": [ - { - "description": "an integer is not null", - "data": 1, - "valid": false - }, - { - "description": "a float is not null", - "data": 1.1, - "valid": false - }, - { - "description": "zero is not null", - "data": 0, - "valid": false - }, - { - "description": "a string is not null", - "data": "foo", - "valid": false - }, - { - "description": "an empty string is not null", - "data": "", - "valid": false - }, - { - "description": "an object is not null", - "data": {}, - "valid": false - }, - { - "description": "an array is not null", - "data": [], - "valid": false - }, - { - "description": "true is not null", - "data": true, - "valid": false - }, - { - "description": "false is not null", - "data": false, - "valid": false - }, - { - "description": "null is null", - "data": null, - "valid": true - } - ] - }, - { - "description": "multiple types can be specified in an array", - "schema": { - "type": [ - "integer", - "string" - ] - }, - "tests": [ - { - "description": "an integer is valid", - "data": 1, - "valid": true - }, - { - "description": "a string is valid", - "data": "foo", - "valid": true - }, - { - "description": "a float is invalid", - "data": 1.1, - "valid": false - }, - { - "description": "an object is invalid", - "data": {}, - "valid": false - }, - { - "description": "an array is invalid", - "data": [], - "valid": false - }, - { - "description": "a boolean is invalid", - "data": true, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - } - ] - }, - { - "description": "type as array with one item", - "schema": { - "type": [ - "string" - ] - }, - "tests": [ - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "number is invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "type: array or object", - "schema": { - "type": [ - "array", - "object" - ] - }, - "tests": [ - { - "description": "array is valid", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "object is valid", - "data": { - "foo": 123 - }, - "valid": true - }, - { - "description": "number is invalid", - "data": 123, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - } - ] - }, - { - "description": "type: array, object or null", - "schema": { - "type": [ - "array", - "object", - "null" - ] - }, - "tests": [ - { - "description": "array is valid", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "object is valid", - "data": { - "foo": 123 - }, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "number is invalid", - "data": 123, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/unevaluatedItems.json b/src/test/resources/tck/draft2019-09/unevaluatedItems.json deleted file mode 100644 index c94a3676..00000000 --- a/src/test/resources/tck/draft2019-09/unevaluatedItems.json +++ /dev/null @@ -1,548 +0,0 @@ -[ - { - "description": "unevaluatedItems true", - "schema": { - "type": "array", - "unevaluatedItems": true - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": [], - "valid": true - }, - { - "description": "with unevaluated items", - "data": [ - "foo" - ], - "valid": true - } - ] - }, - { - "description": "unevaluatedItems false", - "schema": { - "type": "array", - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": [], - "valid": true - }, - { - "description": "with unevaluated items", - "data": [ - "foo" - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems as schema", - "schema": { - "type": "array", - "unevaluatedItems": { - "type": "string" - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": [], - "valid": true - }, - { - "description": "with valid unevaluated items", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "with invalid unevaluated items", - "data": [ - 42 - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with uniform items", - "schema": { - "type": "array", - "items": { - "type": "string" - }, - "unevaluatedItems": false - }, - "tests": [ - { - "description": "unevaluatedItems doesn't apply", - "data": [ - "foo", - "bar" - ], - "valid": true - } - ] - }, - { - "description": "unevaluatedItems with tuple", - "schema": { - "type": "array", - "items": [ - { - "type": "string" - } - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no unevaluted items", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "with unevaluted items", - "data": [ - "foo", - "bar" - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with additionalItems", - "schema": { - "type": "array", - "items": [ - { - "type": "string" - } - ], - "additionalItems": true, - "unevaluatedItems": false - }, - "tests": [ - { - "description": "unevaluatedItems doesn't apply", - "data": [ - "foo", - 42 - ], - "valid": true - } - ] - }, - { - "description": "unevaluatedItems with nested tuple", - "schema": { - "type": "array", - "items": [ - { - "type": "string" - } - ], - "allOf": [ - { - "items": [ - true, - { - "type": "number" - } - ] - } - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no unevaluted items", - "data": [ - "foo", - 42 - ], - "valid": true - }, - { - "description": "with unevaluted items", - "data": [ - "foo", - 42, - true - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with nested additionalItems", - "schema": { - "type": "array", - "allOf": [ - { - "items": [ - { - "type": "string" - } - ], - "additionalItems": true - } - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no additional items", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "with additional items", - "data": [ - "foo", - 42, - true - ], - "valid": true - } - ] - }, - { - "description": "unevaluatedItems with nested unevaluatedItems", - "schema": { - "type": "array", - "allOf": [ - { - "items": [ - { - "type": "string" - } - ] - }, - { - "unevaluatedItems": true - } - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no additional items", - "data": [ - "foo" - ], - "valid": true - }, - { - "description": "with additional items", - "data": [ - "foo", - 42, - true - ], - "valid": true - } - ] - }, - { - "description": "unevaluatedItems with anyOf", - "schema": { - "type": "array", - "items": [ - { - "const": "foo" - } - ], - "anyOf": [ - { - "items": [ - true, - { - "const": "bar" - } - ] - }, - { - "items": [ - true, - true, - { - "const": "baz" - } - ] - } - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "when one schema matches and has no unevaluted items", - "data": [ - "foo", - "bar" - ], - "valid": true - }, - { - "description": "when one schema matches and has unevaluted items", - "data": [ - "foo", - "bar", - 42 - ], - "valid": false - }, - { - "description": "when two schemas match and has no unevaluted items", - "data": [ - "foo", - "bar", - "baz" - ], - "valid": true - }, - { - "description": "when two schemas match and has unevaluted items", - "data": [ - "foo", - "bar", - "baz", - 42 - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with oneOf", - "schema": { - "type": "array", - "items": [ - { - "const": "foo" - } - ], - "oneOf": [ - { - "items": [ - true, - { - "const": "bar" - } - ] - }, - { - "items": [ - true, - { - "const": "baz" - } - ] - } - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no unevaluted items", - "data": [ - "foo", - "bar" - ], - "valid": true - }, - { - "description": "with unevaluted items", - "data": [ - "foo", - "bar", - 42 - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with if/then/else", - "schema": { - "type": "array", - "items": [ - { - "const": "foo" - } - ], - "if": { - "items": [ - true, - { - "const": "bar" - } - ] - }, - "then": { - "items": [ - true, - true, - { - "const": "then" - } - ] - }, - "else": { - "items": [ - true, - true, - true, - { - "const": "else" - } - ] - }, - "unevaluatedItems": false - }, - "tests": [ - { - "description": "when if matches and it has no unevaluted items", - "data": [ - "foo", - "bar", - "then" - ], - "valid": true - }, - { - "description": "when if matches and it has unevaluted items", - "data": [ - "foo", - "bar", - "then", - "else" - ], - "valid": false - }, - { - "description": "when if doesn't match and it has no unevaluted items", - "data": [ - "foo", - 42, - 42, - "else" - ], - "valid": true - }, - { - "description": "when if doesn't match and it has unevaluted items", - "data": [ - "foo", - 42, - 42, - "else", - 42 - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with boolean schemas", - "schema": { - "type": "array", - "allOf": [ - true - ], - "unevaluatedItems": false - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": [], - "valid": true - }, - { - "description": "with unevaluated items", - "data": [ - "foo" - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems with $ref", - "schema": { - "type": "array", - "$ref": "#/$defs/bar", - "items": [ - { - "type": "string" - } - ], - "unevaluatedItems": false, - "$defs": { - "bar": { - "items": [ - true, - { - "type": "string" - } - ] - } - } - }, - "tests": [ - { - "description": "with no unevaluated items", - "data": [ - "foo", - "bar" - ], - "valid": true - }, - { - "description": "with unevaluated items", - "data": [ - "foo", - "bar", - "baz" - ], - "valid": false - } - ] - }, - { - "description": "unevaluatedItems can't see inside cousins", - "schema": { - "allOf": [ - { - "items": [ - true - ] - }, - { - "unevaluatedItems": false - } - ] - }, - "tests": [ - { - "description": "always fails", - "data": [ - 1 - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/unevaluatedProperties.json b/src/test/resources/tck/draft2019-09/unevaluatedProperties.json deleted file mode 100644 index 67b3d8a7..00000000 --- a/src/test/resources/tck/draft2019-09/unevaluatedProperties.json +++ /dev/null @@ -1,657 +0,0 @@ -[ - { - "description": "unevaluatedProperties true", - "schema": { - "type": "object", - "unevaluatedProperties": true - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": {}, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": true - } - ] - }, - { - "description": "unevaluatedProperties schema", - "schema": { - "type": "object", - "unevaluatedProperties": { - "type": "string", - "minLength": 3 - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": {}, - "valid": true - }, - { - "description": "with valid unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with invalid unevaluated properties", - "data": { - "foo": "fo" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties false", - "schema": { - "type": "object", - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": {}, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with adjacent properties", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with adjacent patternProperties", - "schema": { - "type": "object", - "patternProperties": { - "^foo": { - "type": "string" - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with adjacent additionalProperties", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "additionalProperties": true, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no additional properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with additional properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - } - ] - }, - { - "description": "unevaluatedProperties with nested properties", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "allOf": [ - { - "properties": { - "bar": { - "type": "string" - } - } - } - ], - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no additional properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with additional properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with nested patternProperties", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "allOf": [ - { - "patternProperties": { - "^bar": { - "type": "string" - } - } - } - ], - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no additional properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with additional properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with nested additionalProperties", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "allOf": [ - { - "additionalProperties": true - } - ], - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no additional properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with additional properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - } - ] - }, - { - "description": "unevaluatedProperties with nested unevaluatedProperties", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "allOf": [ - { - "unevaluatedProperties": true - } - ], - "unevaluatedProperties": { - "type": "string", - "maxLength": 2 - } - }, - "tests": [ - { - "description": "with no nested unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with nested unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - } - ] - }, - { - "description": "unevaluatedProperties with anyOf", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "anyOf": [ - { - "properties": { - "bar": { - "const": "bar" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "baz": { - "const": "baz" - } - }, - "required": [ - "baz" - ] - }, - { - "properties": { - "quux": { - "const": "quux" - } - }, - "required": [ - "quux" - ] - } - ], - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "when one matches and has no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "when one matches and has unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "not-baz" - }, - "valid": false - }, - { - "description": "when two match and has no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": true - }, - { - "description": "when two match and has unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz", - "quux": "not-quux" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with oneOf", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "oneOf": [ - { - "properties": { - "bar": { - "const": "bar" - } - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "baz": { - "const": "baz" - } - }, - "required": [ - "baz" - ] - } - ], - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "quux": "quux" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with if/then/else", - "schema": { - "type": "object", - "if": { - "properties": { - "foo": { - "const": "then" - } - }, - "required": [ - "foo" - ] - }, - "then": { - "properties": { - "bar": { - "type": "string" - } - }, - "required": [ - "bar" - ] - }, - "else": { - "properties": { - "baz": { - "type": "string" - } - }, - "required": [ - "baz" - ] - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "when if is true and has no unevaluated properties", - "data": { - "foo": "then", - "bar": "bar" - }, - "valid": true - }, - { - "description": "when if is true and has unevaluated properties", - "data": { - "foo": "then", - "bar": "bar", - "baz": "baz" - }, - "valid": false - }, - { - "description": "when if is false and has no unevaluated properties", - "data": { - "baz": "baz" - }, - "valid": true - }, - { - "description": "when if is false and has unevaluated properties", - "data": { - "foo": "else", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with dependentSchemas", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "dependentSchemas": { - "foo": { - "properties": { - "bar": { - "const": "bar" - } - }, - "required": [ - "bar" - ] - } - }, - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "bar": "bar" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with boolean schemas", - "schema": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - }, - "allOf": [ - true - ], - "unevaluatedProperties": false - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "bar": "bar" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties with $ref", - "schema": { - "type": "object", - "$ref": "#/$defs/bar", - "properties": { - "foo": { - "type": "string" - } - }, - "unevaluatedProperties": false, - "$defs": { - "bar": { - "properties": { - "bar": { - "type": "string" - } - } - } - } - }, - "tests": [ - { - "description": "with no unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "with unevaluated properties", - "data": { - "foo": "foo", - "bar": "bar", - "baz": "baz" - }, - "valid": false - } - ] - }, - { - "description": "unevaluatedProperties can't see inside cousins", - "schema": { - "allOf": [ - { - "properties": { - "foo": true - } - }, - { - "unevaluatedProperties": false - } - ] - }, - "tests": [ - { - "description": "always fails", - "data": { - "foo": 1 - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft2019-09/uniqueItems.json b/src/test/resources/tck/draft2019-09/uniqueItems.json deleted file mode 100644 index 55aa0533..00000000 --- a/src/test/resources/tck/draft2019-09/uniqueItems.json +++ /dev/null @@ -1,743 +0,0 @@ -[ - { - "description": "uniqueItems validation", - "schema": { - "uniqueItems": true - }, - "tests": [ - { - "description": "unique array of integers is valid", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "non-unique array of integers is invalid", - "data": [ - 1, - 1 - ], - "valid": false - }, - { - "description": "numbers are unique if mathematically unequal", - "data": [ - 1.0, - 1.00, - 1 - ], - "valid": false - }, - { - "description": "false is not equal to zero", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "true is not equal to one", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "unique array of objects is valid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "baz" - } - ], - "valid": true - }, - { - "description": "non-unique array of objects is invalid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "bar" - } - ], - "valid": false - }, - { - "description": "unique array of nested objects is valid", - "data": [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": false - } - } - } - ], - "valid": true - }, - { - "description": "non-unique array of nested objects is invalid", - "data": [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": true - } - } - } - ], - "valid": false - }, - { - "description": "unique array of arrays is valid", - "data": [ - [ - "foo" - ], - [ - "bar" - ] - ], - "valid": true - }, - { - "description": "non-unique array of arrays is invalid", - "data": [ - [ - "foo" - ], - [ - "foo" - ] - ], - "valid": false - }, - { - "description": "1 and true are unique", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "0 and false are unique", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "[1] and [true] are unique", - "data": [ - [ - 1 - ], - [ - true - ] - ], - "valid": true - }, - { - "description": "[0] and [false] are unique", - "data": [ - [ - 0 - ], - [ - false - ] - ], - "valid": true - }, - { - "description": "nested [1] and [true] are unique", - "data": [ - [ - [ - 1 - ], - "foo" - ], - [ - [ - true - ], - "foo" - ] - ], - "valid": true - }, - { - "description": "nested [0] and [false] are unique", - "data": [ - [ - [ - 0 - ], - "foo" - ], - [ - [ - false - ], - "foo" - ] - ], - "valid": true - }, - { - "description": "unique heterogeneous types are valid", - "data": [ - {}, - [ - 1 - ], - true, - null, - 1, - "{}" - ], - "valid": true - }, - { - "description": "non-unique heterogeneous types are invalid", - "data": [ - {}, - [ - 1 - ], - true, - null, - {}, - 1 - ], - "valid": false - }, - { - "description": "different objects are unique", - "data": [ - { - "a": 1, - "b": 2 - }, - { - "a": 2, - "b": 1 - } - ], - "valid": true - }, - { - "description": "objects are non-unique despite key order", - "data": [ - { - "a": 1, - "b": 2 - }, - { - "b": 2, - "a": 1 - } - ], - "valid": false - } - ] - }, - { - "description": "uniqueItems with an array of items", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is not valid", - "data": [ - false, - false - ], - "valid": false - }, - { - "description": "[true, true] from items array is not valid", - "data": [ - true, - true - ], - "valid": false - }, - { - "description": "unique array extended from [false, true] is valid", - "data": [ - false, - true, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "unique array extended from [true, false] is valid", - "data": [ - true, - false, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "non-unique array extended from [false, true] is not valid", - "data": [ - false, - true, - "foo", - "foo" - ], - "valid": false - }, - { - "description": "non-unique array extended from [true, false] is not valid", - "data": [ - true, - false, - "foo", - "foo" - ], - "valid": false - } - ] - }, - { - "description": "uniqueItems with an array of items and additionalItems=false", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is not valid", - "data": [ - false, - false - ], - "valid": false - }, - { - "description": "[true, true] from items array is not valid", - "data": [ - true, - true - ], - "valid": false - }, - { - "description": "extra items are invalid even if unique", - "data": [ - false, - true, - null - ], - "valid": false - } - ] - }, - { - "description": "uniqueItems=false validation", - "schema": { - "uniqueItems": false - }, - "tests": [ - { - "description": "unique array of integers is valid", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "non-unique array of integers is valid", - "data": [ - 1, - 1 - ], - "valid": true - }, - { - "description": "numbers are unique if mathematically unequal", - "data": [ - 1.0, - 1.00, - 1 - ], - "valid": true - }, - { - "description": "false is not equal to zero", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "true is not equal to one", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "unique array of objects is valid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "baz" - } - ], - "valid": true - }, - { - "description": "non-unique array of objects is valid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "bar" - } - ], - "valid": true - }, - { - "description": "unique array of nested objects is valid", - "data": [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": false - } - } - } - ], - "valid": true - }, - { - "description": "non-unique array of nested objects is valid", - "data": [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": true - } - } - } - ], - "valid": true - }, - { - "description": "unique array of arrays is valid", - "data": [ - [ - "foo" - ], - [ - "bar" - ] - ], - "valid": true - }, - { - "description": "non-unique array of arrays is valid", - "data": [ - [ - "foo" - ], - [ - "foo" - ] - ], - "valid": true - }, - { - "description": "1 and true are unique", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "0 and false are unique", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "unique heterogeneous types are valid", - "data": [ - {}, - [ - 1 - ], - true, - null, - 1 - ], - "valid": true - }, - { - "description": "non-unique heterogeneous types are valid", - "data": [ - {}, - [ - 1 - ], - true, - null, - {}, - 1 - ], - "valid": true - } - ] - }, - { - "description": "uniqueItems=false with an array of items", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is valid", - "data": [ - false, - false - ], - "valid": true - }, - { - "description": "[true, true] from items array is valid", - "data": [ - true, - true - ], - "valid": true - }, - { - "description": "unique array extended from [false, true] is valid", - "data": [ - false, - true, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "unique array extended from [true, false] is valid", - "data": [ - true, - false, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "non-unique array extended from [false, true] is valid", - "data": [ - false, - true, - "foo", - "foo" - ], - "valid": true - }, - { - "description": "non-unique array extended from [true, false] is valid", - "data": [ - true, - false, - "foo", - "foo" - ], - "valid": true - } - ] - }, - { - "description": "uniqueItems=false with an array of items and additionalItems=false", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is valid", - "data": [ - false, - false - ], - "valid": true - }, - { - "description": "[true, true] from items array is valid", - "data": [ - true, - true - ], - "valid": true - }, - { - "description": "extra items are invalid even if unique", - "data": [ - false, - true, - null - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/additionalItems.json b/src/test/resources/tck/draft7/additionalItems.json deleted file mode 100644 index c626d7ac..00000000 --- a/src/test/resources/tck/draft7/additionalItems.json +++ /dev/null @@ -1,178 +0,0 @@ -[ - { - "description": "additionalItems as schema", - "schema": { - "items": [{}], - "additionalItems": {"type": "integer"} - }, - "tests": [ - { - "description": "additional items match schema", - "data": [ null, 2, 3, 4 ], - "valid": true - }, - { - "description": "additional items do not match schema", - "data": [ null, 2, 3, "foo" ], - "valid": false - } - ] - }, - { - "description": "items is schema, no additionalItems", - "schema": { - "items": {}, - "additionalItems": false - }, - "tests": [ - { - "description": "all items match schema", - "data": [ 1, 2, 3, 4, 5 ], - "valid": true - } - ] - }, - { - "description": "array of items with no additionalItems", - "schema": { - "items": [{}, {}, {}], - "additionalItems": false - }, - "tests": [ - { - "description": "empty array", - "data": [], - "valid": true - }, - { - "description": "fewer number of items present (1)", - "data": [ - 1 - ], - "valid": true - }, - { - "description": "fewer number of items present (2)", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "equal number of items present", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "additional items are not permitted", - "data": [ 1, 2, 3, 4 ], - "valid": false - } - ] - }, - { - "description": "additionalItems as false without items", - "schema": {"additionalItems": false}, - "tests": [ - { - "description": - "items defaults to empty schema so everything is valid", - "data": [ 1, 2, 3, 4, 5 ], - "valid": true - }, - { - "description": "ignores non-arrays", - "data": {"foo" : "bar"}, - "valid": true - } - ] - }, - { - "description": "additionalItems are allowed by default", - "schema": { - "items": [ - { - "type": "integer" - } - ] - }, - "tests": [ - { - "description": "only the first item is validated", - "data": [ - 1, - "foo", - false - ], - "valid": true - } - ] - }, - { - "description": "additionalItems should not look in applicators, valid case", - "schema": { - "allOf": [ - { - "items": [ - { - "type": "integer" - } - ] - } - ], - "additionalItems": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "items defined in allOf are not examined", - "data": [ - 1, - null - ], - "valid": true - } - ] - }, - { - "description": "additionalItems should not look in applicators, invalid case", - "schema": { - "allOf": [ - { - "items": [ - { - "type": "integer" - }, - { - "type": "string" - } - ] - } - ], - "items": [ - { - "type": "integer" - } - ], - "additionalItems": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "items defined in allOf are not examined", - "data": [ - 1, - "hello" - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/additionalProperties.json b/src/test/resources/tck/draft7/additionalProperties.json deleted file mode 100644 index 6175c77e..00000000 --- a/src/test/resources/tck/draft7/additionalProperties.json +++ /dev/null @@ -1,151 +0,0 @@ -[ - { - "description": - "additionalProperties being false does not allow other properties", - "schema": { - "properties": {"foo": {}, "bar": {}}, - "patternProperties": { "^v": {} }, - "additionalProperties": false - }, - "tests": [ - { - "description": "no additional properties is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "an additional property is invalid", - "data": {"foo" : 1, "bar" : 2, "quux" : "boom"}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [1, 2, 3], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobarbaz", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - }, - { - "description": "patternProperties are not additional properties", - "data": {"foo":1, "vroom": 2}, - "valid": true - } - ] - }, - { - "description": "non-ASCII pattern with additionalProperties", - "schema": { - "patternProperties": {"^á": {}}, - "additionalProperties": false - }, - "tests": [ - { - "description": "matching the pattern is valid", - "data": {"ármányos": 2}, - "valid": true - }, - { - "description": "not matching the pattern is invalid", - "data": {"élmény": 2}, - "valid": false - } - ] - }, - { - "description": - "additionalProperties allows a schema which should validate", - "schema": { - "properties": {"foo": {}, "bar": {}}, - "additionalProperties": {"type": "boolean"} - }, - "tests": [ - { - "description": "no additional properties is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "an additional valid property is valid", - "data": {"foo" : 1, "bar" : 2, "quux" : true}, - "valid": true - }, - { - "description": "an additional invalid property is invalid", - "data": {"foo" : 1, "bar" : 2, "quux" : 12}, - "valid": false - } - ] - }, - { - "description": - "additionalProperties can exist by itself", - "schema": { - "additionalProperties": {"type": "boolean"} - }, - "tests": [ - { - "description": "an additional valid property is valid", - "data": {"foo" : true}, - "valid": true - }, - { - "description": "an additional invalid property is invalid", - "data": {"foo" : 1}, - "valid": false - } - ] - }, - { - "description": "additionalProperties are allowed by default", - "schema": { - "properties": { - "foo": {}, - "bar": {} - } - }, - "tests": [ - { - "description": "additional properties are allowed", - "data": { - "foo": 1, - "bar": 2, - "quux": true - }, - "valid": true - } - ] - }, - { - "description": "additionalProperties should not look in applicators", - "schema": { - "allOf": [ - { - "properties": { - "foo": {} - } - } - ], - "additionalProperties": { - "type": "boolean" - } - }, - "tests": [ - { - "description": "properties defined in allOf are not examined", - "data": { - "foo": 1, - "bar": true - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/allOf.json b/src/test/resources/tck/draft7/allOf.json deleted file mode 100644 index 99cc2689..00000000 --- a/src/test/resources/tck/draft7/allOf.json +++ /dev/null @@ -1,315 +0,0 @@ -[ - { - "description": "allOf", - "schema": { - "allOf": [ - { - "properties": { - "bar": {"type": "integer"} - }, - "required": ["bar"] - }, - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - } - ] - }, - "tests": [ - { - "description": "allOf", - "data": {"foo": "baz", "bar": 2}, - "valid": true - }, - { - "description": "mismatch second", - "data": {"foo": "baz"}, - "valid": false - }, - { - "description": "mismatch first", - "data": {"bar": 2}, - "valid": false - }, - { - "description": "wrong type", - "data": {"foo": "baz", "bar": "quux"}, - "valid": false - } - ] - }, - { - "description": "allOf with base schema", - "schema": { - "properties": {"bar": {"type": "integer"}}, - "required": ["bar"], - "allOf" : [ - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - }, - { - "properties": { - "baz": {"type": "null"} - }, - "required": ["baz"] - } - ] - }, - "tests": [ - { - "description": "valid", - "data": {"foo": "quux", "bar": 2, "baz": null}, - "valid": true - }, - { - "description": "mismatch base schema", - "data": {"foo": "quux", "baz": null}, - "valid": false - }, - { - "description": "mismatch first allOf", - "data": {"bar": 2, "baz": null}, - "valid": false - }, - { - "description": "mismatch second allOf", - "data": {"foo": "quux", "bar": 2}, - "valid": false - }, - { - "description": "mismatch both", - "data": {"bar": 2}, - "valid": false - } - ] - }, - { - "description": "allOf simple types", - "schema": { - "allOf": [ - {"maximum": 30}, - {"minimum": 20} - ] - }, - "tests": [ - { - "description": "valid", - "data": 25, - "valid": true - }, - { - "description": "mismatch one", - "data": 35, - "valid": false - } - ] - }, - { - "description": "allOf with boolean schemas, all true", - "schema": {"allOf": [true, true]}, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "allOf with boolean schemas, some false", - "schema": {"allOf": [true, false]}, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "allOf with boolean schemas, all false", - "schema": { - "allOf": [ - false, - false - ] - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "allOf with one empty schema", - "schema": { - "allOf": [ - {} - ] - }, - "tests": [ - { - "description": "any data is valid", - "data": 1, - "valid": true - } - ] - }, - { - "description": "allOf with two empty schemas", - "schema": { - "allOf": [ - {}, - {} - ] - }, - "tests": [ - { - "description": "any data is valid", - "data": 1, - "valid": true - } - ] - }, - { - "description": "allOf with the first empty schema", - "schema": { - "allOf": [ - {}, - { - "type": "number" - } - ] - }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "allOf with the last empty schema", - "schema": { - "allOf": [ - { - "type": "number" - }, - {} - ] - }, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "nested allOf, to check validation semantics", - "schema": { - "allOf": [ - { - "allOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "allOf combined with anyOf, oneOf", - "schema": { - "allOf": [ - { - "multipleOf": 2 - } - ], - "anyOf": [ - { - "multipleOf": 3 - } - ], - "oneOf": [ - { - "multipleOf": 5 - } - ] - }, - "tests": [ - { - "description": "allOf: false, anyOf: false, oneOf: false", - "data": 1, - "valid": false - }, - { - "description": "allOf: false, anyOf: false, oneOf: true", - "data": 5, - "valid": false - }, - { - "description": "allOf: false, anyOf: true, oneOf: false", - "data": 3, - "valid": false - }, - { - "description": "allOf: false, anyOf: true, oneOf: true", - "data": 15, - "valid": false - }, - { - "description": "allOf: true, anyOf: false, oneOf: false", - "data": 2, - "valid": false - }, - { - "description": "allOf: true, anyOf: false, oneOf: true", - "data": 10, - "valid": false - }, - { - "description": "allOf: true, anyOf: true, oneOf: false", - "data": 6, - "valid": false - }, - { - "description": "allOf: true, anyOf: true, oneOf: true", - "data": 30, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/anyOf.json b/src/test/resources/tck/draft7/anyOf.json deleted file mode 100644 index 993bce45..00000000 --- a/src/test/resources/tck/draft7/anyOf.json +++ /dev/null @@ -1,223 +0,0 @@ -[ - { - "description": "anyOf", - "schema": { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - }, - "tests": [ - { - "description": "first anyOf valid", - "data": 1, - "valid": true - }, - { - "description": "second anyOf valid", - "data": 2.5, - "valid": true - }, - { - "description": "both anyOf valid", - "data": 3, - "valid": true - }, - { - "description": "neither anyOf valid", - "data": 1.5, - "valid": false - } - ] - }, - { - "description": "anyOf with base schema", - "schema": { - "type": "string", - "anyOf" : [ - { - "maxLength": 2 - }, - { - "minLength": 4 - } - ] - }, - "tests": [ - { - "description": "mismatch base schema", - "data": 3, - "valid": false - }, - { - "description": "one anyOf valid", - "data": "foobar", - "valid": true - }, - { - "description": "both anyOf invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "anyOf with boolean schemas, all true", - "schema": {"anyOf": [true, true]}, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "anyOf with boolean schemas, some true", - "schema": {"anyOf": [true, false]}, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "anyOf with boolean schemas, all false", - "schema": {"anyOf": [false, false]}, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "anyOf complex types", - "schema": { - "anyOf": [ - { - "properties": { - "bar": {"type": "integer"} - }, - "required": ["bar"] - }, - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - } - ] - }, - "tests": [ - { - "description": "first anyOf valid (complex)", - "data": {"bar": 2}, - "valid": true - }, - { - "description": "second anyOf valid (complex)", - "data": {"foo": "baz"}, - "valid": true - }, - { - "description": "both anyOf valid (complex)", - "data": { - "foo": "baz", - "bar": 2 - }, - "valid": true - }, - { - "description": "neither anyOf valid (complex)", - "data": { - "foo": 2, - "bar": "quux" - }, - "valid": false - } - ] - }, - { - "description": "anyOf with one empty schema", - "schema": { - "anyOf": [ - { - "type": "number" - }, - {} - ] - }, - "tests": [ - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "number is valid", - "data": 123, - "valid": true - } - ] - }, - { - "description": "nested anyOf, to check validation semantics", - "schema": { - "anyOf": [ - { - "anyOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "nested anyOf, to check validation semantics", - "schema": { - "anyOf": [ - { - "anyOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/boolean_schema.json b/src/test/resources/tck/draft7/boolean_schema.json deleted file mode 100644 index 6d40f23f..00000000 --- a/src/test/resources/tck/draft7/boolean_schema.json +++ /dev/null @@ -1,104 +0,0 @@ -[ - { - "description": "boolean schema 'true'", - "schema": true, - "tests": [ - { - "description": "number is valid", - "data": 1, - "valid": true - }, - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "boolean true is valid", - "data": true, - "valid": true - }, - { - "description": "boolean false is valid", - "data": false, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "object is valid", - "data": {"foo": "bar"}, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - }, - { - "description": "array is valid", - "data": ["foo"], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "boolean schema 'false'", - "schema": false, - "tests": [ - { - "description": "number is invalid", - "data": 1, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "boolean true is invalid", - "data": true, - "valid": false - }, - { - "description": "boolean false is invalid", - "data": false, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - }, - { - "description": "object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "array is invalid", - "data": ["foo"], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/const.json b/src/test/resources/tck/draft7/const.json deleted file mode 100644 index 33919b93..00000000 --- a/src/test/resources/tck/draft7/const.json +++ /dev/null @@ -1,272 +0,0 @@ -[ - { - "description": "const validation", - "schema": {"const": 2}, - "tests": [ - { - "description": "same value is valid", - "data": 2, - "valid": true - }, - { - "description": "another value is invalid", - "data": 5, - "valid": false - }, - { - "description": "another type is invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "const with object", - "schema": {"const": {"foo": "bar", "baz": "bax"}}, - "tests": [ - { - "description": "same object is valid", - "data": {"foo": "bar", "baz": "bax"}, - "valid": true - }, - { - "description": "same object with different property order is valid", - "data": {"baz": "bax", "foo": "bar"}, - "valid": true - }, - { - "description": "another object is invalid", - "data": {"foo": "bar"}, - "valid": false - }, - { - "description": "another type is invalid", - "data": [1, 2], - "valid": false - } - ] - }, - { - "description": "const with array", - "schema": {"const": [{ "foo": "bar" }]}, - "tests": [ - { - "description": "same array is valid", - "data": [{"foo": "bar"}], - "valid": true - }, - { - "description": "another array item is invalid", - "data": [2], - "valid": false - }, - { - "description": "array with additional items is invalid", - "data": [1, 2, 3], - "valid": false - } - ] - }, - { - "description": "const with null", - "schema": {"const": null}, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "not null is invalid", - "data": 0, - "valid": false - } - ] - }, - { - "description": "const with false does not match 0", - "schema": { - "const": false - }, - "tests": [ - { - "description": "false is valid", - "data": false, - "valid": true - }, - { - "description": "integer zero is invalid", - "data": 0, - "valid": false - }, - { - "description": "float zero is invalid", - "data": 0.0, - "valid": false - } - ] - }, - { - "description": "const with true does not match 1", - "schema": { - "const": true - }, - "tests": [ - { - "description": "true is valid", - "data": true, - "valid": true - }, - { - "description": "integer one is invalid", - "data": 1, - "valid": false - }, - { - "description": "float one is invalid", - "data": 1.0, - "valid": false - } - ] - }, - { - "description": "const with 0 does not match other zero-like types", - "schema": { - "const": 0 - }, - "tests": [ - { - "description": "false is invalid", - "data": false, - "valid": false - }, - { - "description": "integer zero is valid", - "data": 0, - "valid": true - }, - { - "description": "float zero is valid", - "data": 0.0, - "valid": true - }, - { - "description": "empty object is invalid", - "data": {}, - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - }, - { - "description": "empty string is invalid", - "data": "", - "valid": false - } - ] - }, - { - "description": "const with 1 does not match true", - "schema": { - "const": 1 - }, - "tests": [ - { - "description": "true is invalid", - "data": true, - "valid": false - }, - { - "description": "integer one is valid", - "data": 1, - "valid": true - }, - { - "description": "float one is valid", - "data": 1.0, - "valid": true - } - ] - }, - { - "description": "const with -2.0 matches integer and float types", - "schema": { - "const": -2.0 - }, - "tests": [ - { - "description": "integer -2 is valid", - "data": -2, - "valid": true - }, - { - "description": "integer 2 is invalid", - "data": 2, - "valid": false - }, - { - "description": "float -2.0 is valid", - "data": -2.0, - "valid": true - }, - { - "description": "float 2.0 is invalid", - "data": 2.0, - "valid": false - }, - { - "description": "float -2.00001 is invalid", - "data": -2.00001, - "valid": false - } - ] - }, - { - "description": "float and integers are equal up to 64-bit representation limits", - "schema": { - "const": 9007199254740992 - }, - "tests": [ - { - "description": "integer is valid", - "data": 9007199254740992, - "valid": true - }, - { - "description": "integer minus one is invalid", - "data": 9007199254740991, - "valid": false - }, - { - "description": "float is valid", - "data": 9007199254740992.0, - "valid": true - }, - { - "description": "float minus one is invalid", - "data": 9007199254740991.0, - "valid": false - } - ] - }, - { - "description": "nul characters in strings", - "schema": { - "const": "hello\u0000there" - }, - "tests": [ - { - "description": "match string with nul", - "data": "hello\u0000there", - "valid": true - }, - { - "description": "do not match string lacking nul", - "data": "hellothere", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/contains.json b/src/test/resources/tck/draft7/contains.json deleted file mode 100644 index e58eb24e..00000000 --- a/src/test/resources/tck/draft7/contains.json +++ /dev/null @@ -1,149 +0,0 @@ -[ - { - "description": "contains keyword validation", - "schema": { - "contains": {"minimum": 5} - }, - "tests": [ - { - "description": "array with item matching schema (5) is valid", - "data": [3, 4, 5], - "valid": true - }, - { - "description": "array with item matching schema (6) is valid", - "data": [3, 4, 6], - "valid": true - }, - { - "description": "array with two items matching schema (5, 6) is valid", - "data": [3, 4, 5, 6], - "valid": true - }, - { - "description": "array without items matching schema is invalid", - "data": [2, 3, 4], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - }, - { - "description": "not array is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "contains keyword with const keyword", - "schema": { - "contains": { "const": 5 } - }, - "tests": [ - { - "description": "array with item 5 is valid", - "data": [3, 4, 5], - "valid": true - }, - { - "description": "array with two items 5 is valid", - "data": [3, 4, 5, 5], - "valid": true - }, - { - "description": "array without item 5 is invalid", - "data": [1, 2, 3, 4], - "valid": false - } - ] - }, - { - "description": "contains keyword with boolean schema true", - "schema": {"contains": true}, - "tests": [ - { - "description": "any non-empty array is valid", - "data": ["foo"], - "valid": true - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - } - ] - }, - { - "description": "contains keyword with boolean schema false", - "schema": {"contains": false}, - "tests": [ - { - "description": "any non-empty array is invalid", - "data": [ - "foo" - ], - "valid": false - }, - { - "description": "empty array is invalid", - "data": [], - "valid": false - }, - { - "description": "non-arrays are valid", - "data": "contains does not apply to strings", - "valid": true - } - ] - }, - { - "description": "items + contains", - "schema": { - "items": { - "multipleOf": 2 - }, - "contains": { - "multipleOf": 3 - } - }, - "tests": [ - { - "description": "matches items, does not match contains", - "data": [ - 2, - 4, - 8 - ], - "valid": false - }, - { - "description": "does not match items, matches contains", - "data": [ - 3, - 6, - 9 - ], - "valid": false - }, - { - "description": "matches both items and contains", - "data": [ - 6, - 12 - ], - "valid": true - }, - { - "description": "matches neither items nor contains", - "data": [ - 1, - 5 - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/default.json b/src/test/resources/tck/draft7/default.json deleted file mode 100644 index 17629779..00000000 --- a/src/test/resources/tck/draft7/default.json +++ /dev/null @@ -1,49 +0,0 @@ -[ - { - "description": "invalid type for default", - "schema": { - "properties": { - "foo": { - "type": "integer", - "default": [] - } - } - }, - "tests": [ - { - "description": "valid when property is specified", - "data": {"foo": 13}, - "valid": true - }, - { - "description": "still valid when the invalid default is used", - "data": {}, - "valid": true - } - ] - }, - { - "description": "invalid string value for default", - "schema": { - "properties": { - "bar": { - "type": "string", - "minLength": 4, - "default": "bad" - } - } - }, - "tests": [ - { - "description": "valid when property is specified", - "data": {"bar": "good"}, - "valid": true - }, - { - "description": "still valid when the invalid default is used", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/definitions.json b/src/test/resources/tck/draft7/definitions.json deleted file mode 100644 index 43604065..00000000 --- a/src/test/resources/tck/draft7/definitions.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "description": "valid definition", - "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, - "tests": [ - { - "description": "valid definition schema", - "data": { - "definitions": { - "foo": {"type": "integer"} - } - }, - "valid": true - } - ] - }, - { - "description": "invalid definition", - "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, - "tests": [ - { - "description": "invalid definition schema", - "data": { - "definitions": { - "foo": {"type": 1} - } - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/dependencies.json b/src/test/resources/tck/draft7/dependencies.json deleted file mode 100644 index 6bee89d7..00000000 --- a/src/test/resources/tck/draft7/dependencies.json +++ /dev/null @@ -1,261 +0,0 @@ -[ - { - "description": "dependencies", - "schema": { - "dependencies": {"bar": ["foo"]} - }, - "tests": [ - { - "description": "neither", - "data": {}, - "valid": true - }, - { - "description": "nondependant", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "with dependency", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "missing dependency", - "data": {"bar": 2}, - "valid": false - }, - { - "description": "ignores arrays", - "data": ["bar"], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "dependencies with empty array", - "schema": { - "dependencies": {"bar": []} - }, - "tests": [ - { - "description": "empty object", - "data": {}, - "valid": true - }, - { - "description": "object with one property", - "data": { - "bar": 2 - }, - "valid": true - }, - { - "description": "non-object is valid", - "data": 1, - "valid": true - } - ] - }, - { - "description": "multiple dependencies", - "schema": { - "dependencies": {"quux": ["foo", "bar"]} - }, - "tests": [ - { - "description": "neither", - "data": {}, - "valid": true - }, - { - "description": "nondependants", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "with dependencies", - "data": {"foo": 1, "bar": 2, "quux": 3}, - "valid": true - }, - { - "description": "missing dependency", - "data": {"foo": 1, "quux": 2}, - "valid": false - }, - { - "description": "missing other dependency", - "data": {"bar": 1, "quux": 2}, - "valid": false - }, - { - "description": "missing both dependencies", - "data": {"quux": 1}, - "valid": false - } - ] - }, - { - "description": "multiple dependencies subschema", - "schema": { - "dependencies": { - "bar": { - "properties": { - "foo": {"type": "integer"}, - "bar": {"type": "integer"} - } - } - } - }, - "tests": [ - { - "description": "valid", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "no dependency", - "data": {"foo": "quux"}, - "valid": true - }, - { - "description": "wrong type", - "data": {"foo": "quux", "bar": 2}, - "valid": false - }, - { - "description": "wrong type other", - "data": {"foo": 2, "bar": "quux"}, - "valid": false - }, - { - "description": "wrong type both", - "data": {"foo": "quux", "bar": "quux"}, - "valid": false - } - ] - }, - { - "description": "dependencies with boolean subschemas", - "schema": { - "dependencies": { - "foo": true, - "bar": false - } - }, - "tests": [ - { - "description": "object with property having schema true is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with property having schema false is invalid", - "data": {"bar": 2}, - "valid": false - }, - { - "description": "object with both properties is invalid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "dependencies with escaped characters", - "schema": { - "dependencies": { - "foo\nbar": [ - "foo\rbar" - ], - "foo\tbar": { - "minProperties": 4 - }, - "foo'bar": { - "required": [ - "foo\"bar" - ] - }, - "foo\"bar": [ - "foo'bar" - ] - } - }, - "tests": [ - { - "description": "valid object 1", - "data": { - "foo\nbar": 1, - "foo\rbar": 2 - }, - "valid": true - }, - { - "description": "valid object 2", - "data": { - "foo\tbar": 1, - "a": 2, - "b": 3, - "c": 4 - }, - "valid": true - }, - { - "description": "valid object 3", - "data": { - "foo'bar": 1, - "foo\"bar": 2 - }, - "valid": true - }, - { - "description": "invalid object 1", - "data": { - "foo\nbar": 1, - "foo": 2 - }, - "valid": false - }, - { - "description": "invalid object 2", - "data": { - "foo\tbar": 1, - "a": 2 - }, - "valid": false - }, - { - "description": "invalid object 3", - "data": { - "foo'bar": 1 - }, - "valid": false - }, - { - "description": "invalid object 4", - "data": { - "foo\"bar": 2 - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/enum.json b/src/test/resources/tck/draft7/enum.json deleted file mode 100644 index a56b9629..00000000 --- a/src/test/resources/tck/draft7/enum.json +++ /dev/null @@ -1,273 +0,0 @@ -[ - { - "description": "simple enum validation", - "schema": {"enum": [1, 2, 3]}, - "tests": [ - { - "description": "one of the enum is valid", - "data": 1, - "valid": true - }, - { - "description": "something else is invalid", - "data": 4, - "valid": false - } - ] - }, - { - "description": "heterogeneous enum validation", - "schema": {"enum": [6, "foo", [], true, {"foo": 12}]}, - "tests": [ - { - "description": "one of the enum is valid", - "data": [], - "valid": true - }, - { - "description": "something else is invalid", - "data": null, - "valid": false - }, - { - "description": "objects are deep compared", - "data": { - "foo": false - }, - "valid": false - } - ] - }, - { - "description": "heterogeneous enum-with-null validation", - "schema": { - "enum": [ - 6, - null - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "number is valid", - "data": 6, - "valid": true - }, - { - "description": "something else is invalid", - "data": "test", - "valid": false - } - ] - }, - { - "description": "enums in properties", - "schema": { - "type": "object", - "properties": { - "foo": { - "enum": [ - "foo" - ] - }, - "bar": {"enum":["bar"]} - }, - "required": ["bar"] - }, - "tests": [ - { - "description": "both properties are valid", - "data": { - "foo": "foo", - "bar": "bar" - }, - "valid": true - }, - { - "description": "wrong foo value", - "data": { - "foo": "foot", - "bar": "bar" - }, - "valid": false - }, - { - "description": "wrong bar value", - "data": { - "foo": "foo", - "bar": "bart" - }, - "valid": false - }, - { - "description": "missing optional property is valid", - "data": { - "bar": "bar" - }, - "valid": true - }, - { - "description": "missing required property is invalid", - "data": { - "foo": "foo" - }, - "valid": false - }, - { - "description": "missing all properties is invalid", - "data": {}, - "valid": false - } - ] - }, - { - "description": "enum with escaped characters", - "schema": { - "enum": [ - "foo\nbar", - "foo\rbar" - ] - }, - "tests": [ - { - "description": "member 1 is valid", - "data": "foo\nbar", - "valid": true - }, - { - "description": "member 2 is valid", - "data": "foo\rbar", - "valid": true - }, - { - "description": "another string is invalid", - "data": "abc", - "valid": false - } - ] - }, - { - "description": "enum with false does not match 0", - "schema": { - "enum": [ - false - ] - }, - "tests": [ - { - "description": "false is valid", - "data": false, - "valid": true - }, - { - "description": "integer zero is invalid", - "data": 0, - "valid": false - }, - { - "description": "float zero is invalid", - "data": 0.0, - "valid": false - } - ] - }, - { - "description": "enum with true does not match 1", - "schema": { - "enum": [ - true - ] - }, - "tests": [ - { - "description": "true is valid", - "data": true, - "valid": true - }, - { - "description": "integer one is invalid", - "data": 1, - "valid": false - }, - { - "description": "float one is invalid", - "data": 1.0, - "valid": false - } - ] - }, - { - "description": "enum with 0 does not match false", - "schema": { - "enum": [ - 0 - ] - }, - "tests": [ - { - "description": "false is invalid", - "data": false, - "valid": false - }, - { - "description": "integer zero is valid", - "data": 0, - "valid": true - }, - { - "description": "float zero is valid", - "data": 0.0, - "valid": true - } - ] - }, - { - "description": "enum with 1 does not match true", - "schema": { - "enum": [ - 1 - ] - }, - "tests": [ - { - "description": "true is invalid", - "data": true, - "valid": false - }, - { - "description": "integer one is valid", - "data": 1, - "valid": true - }, - { - "description": "float one is valid", - "data": 1.0, - "valid": true - } - ] - }, - { - "description": "nul characters in strings", - "schema": { - "enum": [ - "hello\u0000there" - ] - }, - "tests": [ - { - "description": "match string with nul", - "data": "hello\u0000there", - "valid": true - }, - { - "description": "do not match string lacking nul", - "data": "hellothere", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/exclusiveMaximum.json b/src/test/resources/tck/draft7/exclusiveMaximum.json deleted file mode 100644 index dc3cd709..00000000 --- a/src/test/resources/tck/draft7/exclusiveMaximum.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "exclusiveMaximum validation", - "schema": { - "exclusiveMaximum": 3.0 - }, - "tests": [ - { - "description": "below the exclusiveMaximum is valid", - "data": 2.2, - "valid": true - }, - { - "description": "boundary point is invalid", - "data": 3.0, - "valid": false - }, - { - "description": "above the exclusiveMaximum is invalid", - "data": 3.5, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/exclusiveMinimum.json b/src/test/resources/tck/draft7/exclusiveMinimum.json deleted file mode 100644 index b38d7ece..00000000 --- a/src/test/resources/tck/draft7/exclusiveMinimum.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "exclusiveMinimum validation", - "schema": { - "exclusiveMinimum": 1.1 - }, - "tests": [ - { - "description": "above the exclusiveMinimum is valid", - "data": 1.2, - "valid": true - }, - { - "description": "boundary point is invalid", - "data": 1.1, - "valid": false - }, - { - "description": "below the exclusiveMinimum is invalid", - "data": 0.6, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/format.json b/src/test/resources/tck/draft7/format.json deleted file mode 100644 index 6e6cd01a..00000000 --- a/src/test/resources/tck/draft7/format.json +++ /dev/null @@ -1,648 +0,0 @@ -[ - { - "description": "validation of e-mail addresses", - "schema": { - "format": "email" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IDN e-mail addresses", - "schema": { - "format": "idn-email" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of regexes", - "schema": { - "format": "regex" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IP addresses", - "schema": { - "format": "ipv4" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IPv6 addresses", - "schema": { - "format": "ipv6" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IDN hostnames", - "schema": { - "format": "idn-hostname" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of hostnames", - "schema": { - "format": "hostname" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of date strings", - "schema": { - "format": "date" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of date-time strings", - "schema": { - "format": "date-time" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of time strings", - "schema": { - "format": "time" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of JSON pointers", - "schema": { - "format": "json-pointer" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of relative JSON pointers", - "schema": { - "format": "relative-json-pointer" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IRIs", - "schema": { - "format": "iri" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of IRI references", - "schema": { - "format": "iri-reference" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of URIs", - "schema": { - "format": "uri" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of URI references", - "schema": { - "format": "uri-reference" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "validation of URI templates", - "schema": { - "format": "uri-template" - }, - "tests": [ - { - "description": "ignores integers", - "data": 12, - "valid": true - }, - { - "description": "ignores floats", - "data": 13.7, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores booleans", - "data": false, - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/if-then-else.json b/src/test/resources/tck/draft7/if-then-else.json deleted file mode 100644 index da5e8ad2..00000000 --- a/src/test/resources/tck/draft7/if-then-else.json +++ /dev/null @@ -1,236 +0,0 @@ -[ - { - "description": "ignore if without then or else", - "schema": { - "if": { - "const": 0 - } - }, - "tests": [ - { - "description": "valid when valid against lone if", - "data": 0, - "valid": true - }, - { - "description": "valid when invalid against lone if", - "data": "hello", - "valid": true - } - ] - }, - { - "description": "ignore then without if", - "schema": { - "then": { - "const": 0 - } - }, - "tests": [ - { - "description": "valid when valid against lone then", - "data": 0, - "valid": true - }, - { - "description": "valid when invalid against lone then", - "data": "hello", - "valid": true - } - ] - }, - { - "description": "ignore else without if", - "schema": { - "else": { - "const": 0 - } - }, - "tests": [ - { - "description": "valid when valid against lone else", - "data": 0, - "valid": true - }, - { - "description": "valid when invalid against lone else", - "data": "hello", - "valid": true - } - ] - }, - { - "description": "if and then without else", - "schema": { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - } - }, - "tests": [ - { - "description": "valid through then", - "data": -1, - "valid": true - }, - { - "description": "invalid through then", - "data": -100, - "valid": false - }, - { - "description": "valid when if test fails", - "data": 3, - "valid": true - } - ] - }, - { - "description": "if and else without then", - "schema": { - "if": { - "exclusiveMaximum": 0 - }, - "else": { - "multipleOf": 2 - } - }, - "tests": [ - { - "description": "valid when if test passes", - "data": -1, - "valid": true - }, - { - "description": "valid through else", - "data": 4, - "valid": true - }, - { - "description": "invalid through else", - "data": 3, - "valid": false - } - ] - }, - { - "description": "validate against correct branch, then vs else", - "schema": { - "if": { - "exclusiveMaximum": 0 - }, - "then": { - "minimum": -10 - }, - "else": { - "multipleOf": 2 - } - }, - "tests": [ - { - "description": "valid through then", - "data": -1, - "valid": true - }, - { - "description": "invalid through then", - "data": -100, - "valid": false - }, - { - "description": "valid through else", - "data": 4, - "valid": true - }, - { - "description": "invalid through else", - "data": 3, - "valid": false - } - ] - }, - { - "description": "non-interference across combined schemas", - "schema": { - "allOf": [ - { - "if": { - "exclusiveMaximum": 0 - } - }, - { - "then": { - "minimum": -10 - } - }, - { - "else": { - "multipleOf": 2 - } - } - ] - }, - "tests": [ - { - "description": "valid, but would have been invalid through then", - "data": -100, - "valid": true - }, - { - "description": "valid, but would have been invalid through else", - "data": 3, - "valid": true - } - ] - }, - { - "description": "if with boolean schema true", - "schema": { - "if": true, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - }, - "tests": [ - { - "description": "boolean schema true in if always chooses the then path (valid)", - "data": "then", - "valid": true - }, - { - "description": "boolean schema true in if always chooses the then path (invalid)", - "data": "else", - "valid": false - } - ] - }, - { - "description": "if with boolean schema false", - "schema": { - "if": false, - "then": { - "const": "then" - }, - "else": { - "const": "else" - } - }, - "tests": [ - { - "description": "boolean schema false in if always chooses the else path (invalid)", - "data": "then", - "valid": false - }, - { - "description": "boolean schema false in if always chooses the else path (valid)", - "data": "else", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/items.json b/src/test/resources/tck/draft7/items.json deleted file mode 100644 index 226872f1..00000000 --- a/src/test/resources/tck/draft7/items.json +++ /dev/null @@ -1,462 +0,0 @@ -[ - { - "description": "a schema given for items", - "schema": { - "items": {"type": "integer"} - }, - "tests": [ - { - "description": "valid items", - "data": [ 1, 2, 3 ], - "valid": true - }, - { - "description": "wrong type of items", - "data": [1, "x"], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": {"foo" : "bar"}, - "valid": true - }, - { - "description": "JavaScript pseudo-array is valid", - "data": { - "0": "invalid", - "length": 1 - }, - "valid": true - } - ] - }, - { - "description": "an array of schemas for items", - "schema": { - "items": [ - {"type": "integer"}, - {"type": "string"} - ] - }, - "tests": [ - { - "description": "correct types", - "data": [ 1, "foo" ], - "valid": true - }, - { - "description": "wrong types", - "data": [ "foo", 1 ], - "valid": false - }, - { - "description": "incomplete array of items", - "data": [ 1 ], - "valid": true - }, - { - "description": "array with additional items", - "data": [ 1, "foo", true ], - "valid": true - }, - { - "description": "empty array", - "data": [ ], - "valid": true - }, - { - "description": "JavaScript pseudo-array is valid", - "data": { - "0": "invalid", - "1": "valid", - "length": 2 - }, - "valid": true - } - ] - }, - { - "description": "items with boolean schema (true)", - "schema": {"items": true}, - "tests": [ - { - "description": "any array is valid", - "data": [ 1, "foo", true ], - "valid": true - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "items with boolean schema (false)", - "schema": {"items": false}, - "tests": [ - { - "description": "any non-empty array is invalid", - "data": [ 1, "foo", true ], - "valid": false - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "items with boolean schemas", - "schema": { - "items": [true, false] - }, - "tests": [ - { - "description": "array with one item is valid", - "data": [ 1 ], - "valid": true - }, - { - "description": "array with two items is invalid", - "data": [ - 1, - "foo" - ], - "valid": false - }, - { - "description": "empty array is valid", - "data": [], - "valid": true - } - ] - }, - { - "description": "items and subitems", - "schema": { - "definitions": { - "item": { - "type": "array", - "additionalItems": false, - "items": [ - { - "$ref": "#/definitions/sub-item" - }, - { - "$ref": "#/definitions/sub-item" - } - ] - }, - "sub-item": { - "type": "object", - "required": [ - "foo" - ] - } - }, - "type": "array", - "additionalItems": false, - "items": [ - { - "$ref": "#/definitions/item" - }, - { - "$ref": "#/definitions/item" - }, - { - "$ref": "#/definitions/item" - } - ] - }, - "tests": [ - { - "description": "valid items", - "data": [ - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": true - }, - { - "description": "too many items", - "data": [ - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "too many sub-items", - "data": [ - [ - { - "foo": null - }, - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "wrong item", - "data": [ - { - "foo": null - }, - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "wrong sub-item", - "data": [ - [ - {}, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ], - [ - { - "foo": null - }, - { - "foo": null - } - ] - ], - "valid": false - }, - { - "description": "fewer items is valid", - "data": [ - [ - { - "foo": null - } - ], - [ - { - "foo": null - } - ] - ], - "valid": true - } - ] - }, - { - "description": "nested items", - "schema": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "array", - "items": { - "type": "number" - } - } - } - } - }, - "tests": [ - { - "description": "valid nested array", - "data": [ - [ - [ - [ - 1 - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - [ - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - ], - "valid": true - }, - { - "description": "nested array with invalid type", - "data": [ - [ - [ - [ - "1" - ] - ], - [ - [ - 2 - ], - [ - 3 - ] - ] - ], - [ - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ] - ], - "valid": false - }, - { - "description": "not deep enough", - "data": [ - [ - [ - 1 - ], - [ - 2 - ], - [ - 3 - ] - ], - [ - [ - 4 - ], - [ - 5 - ], - [ - 6 - ] - ] - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/maxItems.json b/src/test/resources/tck/draft7/maxItems.json deleted file mode 100644 index 3b53a6b3..00000000 --- a/src/test/resources/tck/draft7/maxItems.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "maxItems validation", - "schema": {"maxItems": 2}, - "tests": [ - { - "description": "shorter is valid", - "data": [1], - "valid": true - }, - { - "description": "exact length is valid", - "data": [1, 2], - "valid": true - }, - { - "description": "too long is invalid", - "data": [1, 2, 3], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": "foobar", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/maxLength.json b/src/test/resources/tck/draft7/maxLength.json deleted file mode 100644 index 811d35b2..00000000 --- a/src/test/resources/tck/draft7/maxLength.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "maxLength validation", - "schema": {"maxLength": 2}, - "tests": [ - { - "description": "shorter is valid", - "data": "f", - "valid": true - }, - { - "description": "exact length is valid", - "data": "fo", - "valid": true - }, - { - "description": "too long is invalid", - "data": "foo", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - }, - { - "description": "two supplementary Unicode code points is long enough", - "data": "\uD83D\uDCA9\uD83D\uDCA9", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/maxProperties.json b/src/test/resources/tck/draft7/maxProperties.json deleted file mode 100644 index 5a6775d3..00000000 --- a/src/test/resources/tck/draft7/maxProperties.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "description": "maxProperties validation", - "schema": {"maxProperties": 2}, - "tests": [ - { - "description": "shorter is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "exact length is valid", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "too long is invalid", - "data": {"foo": 1, "bar": 2, "baz": 3}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [1, 2, 3], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "maxProperties = 0 means the object is empty", - "schema": { - "maxProperties": 0 - }, - "tests": [ - { - "description": "no properties is valid", - "data": {}, - "valid": true - }, - { - "description": "one property is invalid", - "data": { - "foo": 1 - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/maximum.json b/src/test/resources/tck/draft7/maximum.json deleted file mode 100644 index d36786a5..00000000 --- a/src/test/resources/tck/draft7/maximum.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "description": "maximum validation", - "schema": {"maximum": 3.0}, - "tests": [ - { - "description": "below the maximum is valid", - "data": 2.6, - "valid": true - }, - { - "description": "boundary point is valid", - "data": 3.0, - "valid": true - }, - { - "description": "above the maximum is invalid", - "data": 3.5, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - }, - { - "description": "maximum validation with unsigned integer", - "schema": { - "maximum": 300 - }, - "tests": [ - { - "description": "below the maximum is invalid", - "data": 299.97, - "valid": true - }, - { - "description": "boundary point integer is valid", - "data": 300, - "valid": true - }, - { - "description": "boundary point float is valid", - "data": 300.00, - "valid": true - }, - { - "description": "above the maximum is invalid", - "data": 300.5, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/minItems.json b/src/test/resources/tck/draft7/minItems.json deleted file mode 100644 index ed511881..00000000 --- a/src/test/resources/tck/draft7/minItems.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "minItems validation", - "schema": {"minItems": 1}, - "tests": [ - { - "description": "longer is valid", - "data": [1, 2], - "valid": true - }, - { - "description": "exact length is valid", - "data": [1], - "valid": true - }, - { - "description": "too short is invalid", - "data": [], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": "", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/minLength.json b/src/test/resources/tck/draft7/minLength.json deleted file mode 100644 index 3f09158d..00000000 --- a/src/test/resources/tck/draft7/minLength.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "minLength validation", - "schema": {"minLength": 2}, - "tests": [ - { - "description": "longer is valid", - "data": "foo", - "valid": true - }, - { - "description": "exact length is valid", - "data": "fo", - "valid": true - }, - { - "description": "too short is invalid", - "data": "f", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 1, - "valid": true - }, - { - "description": "one supplementary Unicode code point is not long enough", - "data": "\uD83D\uDCA9", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/minProperties.json b/src/test/resources/tck/draft7/minProperties.json deleted file mode 100644 index 49a0726e..00000000 --- a/src/test/resources/tck/draft7/minProperties.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "description": "minProperties validation", - "schema": {"minProperties": 1}, - "tests": [ - { - "description": "longer is valid", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "exact length is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "too short is invalid", - "data": {}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores strings", - "data": "", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/minimum.json b/src/test/resources/tck/draft7/minimum.json deleted file mode 100644 index 1a45415a..00000000 --- a/src/test/resources/tck/draft7/minimum.json +++ /dev/null @@ -1,71 +0,0 @@ -[ - { - "description": "minimum validation", - "schema": {"minimum": 1.1}, - "tests": [ - { - "description": "above the minimum is valid", - "data": 2.6, - "valid": true - }, - { - "description": "boundary point is valid", - "data": 1.1, - "valid": true - }, - { - "description": "below the minimum is invalid", - "data": 0.6, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - }, - { - "description": "minimum validation with signed integer", - "schema": { - "minimum": -2 - }, - "tests": [ - { - "description": "negative above the minimum is valid", - "data": -1, - "valid": true - }, - { - "description": "positive above the minimum is valid", - "data": 0, - "valid": true - }, - { - "description": "boundary point is valid", - "data": -2, - "valid": true - }, - { - "description": "boundary point with float is valid", - "data": -2.0, - "valid": true - }, - { - "description": "float below the minimum is invalid", - "data": -2.0001, - "valid": false - }, - { - "description": "int below the minimum is invalid", - "data": -3, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/multipleOf.json b/src/test/resources/tck/draft7/multipleOf.json deleted file mode 100644 index e3d51423..00000000 --- a/src/test/resources/tck/draft7/multipleOf.json +++ /dev/null @@ -1,44 +0,0 @@ -[ - { - "description": "by int", - "schema": {"multipleOf": 2}, - "tests": [ - { - "description": "int by int", - "data": 10, - "valid": true - }, - { - "description": "int by int fail", - "data": 7, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "by number", - "schema": {"multipleOf": 1.5}, - "tests": [ - { - "description": "zero is multiple of anything", - "data": 0, - "valid": true - }, - { - "description": "4.5 is multiple of 1.5", - "data": 4.5, - "valid": true - }, - { - "description": "35 is not multiple of 1.5", - "data": 35, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/not.json b/src/test/resources/tck/draft7/not.json deleted file mode 100644 index 98de0eda..00000000 --- a/src/test/resources/tck/draft7/not.json +++ /dev/null @@ -1,117 +0,0 @@ -[ - { - "description": "not", - "schema": { - "not": {"type": "integer"} - }, - "tests": [ - { - "description": "allowed", - "data": "foo", - "valid": true - }, - { - "description": "disallowed", - "data": 1, - "valid": false - } - ] - }, - { - "description": "not multiple types", - "schema": { - "not": {"type": ["integer", "boolean"]} - }, - "tests": [ - { - "description": "valid", - "data": "foo", - "valid": true - }, - { - "description": "mismatch", - "data": 1, - "valid": false - }, - { - "description": "other mismatch", - "data": true, - "valid": false - } - ] - }, - { - "description": "not more complex schema", - "schema": { - "not": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - }, - "tests": [ - { - "description": "match", - "data": 1, - "valid": true - }, - { - "description": "other match", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "mismatch", - "data": {"foo": "bar"}, - "valid": false - } - ] - }, - { - "description": "forbidden property", - "schema": { - "properties": { - "foo": { - "not": {} - } - } - }, - "tests": [ - { - "description": "property present", - "data": {"foo": 1, "bar": 2}, - "valid": false - }, - { - "description": "property absent", - "data": {"bar": 1, "baz": 2}, - "valid": true - } - ] - }, - { - "description": "not with boolean schema true", - "schema": {"not": true}, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "not with boolean schema false", - "schema": {"not": false}, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/oneOf.json b/src/test/resources/tck/draft7/oneOf.json deleted file mode 100644 index d254e002..00000000 --- a/src/test/resources/tck/draft7/oneOf.json +++ /dev/null @@ -1,317 +0,0 @@ -[ - { - "description": "oneOf", - "schema": { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - }, - "tests": [ - { - "description": "first oneOf valid", - "data": 1, - "valid": true - }, - { - "description": "second oneOf valid", - "data": 2.5, - "valid": true - }, - { - "description": "both oneOf valid", - "data": 3, - "valid": false - }, - { - "description": "neither oneOf valid", - "data": 1.5, - "valid": false - } - ] - }, - { - "description": "oneOf with base schema", - "schema": { - "type": "string", - "oneOf" : [ - { - "minLength": 2 - }, - { - "maxLength": 4 - } - ] - }, - "tests": [ - { - "description": "mismatch base schema", - "data": 3, - "valid": false - }, - { - "description": "one oneOf valid", - "data": "foobar", - "valid": true - }, - { - "description": "both oneOf valid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf with boolean schemas, all true", - "schema": {"oneOf": [true, true, true]}, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf with boolean schemas, one true", - "schema": {"oneOf": [true, false, false]}, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "oneOf with boolean schemas, more than one true", - "schema": {"oneOf": [true, true, false]}, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf with boolean schemas, all false", - "schema": {"oneOf": [false, false, false]}, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf complex types", - "schema": { - "oneOf": [ - { - "properties": { - "bar": {"type": "integer"} - }, - "required": ["bar"] - }, - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - } - ] - }, - "tests": [ - { - "description": "first oneOf valid (complex)", - "data": {"bar": 2}, - "valid": true - }, - { - "description": "second oneOf valid (complex)", - "data": {"foo": "baz"}, - "valid": true - }, - { - "description": "both oneOf valid (complex)", - "data": { - "foo": "baz", - "bar": 2 - }, - "valid": false - }, - { - "description": "neither oneOf valid (complex)", - "data": { - "foo": 2, - "bar": "quux" - }, - "valid": false - } - ] - }, - { - "description": "oneOf with empty schema", - "schema": { - "oneOf": [ - { - "type": "number" - }, - {} - ] - }, - "tests": [ - { - "description": "one valid - valid", - "data": "foo", - "valid": true - }, - { - "description": "both valid - invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "oneOf with required", - "schema": { - "type": "object", - "oneOf": [ - { - "required": [ - "foo", - "bar" - ] - }, - { - "required": [ - "foo", - "baz" - ] - } - ] - }, - "tests": [ - { - "description": "both invalid - invalid", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "first valid - valid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": true - }, - { - "description": "second valid - valid", - "data": { - "foo": 1, - "baz": 3 - }, - "valid": true - }, - { - "description": "both valid - invalid", - "data": { - "foo": 1, - "bar": 2, - "baz": 3 - }, - "valid": false - } - ] - }, - { - "description": "oneOf with missing optional property", - "schema": { - "oneOf": [ - { - "properties": { - "bar": true, - "baz": true - }, - "required": [ - "bar" - ] - }, - { - "properties": { - "foo": true - }, - "required": [ - "foo" - ] - } - ] - }, - "tests": [ - { - "description": "first oneOf valid", - "data": { - "bar": 8 - }, - "valid": true - }, - { - "description": "second oneOf valid", - "data": { - "foo": "foo" - }, - "valid": true - }, - { - "description": "both oneOf valid", - "data": { - "foo": "foo", - "bar": 8 - }, - "valid": false - }, - { - "description": "neither oneOf valid", - "data": { - "baz": "quux" - }, - "valid": false - } - ] - }, - { - "description": "nested oneOf, to check validation semantics", - "schema": { - "oneOf": [ - { - "oneOf": [ - { - "type": "null" - } - ] - } - ] - }, - "tests": [ - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "anything non-null is invalid", - "data": 123, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/bignum.json b/src/test/resources/tck/draft7/optional/bignum.json deleted file mode 100644 index fac275e2..00000000 --- a/src/test/resources/tck/draft7/optional/bignum.json +++ /dev/null @@ -1,105 +0,0 @@ -[ - { - "description": "integer", - "schema": {"type": "integer"}, - "tests": [ - { - "description": "a bignum is an integer", - "data": 12345678910111213141516171819202122232425262728293031, - "valid": true - } - ] - }, - { - "description": "number", - "schema": {"type": "number"}, - "tests": [ - { - "description": "a bignum is a number", - "data": 98249283749234923498293171823948729348710298301928331, - "valid": true - } - ] - }, - { - "description": "integer", - "schema": {"type": "integer"}, - "tests": [ - { - "description": "a negative bignum is an integer", - "data": -12345678910111213141516171819202122232425262728293031, - "valid": true - } - ] - }, - { - "description": "number", - "schema": {"type": "number"}, - "tests": [ - { - "description": "a negative bignum is a number", - "data": -98249283749234923498293171823948729348710298301928331, - "valid": true - } - ] - }, - { - "description": "string", - "schema": {"type": "string"}, - "tests": [ - { - "description": "a bignum is not a string", - "data": 98249283749234923498293171823948729348710298301928331, - "valid": false - } - ] - }, - { - "description": "integer comparison", - "schema": {"maximum": 18446744073709551615}, - "tests": [ - { - "description": "comparison works for high numbers", - "data": 18446744073709551600, - "valid": true - } - ] - }, - { - "description": "float comparison with high precision", - "schema": { - "exclusiveMaximum": 972783798187987123879878123.18878137 - }, - "tests": [ - { - "description": "comparison works for high numbers", - "data": 972783798187987123879878123.188781371, - "valid": false - } - ] - }, - { - "description": "integer comparison", - "schema": {"minimum": -18446744073709551615}, - "tests": [ - { - "description": "comparison works for very negative numbers", - "data": -18446744073709551600, - "valid": true - } - ] - }, - { - "description": "float comparison with high precision on negative numbers", - "schema": { - "exclusiveMinimum": -972783798187987123879878123.18878137 - }, - "tests": [ - { - "description": "comparison works for very negative numbers", - "data": -972783798187987123879878123.188781371, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/collapse_test.js b/src/test/resources/tck/draft7/optional/collapse_test.js deleted file mode 100644 index 29c77cb1..00000000 --- a/src/test/resources/tck/draft7/optional/collapse_test.js +++ /dev/null @@ -1,6 +0,0 @@ -let fs = require('fs'); -let ar = []; - -fs.readdirSync("format").forEach(file => ar = ar.concat(JSON.parse(fs.readFileSync("format/" + file)))); - -console.log(JSON.stringify(ar)) \ No newline at end of file diff --git a/src/test/resources/tck/draft7/optional/content.json b/src/test/resources/tck/draft7/optional/content.json deleted file mode 100644 index 3f5a7430..00000000 --- a/src/test/resources/tck/draft7/optional/content.json +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "description": "validation of string-encoded content based on media type", - "schema": { - "contentMediaType": "application/json" - }, - "tests": [ - { - "description": "a valid JSON document", - "data": "{\"foo\": \"bar\"}", - "valid": true - }, - { - "description": "an invalid JSON document", - "data": "{:}", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - } - ] - }, - { - "description": "validation of binary string-encoding", - "schema": { - "contentEncoding": "base64" - }, - "tests": [ - { - "description": "a valid base64 string", - "data": "eyJmb28iOiAiYmFyIn0K", - "valid": true - }, - { - "description": "an invalid base64 string (% is not a valid character)", - "data": "eyJmb28iOi%iYmFyIn0K", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - } - ] - }, - { - "description": "validation of binary-encoded media type documents", - "schema": { - "contentMediaType": "application/json", - "contentEncoding": "base64" - }, - "tests": [ - { - "description": "a valid base64-encoded JSON document", - "data": "eyJmb28iOiAiYmFyIn0K", - "valid": true - }, - { - "description": "a validly-encoded invalid JSON document", - "data": "ezp9Cg==", - "valid": false - }, - { - "description": "an invalid base64 string that is valid JSON", - "data": "{}", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/ecmascript-regex.json b/src/test/resources/tck/draft7/optional/ecmascript-regex.json deleted file mode 100644 index 08dc9360..00000000 --- a/src/test/resources/tck/draft7/optional/ecmascript-regex.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "description": "ECMA 262 regex non-compliance", - "schema": { "format": "regex" }, - "tests": [ - { - "description": "ECMA 262 has no support for \\Z anchor from .NET", - "data": "^\\S(|(.|\\n)*\\S)\\Z", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/date-time.json b/src/test/resources/tck/draft7/optional/format/date-time.json deleted file mode 100644 index dfccee6e..00000000 --- a/src/test/resources/tck/draft7/optional/format/date-time.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "description": "validation of date-time strings", - "schema": {"format": "date-time"}, - "tests": [ - { - "description": "a valid date-time string", - "data": "1963-06-19T08:30:06.283185Z", - "valid": true - }, - { - "description": "a valid date-time string without second fraction", - "data": "1963-06-19T08:30:06Z", - "valid": true - }, - { - "description": "a valid date-time string with plus offset", - "data": "1937-01-01T12:00:27.87+00:20", - "valid": true - }, - { - "description": "a valid date-time string with minus offset", - "data": "1990-12-31T15:59:50.123-08:00", - "valid": true - }, - { - "description": "a invalid day in date-time string", - "data": "1990-02-31T15:59:60.123-08:00", - "valid": false - }, - { - "description": "an invalid offset in date-time string", - "data": "1990-12-31T15:59:60-24:00", - "valid": false - }, - { - "description": "an invalid date-time string", - "data": "06/19/1963 08:30:06 PST", - "valid": false - }, - { - "description": "case-insensitive T and Z", - "data": "1963-06-19t08:30:06.283185z", - "valid": true - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "2013-350T01:01:01", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/date.json b/src/test/resources/tck/draft7/optional/format/date.json deleted file mode 100644 index cd23baae..00000000 --- a/src/test/resources/tck/draft7/optional/format/date.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "description": "validation of date strings", - "schema": {"format": "date"}, - "tests": [ - { - "description": "a valid date string", - "data": "1963-06-19", - "valid": true - }, - { - "description": "an invalid date-time string", - "data": "06/19/1963", - "valid": false - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "2013-350", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/email.json b/src/test/resources/tck/draft7/optional/format/email.json deleted file mode 100644 index c837c84b..00000000 --- a/src/test/resources/tck/draft7/optional/format/email.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "description": "validation of e-mail addresses", - "schema": {"format": "email"}, - "tests": [ - { - "description": "a valid e-mail address", - "data": "joe.bloggs@example.com", - "valid": true - }, - { - "description": "an invalid e-mail address", - "data": "2962", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/hostname.json b/src/test/resources/tck/draft7/optional/format/hostname.json deleted file mode 100644 index d22e57db..00000000 --- a/src/test/resources/tck/draft7/optional/format/hostname.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "validation of host names", - "schema": {"format": "hostname"}, - "tests": [ - { - "description": "a valid host name", - "data": "www.example.com", - "valid": true - }, - { - "description": "a valid punycoded IDN hostname", - "data": "xn--4gbwdl.xn--wgbh1c", - "valid": true - }, - { - "description": "a host name starting with an illegal character", - "data": "-a-host-name-that-starts-with--", - "valid": false - }, - { - "description": "a host name containing illegal characters", - "data": "not_a_valid_host_name", - "valid": false - }, - { - "description": "a host name with a component too long", - "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/idn-email.json b/src/test/resources/tck/draft7/optional/format/idn-email.json deleted file mode 100644 index 637409ea..00000000 --- a/src/test/resources/tck/draft7/optional/format/idn-email.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "description": "validation of an internationalized e-mail addresses", - "schema": {"format": "idn-email"}, - "tests": [ - { - "description": "a valid idn e-mail (example@example.test in Hangul)", - "data": "실례@실례.테스트", - "valid": true - }, - { - "description": "an invalid idn e-mail address", - "data": "2962", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/idn-hostname.json b/src/test/resources/tck/draft7/optional/format/idn-hostname.json deleted file mode 100644 index 3291820e..00000000 --- a/src/test/resources/tck/draft7/optional/format/idn-hostname.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "validation of internationalized host names", - "schema": {"format": "idn-hostname"}, - "tests": [ - { - "description": "a valid host name (example.test in Hangul)", - "data": "실례.테스트", - "valid": true - }, - { - "description": "illegal first char U+302E Hangul single dot tone mark", - "data": "〮실례.테스트", - "valid": false - }, - { - "description": "contains illegal char U+302E Hangul single dot tone mark", - "data": "실〮례.테스트", - "valid": false - }, - { - "description": "a host name with a component too long", - "data": "실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실실례례테스트례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례례례례례례례례테스트례례례례례례례례례례례례테스트례례실례.테스트", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/ipv4.json b/src/test/resources/tck/draft7/optional/format/ipv4.json deleted file mode 100644 index 661148a7..00000000 --- a/src/test/resources/tck/draft7/optional/format/ipv4.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, - "tests": [ - { - "description": "a valid IP address", - "data": "192.168.0.1", - "valid": true - }, - { - "description": "an IP address with too many components", - "data": "127.0.0.0.1", - "valid": false - }, - { - "description": "an IP address with out-of-range values", - "data": "256.256.256.256", - "valid": false - }, - { - "description": "an IP address without 4 components", - "data": "127.0", - "valid": false - }, - { - "description": "an IP address as an integer", - "data": "0x7f000001", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/ipv6.json b/src/test/resources/tck/draft7/optional/format/ipv6.json deleted file mode 100644 index f67559b3..00000000 --- a/src/test/resources/tck/draft7/optional/format/ipv6.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, - "tests": [ - { - "description": "a valid IPv6 address", - "data": "::1", - "valid": true - }, - { - "description": "an IPv6 address with out-of-range values", - "data": "12345::", - "valid": false - }, - { - "description": "an IPv6 address with too many components", - "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", - "valid": false - }, - { - "description": "an IPv6 address containing illegal characters", - "data": "::laptop", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/iri-reference.json b/src/test/resources/tck/draft7/optional/format/iri-reference.json deleted file mode 100644 index 1fd779c2..00000000 --- a/src/test/resources/tck/draft7/optional/format/iri-reference.json +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "description": "validation of IRI References", - "schema": {"format": "iri-reference"}, - "tests": [ - { - "description": "a valid IRI", - "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", - "valid": true - }, - { - "description": "a valid protocol-relative IRI Reference", - "data": "//ƒøø.ßår/?∂éœ=πîx#πîüx", - "valid": true - }, - { - "description": "a valid relative IRI Reference", - "data": "/âππ", - "valid": true - }, - { - "description": "an invalid IRI Reference", - "data": "\\\\WINDOWS\\filëßåré", - "valid": false - }, - { - "description": "a valid IRI Reference", - "data": "âππ", - "valid": true - }, - { - "description": "a valid IRI fragment", - "data": "#ƒrägmênt", - "valid": true - }, - { - "description": "an invalid IRI fragment", - "data": "#ƒräg\\mênt", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/iri.json b/src/test/resources/tck/draft7/optional/format/iri.json deleted file mode 100644 index ed54094c..00000000 --- a/src/test/resources/tck/draft7/optional/format/iri.json +++ /dev/null @@ -1,53 +0,0 @@ -[ - { - "description": "validation of IRIs", - "schema": {"format": "iri"}, - "tests": [ - { - "description": "a valid IRI with anchor tag", - "data": "http://ƒøø.ßår/?∂éœ=πîx#πîüx", - "valid": true - }, - { - "description": "a valid IRI with anchor tag and parantheses", - "data": "http://ƒøø.com/blah_(wîkïpédiå)_blah#ßité-1", - "valid": true - }, - { - "description": "a valid IRI with URL-encoded stuff", - "data": "http://ƒøø.ßår/?q=Test%20URL-encoded%20stuff", - "valid": true - }, - { - "description": "a valid IRI with many special characters", - "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", - "valid": true - }, - { - "description": "a valid IRI based on IPv6", - "data": "http://[2001:0db8:85a3:0000:0000:8a2e:0370:7334]", - "valid": true - }, - { - "description": "an invalid IRI based on IPv6", - "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "valid": false - }, - { - "description": "an invalid relative IRI Reference", - "data": "/abc", - "valid": false - }, - { - "description": "an invalid IRI", - "data": "\\\\WINDOWS\\filëßåré", - "valid": false - }, - { - "description": "an invalid IRI though valid IRI reference", - "data": "âππ", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/json-pointer.json b/src/test/resources/tck/draft7/optional/format/json-pointer.json deleted file mode 100644 index 65c2f064..00000000 --- a/src/test/resources/tck/draft7/optional/format/json-pointer.json +++ /dev/null @@ -1,168 +0,0 @@ -[ - { - "description": "validation of JSON-pointers (JSON String Representation)", - "schema": {"format": "json-pointer"}, - "tests": [ - { - "description": "a valid JSON-pointer", - "data": "/foo/bar~0/baz~1/%a", - "valid": true - }, - { - "description": "not a valid JSON-pointer (~ not escaped)", - "data": "/foo/bar~", - "valid": false - }, - { - "description": "valid JSON-pointer with empty segment", - "data": "/foo//bar", - "valid": true - }, - { - "description": "valid JSON-pointer with the last empty segment", - "data": "/foo/bar/", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #1", - "data": "", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #2", - "data": "/foo", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #3", - "data": "/foo/0", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #4", - "data": "/", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #5", - "data": "/a~1b", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #6", - "data": "/c%d", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #7", - "data": "/e^f", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #8", - "data": "/g|h", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #9", - "data": "/i\\j", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #10", - "data": "/k\"l", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #11", - "data": "/ ", - "valid": true - }, - { - "description": "valid JSON-pointer as stated in RFC 6901 #12", - "data": "/m~0n", - "valid": true - }, - { - "description": "valid JSON-pointer used adding to the last array position", - "data": "/foo/-", - "valid": true - }, - { - "description": "valid JSON-pointer (- used as object member name)", - "data": "/foo/-/bar", - "valid": true - }, - { - "description": "valid JSON-pointer (multiple escaped characters)", - "data": "/~1~0~0~1~1", - "valid": true - }, - { - "description": "valid JSON-pointer (escaped with fraction part) #1", - "data": "/~1.1", - "valid": true - }, - { - "description": "valid JSON-pointer (escaped with fraction part) #2", - "data": "/~0.1", - "valid": true - }, - { - "description": "not a valid JSON-pointer (URI Fragment Identifier) #1", - "data": "#", - "valid": false - }, - { - "description": "not a valid JSON-pointer (URI Fragment Identifier) #2", - "data": "#/", - "valid": false - }, - { - "description": "not a valid JSON-pointer (URI Fragment Identifier) #3", - "data": "#a", - "valid": false - }, - { - "description": "not a valid JSON-pointer (some escaped, but not all) #1", - "data": "/~0~", - "valid": false - }, - { - "description": "not a valid JSON-pointer (some escaped, but not all) #2", - "data": "/~0/~", - "valid": false - }, - { - "description": "not a valid JSON-pointer (wrong escape character) #1", - "data": "/~2", - "valid": false - }, - { - "description": "not a valid JSON-pointer (wrong escape character) #2", - "data": "/~-1", - "valid": false - }, - { - "description": "not a valid JSON-pointer (multiple characters not escaped)", - "data": "/~~", - "valid": false - }, - { - "description": "not a valid JSON-pointer (isn't empty nor starts with /) #1", - "data": "a", - "valid": false - }, - { - "description": "not a valid JSON-pointer (isn't empty nor starts with /) #2", - "data": "0", - "valid": false - }, - { - "description": "not a valid JSON-pointer (isn't empty nor starts with /) #3", - "data": "a/a", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/regex.json b/src/test/resources/tck/draft7/optional/format/regex.json deleted file mode 100644 index d99d021e..00000000 --- a/src/test/resources/tck/draft7/optional/format/regex.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "description": "validation of regular expressions", - "schema": {"format": "regex"}, - "tests": [ - { - "description": "a valid regular expression", - "data": "([abc])+\\s+$", - "valid": true - }, - { - "description": "a regular expression with unclosed parens is invalid", - "data": "^(abc]", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/relative-json-pointer.json b/src/test/resources/tck/draft7/optional/format/relative-json-pointer.json deleted file mode 100644 index ceeb743a..00000000 --- a/src/test/resources/tck/draft7/optional/format/relative-json-pointer.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "validation of Relative JSON Pointers (RJP)", - "schema": {"format": "relative-json-pointer"}, - "tests": [ - { - "description": "a valid upwards RJP", - "data": "1", - "valid": true - }, - { - "description": "a valid downwards RJP", - "data": "0/foo/bar", - "valid": true - }, - { - "description": "a valid up and then down RJP, with array index", - "data": "2/0/baz/1/zip", - "valid": true - }, - { - "description": "a valid RJP taking the member or index name", - "data": "0#", - "valid": true - }, - { - "description": "an invalid RJP that is a valid JSON Pointer", - "data": "/foo/bar", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/time.json b/src/test/resources/tck/draft7/optional/format/time.json deleted file mode 100644 index 4ec8a01a..00000000 --- a/src/test/resources/tck/draft7/optional/format/time.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "description": "validation of time strings", - "schema": {"format": "time"}, - "tests": [ - { - "description": "a valid time string", - "data": "08:30:06.283185Z", - "valid": true - }, - { - "description": "an invalid time string", - "data": "08:30:06 PST", - "valid": false - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "01:01:01,1111", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/uri-reference.json b/src/test/resources/tck/draft7/optional/format/uri-reference.json deleted file mode 100644 index e4c9eef6..00000000 --- a/src/test/resources/tck/draft7/optional/format/uri-reference.json +++ /dev/null @@ -1,43 +0,0 @@ -[ - { - "description": "validation of URI References", - "schema": {"format": "uri-reference"}, - "tests": [ - { - "description": "a valid URI", - "data": "http://foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid protocol-relative URI Reference", - "data": "//foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid relative URI Reference", - "data": "/abc", - "valid": true - }, - { - "description": "an invalid URI Reference", - "data": "\\\\WINDOWS\\fileshare", - "valid": false - }, - { - "description": "a valid URI Reference", - "data": "abc", - "valid": true - }, - { - "description": "a valid URI fragment", - "data": "#fragment", - "valid": true - }, - { - "description": "an invalid URI fragment", - "data": "#frag\\ment", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/uri-template.json b/src/test/resources/tck/draft7/optional/format/uri-template.json deleted file mode 100644 index d8396a5a..00000000 --- a/src/test/resources/tck/draft7/optional/format/uri-template.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "format: uri-template", - "schema": { - "format": "uri-template" - }, - "tests": [ - { - "description": "a valid uri-template", - "data": "http://example.com/dictionary/{term:1}/{term}", - "valid": true - }, - { - "description": "an invalid uri-template", - "data": "http://example.com/dictionary/{term:1}/{term", - "valid": false - }, - { - "description": "a valid uri-template without variables", - "data": "http://example.com/dictionary", - "valid": true - }, - { - "description": "a valid relative uri-template", - "data": "dictionary/{term:1}/{term}", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/format/uri.json b/src/test/resources/tck/draft7/optional/format/uri.json deleted file mode 100644 index 25cc40c8..00000000 --- a/src/test/resources/tck/draft7/optional/format/uri.json +++ /dev/null @@ -1,103 +0,0 @@ -[ - { - "description": "validation of URIs", - "schema": {"format": "uri"}, - "tests": [ - { - "description": "a valid URL with anchor tag", - "data": "http://foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid URL with anchor tag and parantheses", - "data": "http://foo.com/blah_(wikipedia)_blah#cite-1", - "valid": true - }, - { - "description": "a valid URL with URL-encoded stuff", - "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff", - "valid": true - }, - { - "description": "a valid puny-coded URL ", - "data": "http://xn--nw2a.xn--j6w193g/", - "valid": true - }, - { - "description": "a valid URL with many special characters", - "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", - "valid": true - }, - { - "description": "a valid URL based on IPv4", - "data": "http://223.255.255.254", - "valid": true - }, - { - "description": "a valid URL with ftp scheme", - "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt", - "valid": true - }, - { - "description": "a valid URL for a simple text file", - "data": "http://www.ietf.org/rfc/rfc2396.txt", - "valid": true - }, - { - "description": "a valid URL ", - "data": "ldap://[2001:db8::7]/c=GB?objectClass?one", - "valid": true - }, - { - "description": "a valid mailto URI", - "data": "mailto:John.Doe@example.com", - "valid": true - }, - { - "description": "a valid newsgroup URI", - "data": "news:comp.infosystems.www.servers.unix", - "valid": true - }, - { - "description": "a valid tel URI", - "data": "tel:+1-816-555-1212", - "valid": true - }, - { - "description": "a valid URN", - "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", - "valid": true - }, - { - "description": "an invalid protocol-relative URI Reference", - "data": "//foo.bar/?baz=qux#quux", - "valid": false - }, - { - "description": "an invalid relative URI Reference", - "data": "/abc", - "valid": false - }, - { - "description": "an invalid URI", - "data": "\\\\WINDOWS\\fileshare", - "valid": false - }, - { - "description": "an invalid URI though valid URI reference", - "data": "abc", - "valid": false - }, - { - "description": "an invalid URI with spaces", - "data": "http:// shouldfail.com", - "valid": false - }, - { - "description": "an invalid URI with spaces and missing scheme", - "data": ":// should fail", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/optional/zeroTerminatedFloats.json b/src/test/resources/tck/draft7/optional/zeroTerminatedFloats.json deleted file mode 100644 index 1bcdf960..00000000 --- a/src/test/resources/tck/draft7/optional/zeroTerminatedFloats.json +++ /dev/null @@ -1,15 +0,0 @@ -[ - { - "description": "some languages do not distinguish between different types of numeric value", - "schema": { - "type": "integer" - }, - "tests": [ - { - "description": "a float without fractional part is an integer", - "data": 1.0, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/pattern.json b/src/test/resources/tck/draft7/pattern.json deleted file mode 100644 index 03bf9a6d..00000000 --- a/src/test/resources/tck/draft7/pattern.json +++ /dev/null @@ -1,59 +0,0 @@ -[ - { - "description": "pattern validation", - "schema": {"pattern": "^a*$"}, - "tests": [ - { - "description": "a matching pattern is valid", - "data": "aaa", - "valid": true - }, - { - "description": "a non-matching pattern is invalid", - "data": "abc", - "valid": false - }, - { - "description": "ignores booleans", - "data": true, - "valid": true - }, - { - "description": "ignores integers", - "data": 123, - "valid": true - }, - { - "description": "ignores floats", - "data": 1.0, - "valid": true - }, - { - "description": "ignores objects", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores null", - "data": null, - "valid": true - } - ] - }, - { - "description": "pattern is not anchored", - "schema": {"pattern": "a+"}, - "tests": [ - { - "description": "matches a substring", - "data": "xxaayy", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/patternProperties.json b/src/test/resources/tck/draft7/patternProperties.json deleted file mode 100644 index 1d04a167..00000000 --- a/src/test/resources/tck/draft7/patternProperties.json +++ /dev/null @@ -1,151 +0,0 @@ -[ - { - "description": - "patternProperties validates properties matching a regex", - "schema": { - "patternProperties": { - "f.*o": {"type": "integer"} - } - }, - "tests": [ - { - "description": "a single valid match is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "multiple valid matches is valid", - "data": {"foo": 1, "foooooo" : 2}, - "valid": true - }, - { - "description": "a single invalid match is invalid", - "data": {"foo": "bar", "fooooo": 2}, - "valid": false - }, - { - "description": "multiple invalid matches is invalid", - "data": {"foo": "bar", "foooooo" : "baz"}, - "valid": false - }, - { - "description": "ignores arrays", - "data": ["foo"], - "valid": true - }, - { - "description": "ignores strings", - "data": "foo", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "multiple simultaneous patternProperties are validated", - "schema": { - "patternProperties": { - "a*": {"type": "integer"}, - "aaa*": {"maximum": 20} - } - }, - "tests": [ - { - "description": "a single valid match is valid", - "data": {"a": 21}, - "valid": true - }, - { - "description": "a simultaneous match is valid", - "data": {"aaaa": 18}, - "valid": true - }, - { - "description": "multiple matches is valid", - "data": {"a": 21, "aaaa": 18}, - "valid": true - }, - { - "description": "an invalid due to one is invalid", - "data": {"a": "bar"}, - "valid": false - }, - { - "description": "an invalid due to the other is invalid", - "data": {"aaaa": 31}, - "valid": false - }, - { - "description": "an invalid due to both is invalid", - "data": {"aaa": "foo", "aaaa": 31}, - "valid": false - } - ] - }, - { - "description": "regexes are not anchored by default and are case sensitive", - "schema": { - "patternProperties": { - "[0-9]{2,}": { "type": "boolean" }, - "X_": { "type": "string" } - } - }, - "tests": [ - { - "description": "non recognized members are ignored", - "data": { "answer 1": "42" }, - "valid": true - }, - { - "description": "recognized members are accounted for", - "data": { "a31b": null }, - "valid": false - }, - { - "description": "regexes are case sensitive", - "data": { "a_x_3": 3 }, - "valid": true - }, - { - "description": "regexes are case sensitive, 2", - "data": { "a_X_3": 3 }, - "valid": false - } - ] - }, - { - "description": "patternProperties with boolean schemas", - "schema": { - "patternProperties": { - "f.*": true, - "b.*": false - } - }, - "tests": [ - { - "description": "object with property matching schema true is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "object with property matching schema false is invalid", - "data": {"bar": 2}, - "valid": false - }, - { - "description": "object with both properties is invalid", - "data": {"foo": 1, "bar": 2}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/properties.json b/src/test/resources/tck/draft7/properties.json deleted file mode 100644 index 7ef0e092..00000000 --- a/src/test/resources/tck/draft7/properties.json +++ /dev/null @@ -1,184 +0,0 @@ -[ - { - "description": "object properties validation", - "schema": { - "properties": { - "foo": {"type": "integer"}, - "bar": {"type": "string"} - } - }, - "tests": [ - { - "description": "both properties present and valid is valid", - "data": {"foo": 1, "bar": "baz"}, - "valid": true - }, - { - "description": "one property invalid is invalid", - "data": {"foo": 1, "bar": {}}, - "valid": false - }, - { - "description": "both properties invalid is invalid", - "data": {"foo": [], "bar": {}}, - "valid": false - }, - { - "description": "doesn't invalidate other properties", - "data": {"quux": []}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": - "properties, patternProperties, additionalProperties interaction", - "schema": { - "properties": { - "foo": {"type": "array", "maxItems": 3}, - "bar": {"type": "array"} - }, - "patternProperties": {"f.o": {"minItems": 2}}, - "additionalProperties": {"type": "integer"} - }, - "tests": [ - { - "description": "property validates property", - "data": {"foo": [1, 2]}, - "valid": true - }, - { - "description": "property invalidates property", - "data": {"foo": [1, 2, 3, 4]}, - "valid": false - }, - { - "description": "patternProperty invalidates property", - "data": {"foo": []}, - "valid": false - }, - { - "description": "patternProperty validates nonproperty", - "data": {"fxo": [1, 2]}, - "valid": true - }, - { - "description": "patternProperty invalidates nonproperty", - "data": {"fxo": []}, - "valid": false - }, - { - "description": "additionalProperty ignores property", - "data": {"bar": []}, - "valid": true - }, - { - "description": "additionalProperty validates others", - "data": {"quux": 3}, - "valid": true - }, - { - "description": "additionalProperty invalidates others", - "data": {"quux": "foo"}, - "valid": false - } - ] - }, - { - "description": "properties with boolean schema", - "schema": { - "properties": { - "foo": true, - "bar": false - } - }, - "tests": [ - { - "description": "no property present is valid", - "data": {}, - "valid": true - }, - { - "description": "only 'true' property present is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "only 'false' property present is invalid", - "data": { - "bar": 2 - }, - "valid": false - }, - { - "description": "both properties present is invalid", - "data": { - "foo": 1, - "bar": 2 - }, - "valid": false - } - ] - }, - { - "description": "properties with escaped characters", - "schema": { - "properties": { - "foo\nbar": { - "type": "number" - }, - "foo\"bar": { - "type": "number" - }, - "foo\\bar": { - "type": "number" - }, - "foo\rbar": { - "type": "number" - }, - "foo\tbar": { - "type": "number" - }, - "foo\fbar": { - "type": "number" - } - } - }, - "tests": [ - { - "description": "object with all numbers is valid", - "data": { - "foo\nbar": 1, - "foo\"bar": 1, - "foo\\bar": 1, - "foo\rbar": 1, - "foo\tbar": 1, - "foo\fbar": 1 - }, - "valid": true - }, - { - "description": "object with strings is invalid", - "data": { - "foo\nbar": "1", - "foo\"bar": "1", - "foo\\bar": "1", - "foo\rbar": "1", - "foo\tbar": "1", - "foo\fbar": "1" - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/propertyNames.json b/src/test/resources/tck/draft7/propertyNames.json deleted file mode 100644 index 8423690d..00000000 --- a/src/test/resources/tck/draft7/propertyNames.json +++ /dev/null @@ -1,78 +0,0 @@ -[ - { - "description": "propertyNames validation", - "schema": { - "propertyNames": {"maxLength": 3} - }, - "tests": [ - { - "description": "all property names valid", - "data": { - "f": {}, - "foo": {} - }, - "valid": true - }, - { - "description": "some property names invalid", - "data": { - "foo": {}, - "foobar": {} - }, - "valid": false - }, - { - "description": "object without properties is valid", - "data": {}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [1, 2, 3, 4], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "propertyNames with boolean schema true", - "schema": {"propertyNames": true}, - "tests": [ - { - "description": "object with any properties is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "propertyNames with boolean schema false", - "schema": {"propertyNames": false}, - "tests": [ - { - "description": "object with any properties is invalid", - "data": {"foo": 1}, - "valid": false - }, - { - "description": "empty object is valid", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/draft7/ref.json b/src/test/resources/tck/draft7/ref.json deleted file mode 100644 index cd323fc0..00000000 --- a/src/test/resources/tck/draft7/ref.json +++ /dev/null @@ -1,510 +0,0 @@ -[ - { - "description": "root pointer ref", - "schema": { - "properties": { - "foo": {"$ref": "#"} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "match", - "data": {"foo": false}, - "valid": true - }, - { - "description": "recursive match", - "data": {"foo": {"foo": false}}, - "valid": true - }, - { - "description": "mismatch", - "data": {"bar": false}, - "valid": false - }, - { - "description": "recursive mismatch", - "data": {"foo": {"bar": false}}, - "valid": false - } - ] - }, - { - "description": "relative pointer ref to object", - "schema": { - "properties": { - "foo": {"type": "integer"}, - "bar": {"$ref": "#/properties/foo"} - } - }, - "tests": [ - { - "description": "match", - "data": {"bar": 3}, - "valid": true - }, - { - "description": "mismatch", - "data": {"bar": true}, - "valid": false - } - ] - }, - { - "description": "relative pointer ref to array", - "schema": { - "items": [ - {"type": "integer"}, - {"$ref": "#/items/0"} - ] - }, - "tests": [ - { - "description": "match array", - "data": [1, 2], - "valid": true - }, - { - "description": "mismatch array", - "data": [1, "foo"], - "valid": false - } - ] - }, - { - "description": "escaped pointer ref", - "schema": { - "tilde~field": { - "type": "integer" - }, - "slash/field": { - "type": "integer" - }, - "percent%field": { - "type": "integer" - }, - "properties": { - "tilde": { - "$ref": "#/tilde~0field" - }, - "slash": { - "$ref": "#/slash~1field" - }, - "percent": { - "$ref": "#/percent%25field" - } - } - }, - "tests": [ - { - "description": "slash invalid", - "data": {"slash": "aoeu"}, - "valid": false - }, - { - "description": "tilde invalid", - "data": { - "tilde": "aoeu" - }, - "valid": false - }, - { - "description": "percent invalid", - "data": {"percent": "aoeu"}, - "valid": false - }, - { - "description": "slash valid", - "data": {"slash": 123}, - "valid": true - }, - { - "description": "tilde valid", - "data": { - "tilde": 123 - }, - "valid": true - }, - { - "description": "percent valid", - "data": {"percent": 123}, - "valid": true - } - ] - }, - { - "description": "nested refs", - "schema": { - "definitions": { - "a": {"type": "integer"}, - "b": {"$ref": "#/definitions/a"}, - "c": {"$ref": "#/definitions/b"} - }, - "$ref": "#/definitions/c" - }, - "tests": [ - { - "description": "nested ref valid", - "data": 5, - "valid": true - }, - { - "description": "nested ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref overrides any sibling keywords", - "schema": { - "definitions": { - "reffed": { - "type": "array" - } - }, - "properties": { - "foo": { - "$ref": "#/definitions/reffed", - "maxItems": 2 - } - } - }, - "tests": [ - { - "description": "ref valid", - "data": { "foo": [] }, - "valid": true - }, - { - "description": "ref valid, maxItems ignored", - "data": { "foo": [ 1, 2, 3] }, - "valid": true - }, - { - "description": "ref invalid", - "data": { "foo": "string" }, - "valid": false - } - ] - }, - { - "description": "remote ref, containing refs itself", - "schema": {"$ref": "http://json-schema.org/draft-07/schema#"}, - "tests": [ - { - "description": "remote ref valid", - "data": {"minLength": 1}, - "valid": true - }, - { - "description": "remote ref invalid", - "data": {"minLength": -1}, - "valid": false - } - ] - }, - { - "description": "property named $ref that is not a reference", - "schema": { - "properties": { - "$ref": { - "type": "string" - } - } - }, - "tests": [ - { - "description": "property named $ref valid", - "data": { - "$ref": "a" - }, - "valid": true - }, - { - "description": "property named $ref invalid", - "data": { - "$ref": 2 - }, - "valid": false - } - ] - }, - { - "description": "property named $ref, containing an actual $ref", - "schema": { - "properties": { - "$ref": { - "$ref": "#/definitions/is-string" - } - }, - "definitions": { - "is-string": { - "type": "string" - } - } - }, - "tests": [ - { - "description": "property named $ref valid", - "data": { - "$ref": "a" - }, - "valid": true - }, - { - "description": "property named $ref invalid", - "data": { - "$ref": 2 - }, - "valid": false - } - ] - }, - { - "description": "$ref to boolean schema true", - "schema": { - "$ref": "#/definitions/bool", - "definitions": { - "bool": true - } - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "$ref to boolean schema false", - "schema": { - "$ref": "#/definitions/bool", - "definitions": { - "bool": false - } - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "Recursive references between schemas", - "schema": { - "$id": "http://localhost:1234/tree", - "description": "tree of nodes", - "type": "object", - "properties": { - "meta": {"type": "string"}, - "nodes": { - "type": "array", - "items": {"$ref": "node"} - } - }, - "required": ["meta", "nodes"], - "definitions": { - "node": { - "$id": "http://localhost:1234/node", - "description": "node", - "type": "object", - "properties": { - "value": {"type": "number"}, - "subtree": {"$ref": "tree"} - }, - "required": ["value"] - } - } - }, - "tests": [ - { - "description": "valid tree", - "data": { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - {"value": 1.1}, - {"value": 1.2} - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - {"value": 2.1}, - {"value": 2.2} - ] - } - } - ] - }, - "valid": true - }, - { - "description": "invalid tree", - "data": { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - {"value": "string is invalid"}, - {"value": 1.2} - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - { - "value": 2.1 - }, - { - "value": 2.2 - } - ] - } - } - ] - }, - "valid": false - } - ] - }, - { - "description": "refs with quote", - "schema": { - "properties": { - "foo\"bar": { - "$ref": "#/definitions/foo%22bar" - } - }, - "definitions": { - "foo\"bar": { - "type": "number" - } - } - }, - "tests": [ - { - "description": "object with numbers is valid", - "data": { - "foo\"bar": 1 - }, - "valid": true - }, - { - "description": "object with strings is invalid", - "data": { - "foo\"bar": "1" - }, - "valid": false - } - ] - }, - { - "description": "Location-independent identifier", - "schema": { - "allOf": [ - { - "$ref": "#foo" - } - ], - "definitions": { - "A": { - "$id": "#foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "Location-independent identifier with absolute URI", - "schema": { - "allOf": [ - { - "$ref": "http://localhost:1234/bar#foo" - } - ], - "definitions": { - "A": { - "$id": "http://localhost:1234/bar#foo", - "type": "integer" - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - }, - { - "description": "Location-independent identifier with base URI change in subschema", - "schema": { - "$id": "http://localhost:1234/root", - "allOf": [ - { - "$ref": "http://localhost:1234/nested.json#foo" - } - ], - "definitions": { - "A": { - "$id": "nested.json", - "definitions": { - "B": { - "$id": "#foo", - "type": "integer" - } - } - } - } - }, - "tests": [ - { - "data": 1, - "description": "match", - "valid": true - }, - { - "data": "a", - "description": "mismatch", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/refRemote.json b/src/test/resources/tck/draft7/refRemote.json deleted file mode 100644 index 819d3267..00000000 --- a/src/test/resources/tck/draft7/refRemote.json +++ /dev/null @@ -1,171 +0,0 @@ -[ - { - "description": "remote ref", - "schema": {"$ref": "http://localhost:1234/integer.json"}, - "tests": [ - { - "description": "remote ref valid", - "data": 1, - "valid": true - }, - { - "description": "remote ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "fragment within remote ref", - "schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, - "tests": [ - { - "description": "remote fragment valid", - "data": 1, - "valid": true - }, - { - "description": "remote fragment invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref within remote ref", - "schema": { - "$ref": "http://localhost:1234/subSchemas.json#/refToInteger" - }, - "tests": [ - { - "description": "ref within ref valid", - "data": 1, - "valid": true - }, - { - "description": "ref within ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "base URI change", - "schema": { - "$id": "http://localhost:1234/", - "items": { - "$id": "folder/", - "items": {"$ref": "folderInteger.json"} - } - }, - "tests": [ - { - "description": "base URI change ref valid", - "data": [[1]], - "valid": true - }, - { - "description": "base URI change ref invalid", - "data": [["a"]], - "valid": false - } - ] - }, - { - "description": "base URI change - change folder", - "schema": { - "$id": "http://localhost:1234/scope_change_defs1.json", - "type" : "object", - "properties": { - "list": {"$ref": "#/definitions/baz"} - }, - "definitions": { - "baz": { - "$id": "folder/", - "type": "array", - "items": {"$ref": "folderInteger.json"} - } - } - }, - "tests": [ - { - "description": "number is valid", - "data": {"list": [1]}, - "valid": true - }, - { - "description": "string is invalid", - "data": {"list": ["a"]}, - "valid": false - } - ] - }, - { - "description": "base URI change - change folder in subschema", - "schema": { - "$id": "http://localhost:1234/scope_change_defs2.json", - "type" : "object", - "properties": { - "list": {"$ref": "#/definitions/baz/definitions/bar"} - }, - "definitions": { - "baz": { - "$id": "folder/", - "definitions": { - "bar": { - "type": "array", - "items": {"$ref": "folderInteger.json"} - } - } - } - } - }, - "tests": [ - { - "description": "number is valid", - "data": {"list": [1]}, - "valid": true - }, - { - "description": "string is invalid", - "data": {"list": ["a"]}, - "valid": false - } - ] - }, - { - "description": "root ref in remote ref", - "schema": { - "$id": "http://localhost:1234/object", - "type": "object", - "properties": { - "name": {"$ref": "name.json#/definitions/orNull"} - } - }, - "tests": [ - { - "description": "string is valid", - "data": { - "name": "foo" - }, - "valid": true - }, - { - "description": "null is valid", - "data": { - "name": null - }, - "valid": true - }, - { - "description": "object is invalid", - "data": { - "name": { - "name": null - } - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/remotes/folder/folderInteger.json b/src/test/resources/tck/draft7/remotes/folder/folderInteger.json deleted file mode 100644 index dbe5c758..00000000 --- a/src/test/resources/tck/draft7/remotes/folder/folderInteger.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "integer" -} \ No newline at end of file diff --git a/src/test/resources/tck/draft7/remotes/integer.json b/src/test/resources/tck/draft7/remotes/integer.json deleted file mode 100644 index dbe5c758..00000000 --- a/src/test/resources/tck/draft7/remotes/integer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "integer" -} \ No newline at end of file diff --git a/src/test/resources/tck/draft7/remotes/name.json b/src/test/resources/tck/draft7/remotes/name.json deleted file mode 100644 index 19ba0935..00000000 --- a/src/test/resources/tck/draft7/remotes/name.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "definitions": { - "orNull": { - "anyOf": [ - {"type": "null"}, - {"$ref": "#"} - ] - } - }, - "type": "string" -} diff --git a/src/test/resources/tck/draft7/remotes/subSchemas.json b/src/test/resources/tck/draft7/remotes/subSchemas.json deleted file mode 100644 index 8b6d8f84..00000000 --- a/src/test/resources/tck/draft7/remotes/subSchemas.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/integer" - } -} \ No newline at end of file diff --git a/src/test/resources/tck/draft7/required.json b/src/test/resources/tck/draft7/required.json deleted file mode 100644 index c706edf6..00000000 --- a/src/test/resources/tck/draft7/required.json +++ /dev/null @@ -1,105 +0,0 @@ -[ - { - "description": "required validation", - "schema": { - "properties": { - "foo": {}, - "bar": {} - }, - "required": ["foo"] - }, - "tests": [ - { - "description": "present required property is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "non-present required property is invalid", - "data": {"bar": 1}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores strings", - "data": "", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "required default validation", - "schema": { - "properties": { - "foo": {} - } - }, - "tests": [ - { - "description": "not required by default", - "data": {}, - "valid": true - } - ] - }, - { - "description": "required with empty array", - "schema": { - "properties": { - "foo": {} - }, - "required": [] - }, - "tests": [ - { - "description": "property not required", - "data": {}, - "valid": true - } - ] - }, - { - "description": "required with escaped characters", - "schema": { - "required": [ - "foo\nbar", - "foo\"bar", - "foo\\bar", - "foo\rbar", - "foo\tbar", - "foo\fbar" - ] - }, - "tests": [ - { - "description": "object with all properties present is valid", - "data": { - "foo\nbar": 1, - "foo\"bar": 1, - "foo\\bar": 1, - "foo\rbar": 1, - "foo\tbar": 1, - "foo\fbar": 1 - }, - "valid": true - }, - { - "description": "object with some properties missing is invalid", - "data": { - "foo\nbar": "1", - "foo\"bar": "1" - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/type.json b/src/test/resources/tck/draft7/type.json deleted file mode 100644 index 253c69ac..00000000 --- a/src/test/resources/tck/draft7/type.json +++ /dev/null @@ -1,495 +0,0 @@ -[ - { - "description": "integer type matches integers", - "schema": {"type": "integer"}, - "tests": [ - { - "description": "an integer is an integer", - "data": 1, - "valid": true - }, - { - "description": "a float with zero fractional part is an integer", - "data": 1.0, - "valid": true - }, - { - "description": "a float is not an integer", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an integer", - "data": "foo", - "valid": false - }, - { - "description": "a string is still not an integer, even if it looks like one", - "data": "1", - "valid": false - }, - { - "description": "an object is not an integer", - "data": {}, - "valid": false - }, - { - "description": "an array is not an integer", - "data": [], - "valid": false - }, - { - "description": "a boolean is not an integer", - "data": true, - "valid": false - }, - { - "description": "null is not an integer", - "data": null, - "valid": false - } - ] - }, - { - "description": "number type matches numbers", - "schema": {"type": "number"}, - "tests": [ - { - "description": "an integer is a number", - "data": 1, - "valid": true - }, - { - "description": "a float with zero fractional part is a number (and an integer)", - "data": 1.0, - "valid": true - }, - { - "description": "a float is a number", - "data": 1.1, - "valid": true - }, - { - "description": "a string is not a number", - "data": "foo", - "valid": false - }, - { - "description": "a string is still not a number, even if it looks like one", - "data": "1", - "valid": false - }, - { - "description": "an object is not a number", - "data": {}, - "valid": false - }, - { - "description": "an array is not a number", - "data": [], - "valid": false - }, - { - "description": "a boolean is not a number", - "data": true, - "valid": false - }, - { - "description": "null is not a number", - "data": null, - "valid": false - } - ] - }, - { - "description": "string type matches strings", - "schema": {"type": "string"}, - "tests": [ - { - "description": "1 is not a string", - "data": 1, - "valid": false - }, - { - "description": "a float is not a string", - "data": 1.1, - "valid": false - }, - { - "description": "a string is a string", - "data": "foo", - "valid": true - }, - { - "description": "a string is still a string, even if it looks like a number", - "data": "1", - "valid": true - }, - { - "description": "an empty string is still a string", - "data": "", - "valid": true - }, - { - "description": "an object is not a string", - "data": {}, - "valid": false - }, - { - "description": "an array is not a string", - "data": [], - "valid": false - }, - { - "description": "a boolean is not a string", - "data": true, - "valid": false - }, - { - "description": "null is not a string", - "data": null, - "valid": false - } - ] - }, - { - "description": "object type matches objects", - "schema": {"type": "object"}, - "tests": [ - { - "description": "an integer is not an object", - "data": 1, - "valid": false - }, - { - "description": "a float is not an object", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an object", - "data": "foo", - "valid": false - }, - { - "description": "an object is an object", - "data": {}, - "valid": true - }, - { - "description": "an array is not an object", - "data": [], - "valid": false - }, - { - "description": "a boolean is not an object", - "data": true, - "valid": false - }, - { - "description": "null is not an object", - "data": null, - "valid": false - } - ] - }, - { - "description": "array type matches arrays", - "schema": {"type": "array"}, - "tests": [ - { - "description": "an integer is not an array", - "data": 1, - "valid": false - }, - { - "description": "a float is not an array", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an array", - "data": "foo", - "valid": false - }, - { - "description": "an object is not an array", - "data": {}, - "valid": false - }, - { - "description": "an array is an array", - "data": [], - "valid": true - }, - { - "description": "a boolean is not an array", - "data": true, - "valid": false - }, - { - "description": "null is not an array", - "data": null, - "valid": false - } - ] - }, - { - "description": "boolean type matches booleans", - "schema": {"type": "boolean"}, - "tests": [ - { - "description": "an integer is not a boolean", - "data": 1, - "valid": false - }, - { - "description": "zero is not a boolean", - "data": 0, - "valid": false - }, - { - "description": "a float is not a boolean", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not a boolean", - "data": "foo", - "valid": false - }, - { - "description": "an empty string is not a boolean", - "data": "", - "valid": false - }, - { - "description": "an object is not a boolean", - "data": {}, - "valid": false - }, - { - "description": "an array is not a boolean", - "data": [], - "valid": false - }, - { - "description": "true is a boolean", - "data": true, - "valid": true - }, - { - "description": "false is a boolean", - "data": false, - "valid": true - }, - { - "description": "null is not a boolean", - "data": null, - "valid": false - } - ] - }, - { - "description": "null type matches only the null object", - "schema": {"type": "null"}, - "tests": [ - { - "description": "an integer is not null", - "data": 1, - "valid": false - }, - { - "description": "a float is not null", - "data": 1.1, - "valid": false - }, - { - "description": "zero is not null", - "data": 0, - "valid": false - }, - { - "description": "a string is not null", - "data": "foo", - "valid": false - }, - { - "description": "an empty string is not null", - "data": "", - "valid": false - }, - { - "description": "an object is not null", - "data": {}, - "valid": false - }, - { - "description": "an array is not null", - "data": [], - "valid": false - }, - { - "description": "true is not null", - "data": true, - "valid": false - }, - { - "description": "false is not null", - "data": false, - "valid": false - }, - { - "description": "null is null", - "data": null, - "valid": true - } - ] - }, - { - "description": "multiple types can be specified in an array", - "schema": {"type": ["integer", "string"]}, - "tests": [ - { - "description": "an integer is valid", - "data": 1, - "valid": true - }, - { - "description": "a string is valid", - "data": "foo", - "valid": true - }, - { - "description": "a float is invalid", - "data": 1.1, - "valid": false - }, - { - "description": "an object is invalid", - "data": {}, - "valid": false - }, - { - "description": "an array is invalid", - "data": [], - "valid": false - }, - { - "description": "a boolean is invalid", - "data": true, - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - } - ] - }, - { - "description": "type as array with one item", - "schema": { - "type": [ - "string" - ] - }, - "tests": [ - { - "description": "string is valid", - "data": "foo", - "valid": true - }, - { - "description": "number is invalid", - "data": 123, - "valid": false - } - ] - }, - { - "description": "type: array or object", - "schema": { - "type": [ - "array", - "object" - ] - }, - "tests": [ - { - "description": "array is valid", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "object is valid", - "data": { - "foo": 123 - }, - "valid": true - }, - { - "description": "number is invalid", - "data": 123, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - }, - { - "description": "null is invalid", - "data": null, - "valid": false - } - ] - }, - { - "description": "type: array, object or null", - "schema": { - "type": [ - "array", - "object", - "null" - ] - }, - "tests": [ - { - "description": "array is valid", - "data": [ - 1, - 2, - 3 - ], - "valid": true - }, - { - "description": "object is valid", - "data": { - "foo": 123 - }, - "valid": true - }, - { - "description": "null is valid", - "data": null, - "valid": true - }, - { - "description": "number is invalid", - "data": 123, - "valid": false - }, - { - "description": "string is invalid", - "data": "foo", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/draft7/uniqueItems.json b/src/test/resources/tck/draft7/uniqueItems.json deleted file mode 100644 index 4425487e..00000000 --- a/src/test/resources/tck/draft7/uniqueItems.json +++ /dev/null @@ -1,700 +0,0 @@ -[ - { - "description": "uniqueItems validation", - "schema": {"uniqueItems": true}, - "tests": [ - { - "description": "unique array of integers is valid", - "data": [1, 2], - "valid": true - }, - { - "description": "non-unique array of integers is invalid", - "data": [ - 1, - 1 - ], - "valid": false - }, - { - "description": "numbers are unique if mathematically unequal", - "data": [ - 1.0, - 1.00, - 1 - ], - "valid": false - }, - { - "description": "false is not equal to zero", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "true is not equal to one", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "unique array of objects is valid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "baz" - } - ], - "valid": true - }, - { - "description": "non-unique array of objects is invalid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "bar" - } - ], - "valid": false - }, - { - "description": "unique array of nested objects is valid", - "data": [ - {"foo": {"bar" : {"baz" : true}}}, - {"foo": {"bar" : {"baz" : false}}} - ], - "valid": true - }, - { - "description": "non-unique array of nested objects is invalid", - "data": [ - {"foo": {"bar" : {"baz" : true}}}, - {"foo": {"bar" : {"baz" : true}}} - ], - "valid": false - }, - { - "description": "unique array of arrays is valid", - "data": [["foo"], ["bar"]], - "valid": true - }, - { - "description": "non-unique array of arrays is invalid", - "data": [["foo"], ["foo"]], - "valid": false - }, - { - "description": "1 and true are unique", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "0 and false are unique", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "[1] and [true] are unique", - "data": [ - [ - 1 - ], - [ - true - ] - ], - "valid": true - }, - { - "description": "[0] and [false] are unique", - "data": [ - [ - 0 - ], - [ - false - ] - ], - "valid": true - }, - { - "description": "nested [1] and [true] are unique", - "data": [ - [ - [ - 1 - ], - "foo" - ], - [ - [ - true - ], - "foo" - ] - ], - "valid": true - }, - { - "description": "nested [0] and [false] are unique", - "data": [ - [ - [ - 0 - ], - "foo" - ], - [ - [ - false - ], - "foo" - ] - ], - "valid": true - }, - { - "description": "unique heterogeneous types are valid", - "data": [ - {}, - [ - 1 - ], - true, - null, - 1, - "{}" - ], - "valid": true - }, - { - "description": "non-unique heterogeneous types are invalid", - "data": [ - {}, - [ - 1 - ], - true, - null, - {}, - 1 - ], - "valid": false - }, - { - "description": "different objects are unique", - "data": [ - { - "a": 1, - "b": 2 - }, - { - "a": 2, - "b": 1 - } - ], - "valid": true - }, - { - "description": "objects are non-unique despite key order", - "data": [ - { - "a": 1, - "b": 2 - }, - { - "b": 2, - "a": 1 - } - ], - "valid": false - } - ] - }, - { - "description": "uniqueItems with an array of items", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is not valid", - "data": [ - false, - false - ], - "valid": false - }, - { - "description": "[true, true] from items array is not valid", - "data": [ - true, - true - ], - "valid": false - }, - { - "description": "unique array extended from [false, true] is valid", - "data": [ - false, - true, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "unique array extended from [true, false] is valid", - "data": [ - true, - false, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "non-unique array extended from [false, true] is not valid", - "data": [ - false, - true, - "foo", - "foo" - ], - "valid": false - }, - { - "description": "non-unique array extended from [true, false] is not valid", - "data": [ - true, - false, - "foo", - "foo" - ], - "valid": false - } - ] - }, - { - "description": "uniqueItems with an array of items and additionalItems=false", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": true, - "additionalItems": false - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is not valid", - "data": [ - false, - false - ], - "valid": false - }, - { - "description": "[true, true] from items array is not valid", - "data": [ - true, - true - ], - "valid": false - }, - { - "description": "extra items are invalid even if unique", - "data": [ - false, - true, - null - ], - "valid": false - } - ] - }, - { - "description": "uniqueItems=false validation", - "schema": { - "uniqueItems": false - }, - "tests": [ - { - "description": "unique array of integers is valid", - "data": [ - 1, - 2 - ], - "valid": true - }, - { - "description": "non-unique array of integers is valid", - "data": [ - 1, - 1 - ], - "valid": true - }, - { - "description": "numbers are unique if mathematically unequal", - "data": [ - 1.0, - 1.00, - 1 - ], - "valid": true - }, - { - "description": "false is not equal to zero", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "true is not equal to one", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "unique array of objects is valid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "baz" - } - ], - "valid": true - }, - { - "description": "non-unique array of objects is valid", - "data": [ - { - "foo": "bar" - }, - { - "foo": "bar" - } - ], - "valid": true - }, - { - "description": "unique array of nested objects is valid", - "data": [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": false - } - } - } - ], - "valid": true - }, - { - "description": "non-unique array of nested objects is valid", - "data": [ - { - "foo": { - "bar": { - "baz": true - } - } - }, - { - "foo": { - "bar": { - "baz": true - } - } - } - ], - "valid": true - }, - { - "description": "unique array of arrays is valid", - "data": [ - [ - "foo" - ], - [ - "bar" - ] - ], - "valid": true - }, - { - "description": "non-unique array of arrays is valid", - "data": [ - [ - "foo" - ], - [ - "foo" - ] - ], - "valid": true - }, - { - "description": "1 and true are unique", - "data": [ - 1, - true - ], - "valid": true - }, - { - "description": "0 and false are unique", - "data": [ - 0, - false - ], - "valid": true - }, - { - "description": "unique heterogeneous types are valid", - "data": [ - {}, - [ - 1 - ], - true, - null, - 1 - ], - "valid": true - }, - { - "description": "non-unique heterogeneous types are valid", - "data": [ - {}, - [ - 1 - ], - true, - null, - {}, - 1 - ], - "valid": true - } - ] - }, - { - "description": "uniqueItems=false with an array of items", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is valid", - "data": [ - false, - false - ], - "valid": true - }, - { - "description": "[true, true] from items array is valid", - "data": [ - true, - true - ], - "valid": true - }, - { - "description": "unique array extended from [false, true] is valid", - "data": [ - false, - true, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "unique array extended from [true, false] is valid", - "data": [ - true, - false, - "foo", - "bar" - ], - "valid": true - }, - { - "description": "non-unique array extended from [false, true] is valid", - "data": [ - false, - true, - "foo", - "foo" - ], - "valid": true - }, - { - "description": "non-unique array extended from [true, false] is valid", - "data": [ - true, - false, - "foo", - "foo" - ], - "valid": true - } - ] - }, - { - "description": "uniqueItems=false with an array of items and additionalItems=false", - "schema": { - "items": [ - { - "type": "boolean" - }, - { - "type": "boolean" - } - ], - "uniqueItems": false, - "additionalItems": false - }, - "tests": [ - { - "description": "[false, true] from items array is valid", - "data": [ - false, - true - ], - "valid": true - }, - { - "description": "[true, false] from items array is valid", - "data": [ - true, - false - ], - "valid": true - }, - { - "description": "[false, false] from items array is valid", - "data": [ - false, - false - ], - "valid": true - }, - { - "description": "[true, true] from items array is valid", - "data": [ - true, - true - ], - "valid": true - }, - { - "description": "extra items are invalid even if unique", - "data": [ - false, - true, - null - ], - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/additionalProperties.json b/src/test/resources/tck/openapi3/additionalProperties.json deleted file mode 100644 index d0bc40f4..00000000 --- a/src/test/resources/tck/openapi3/additionalProperties.json +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "description": - "additionalProperties being false does not allow other properties", - "schema": { - "properties": {"foo": {}, "bar": {}}, - "additionalProperties": false - }, - "tests": [ - { - "description": "no additional properties is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "an additional property is invalid", - "data": {"foo" : 1, "bar" : 2, "quux" : "boom"}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [1, 2, 3], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobarbaz", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": - "additionalProperties allows a schema which should validate", - "schema": { - "properties": {"foo": {}, "bar": {}}, - "additionalProperties": {"type": "boolean"} - }, - "tests": [ - { - "description": "no additional properties is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "an additional valid property is valid", - "data": {"foo" : 1, "bar" : 2, "quux" : true}, - "valid": true - }, - { - "description": "an additional invalid property is invalid", - "data": {"foo" : 1, "bar" : 2, "quux" : 12}, - "valid": false - } - ] - }, - { - "description": - "additionalProperties can exist by itself", - "schema": { - "additionalProperties": {"type": "boolean"} - }, - "tests": [ - { - "description": "an additional valid property is valid", - "data": {"foo" : true}, - "valid": true - }, - { - "description": "an additional invalid property is invalid", - "data": {"foo" : 1}, - "valid": false - } - ] - }, - { - "description": "additionalProperties are allowed by default", - "schema": {"properties": {"foo": {}, "bar": {}}}, - "tests": [ - { - "description": "additional properties are allowed", - "data": {"foo": 1, "bar": 2, "quux": true}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/allOf.json b/src/test/resources/tck/openapi3/allOf.json deleted file mode 100644 index 2427ef17..00000000 --- a/src/test/resources/tck/openapi3/allOf.json +++ /dev/null @@ -1,114 +0,0 @@ -[ - { - "description": "allOf", - "schema": { - "allOf": [ - { - "type": "object", - "properties": { - "bar": {"type": "integer"} - }, - "required": ["bar"] - }, - { - "type": "object", - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - } - ] - }, - "tests": [ - { - "description": "allOf", - "data": {"foo": "baz", "bar": 2}, - "valid": true - }, - { - "description": "mismatch second", - "data": {"foo": "baz"}, - "valid": false - }, - { - "description": "mismatch first", - "data": {"bar": 2}, - "valid": false - }, - { - "description": "wrong type", - "data": {"foo": "baz", "bar": "quux"}, - "valid": false - } - ] - }, - { - "description": "allOf with base schema", - "schema": { - "properties": {"bar": {"type": "integer"}}, - "required": ["bar"], - "allOf" : [ - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - }, - { - "properties": { - "baz": {"type": "string", "nullable": true} - }, - "required": ["baz"] - } - ] - }, - "tests": [ - { - "description": "valid", - "data": {"foo": "quux", "bar": 2, "baz": null}, - "valid": true - }, - { - "description": "mismatch base schema", - "data": {"foo": "quux", "baz": null}, - "valid": false - }, - { - "description": "mismatch first allOf", - "data": {"bar": 2, "baz": null}, - "valid": false - }, - { - "description": "mismatch second allOf", - "data": {"foo": "quux", "bar": 2}, - "valid": false - }, - { - "description": "mismatch both", - "data": {"bar": 2}, - "valid": false - } - ] - }, - { - "description": "allOf simple types", - "schema": { - "allOf": [ - {"maximum": 30}, - {"minimum": 20} - ] - }, - "tests": [ - { - "description": "valid", - "data": 25, - "valid": true - }, - { - "description": "mismatch one", - "data": 35, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/anyOf.json b/src/test/resources/tck/openapi3/anyOf.json deleted file mode 100644 index 6c8b2518..00000000 --- a/src/test/resources/tck/openapi3/anyOf.json +++ /dev/null @@ -1,109 +0,0 @@ -[ - { - "description": "anyOf", - "schema": { - "anyOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - }, - "tests": [ - { - "description": "first anyOf valid", - "data": 1, - "valid": true - }, - { - "description": "second anyOf valid", - "data": 2.5, - "valid": true - }, - { - "description": "both anyOf valid", - "data": 3, - "valid": true - }, - { - "description": "neither anyOf valid", - "data": 1.5, - "valid": false - } - ] - }, - { - "description": "anyOf with base schema", - "schema": { - "type": "string", - "anyOf" : [ - { - "maxLength": 2 - }, - { - "minLength": 4 - } - ] - }, - "tests": [ - { - "description": "mismatch base schema", - "data": 3, - "valid": false - }, - { - "description": "one anyOf valid", - "data": "foobar", - "valid": true - }, - { - "description": "both anyOf invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "anyOf complex types", - "schema": { - "anyOf": [ - { - "properties": { - "bar": {"type": "integer"} - }, - "required": ["bar"] - }, - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - } - ] - }, - "tests": [ - { - "description": "first anyOf valid (complex)", - "data": {"bar": 2}, - "valid": true - }, - { - "description": "second anyOf valid (complex)", - "data": {"foo": "baz"}, - "valid": true - }, - { - "description": "both anyOf valid (complex)", - "data": {"foo": "baz", "bar": 2}, - "valid": true - }, - { - "description": "neither anyOf valid (complex)", - "data": {"foo": 2, "bar": "quux"}, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/discriminator.json b/src/test/resources/tck/openapi3/discriminator.json deleted file mode 100644 index cda878a2..00000000 --- a/src/test/resources/tck/openapi3/discriminator.json +++ /dev/null @@ -1,78 +0,0 @@ -[ - { - "description": "discriminator with oneOf validation with explicit names", - "schema": { - "oneOf": [ - { - "name": "A", - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "value_a": { - "type": "string" - } - }, - "required": ["id", "value_a"] - }, - { - "name": "B", - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "value_b": { - "type": "string" - } - }, - "required": ["id"] - } - ], - "discriminator": { - "propertyName": "id" - } - }, - "tests": [ - { - "description": "should be valid with id A and property value_a", - "data": { - "id": "A", - "value_a": "a" - }, - "valid": true - }, - { - "description": "should be invalid with id A and property value_b", - "data": { - "id": "A", - "value_b": "b" - }, - "valid": false - }, - { - "description": "should be valid with id B and property value_b", - "data": { - "id": "B", - "value_b": "b" - }, - "valid": true - }, - { - "description": "should be invalid without id", - "data": { - "value_b": "b" - }, - "valid": false - }, - { - "description": "should be invalid with id A and without value_a", - "data": { - "id": "A" - }, - "valid": false - } - ] - } -] \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/enum.json b/src/test/resources/tck/openapi3/enum.json deleted file mode 100644 index 392575b2..00000000 --- a/src/test/resources/tck/openapi3/enum.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "description": "simple enum validation", - "schema": {"enum": [1, 2, 3]}, - "tests": [ - { - "description": "one of the enum is valid", - "data": 1, - "valid": true - }, - { - "description": "something else is invalid", - "data": 4, - "valid": false - } - ] - }, - { - "description": "heterogeneous enum validation", - "schema": {"enum": [6, "foo", [], true, {"foo": 12}]}, - "tests": [ - { - "description": "one of the enum is valid", - "data": [], - "valid": true - }, - { - "description": "something else is invalid", - "data": "bla", - "valid": false - }, - { - "description": "objects are deep compared", - "data": {"foo": false}, - "valid": false - } - ] - }, - { - "description": "enums in properties", - "schema": { - "type":"object", - "properties": { - "foo": {"enum":["foo"]}, - "bar": {"enum":["bar"]} - }, - "required": ["bar"] - }, - "tests": [ - { - "description": "both properties are valid", - "data": {"foo":"foo", "bar":"bar"}, - "valid": true - }, - { - "description": "missing optional property is valid", - "data": {"bar":"bar"}, - "valid": true - }, - { - "description": "missing required property is invalid", - "data": {"foo":"foo"}, - "valid": false - }, - { - "description": "missing all properties is invalid", - "data": {}, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/exclusiveMaximum.json b/src/test/resources/tck/openapi3/exclusiveMaximum.json deleted file mode 100644 index a790753f..00000000 --- a/src/test/resources/tck/openapi3/exclusiveMaximum.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - { - "description": "exclusiveMaximum validation", - "schema": { - "maximum": 3.0, - "exclusiveMaximum": true - }, - "tests": [ - { - "description": "below the exclusiveMaximum is valid", - "data": 2.2, - "valid": true - }, - { - "description": "boundary point is invalid", - "data": 3.0, - "valid": false - }, - { - "description": "above the exclusiveMaximum is invalid", - "data": 3.5, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/exclusiveMinimum.json b/src/test/resources/tck/openapi3/exclusiveMinimum.json deleted file mode 100644 index a75e6555..00000000 --- a/src/test/resources/tck/openapi3/exclusiveMinimum.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - { - "description": "exclusiveMinimum validation", - "schema": { - "minimum": 1.1, - "exclusiveMinimum": true - }, - "tests": [ - { - "description": "above the exclusiveMinimum is valid", - "data": 1.2, - "valid": true - }, - { - "description": "boundary point is invalid", - "data": 1.1, - "valid": false - }, - { - "description": "below the exclusiveMinimum is invalid", - "data": 0.6, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/format.json b/src/test/resources/tck/openapi3/format.json deleted file mode 100644 index 0f3d1c2e..00000000 --- a/src/test/resources/tck/openapi3/format.json +++ /dev/null @@ -1,312 +0,0 @@ -[ - { - "description": "validation of date-time strings", - "schema": {"format": "date-time"}, - "tests": [ - { - "description": "a valid date-time string", - "data": "1963-06-19T08:30:06.283185Z", - "valid": true - }, - { - "description": "an invalid date-time string", - "data": "06/19/1963 08:30:06 PST", - "valid": false - }, - { - "description": "only RFC3339 not all of ISO 8601 are valid", - "data": "2013-350T01:01:01", - "valid": false - } - ] - }, - { - "description": "ignore password format", - "schema": { - "format": "password" - }, - "tests": [ - { - "description": "a valid string", - "data": "hello world", - "valid": true - } - ] - }, - { - "description": "validation of URIs", - "schema": { - "format": "uri" - }, - "tests": [ - { - "description": "a valid URL with anchor tag", - "data": "http://foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid URL with anchor tag and parantheses", - "data": "http://foo.com/blah_(wikipedia)_blah#cite-1", - "valid": true - }, - { - "description": "a valid URL with URL-encoded stuff", - "data": "http://foo.bar/?q=Test%20URL-encoded%20stuff", - "valid": true - }, - { - "description": "a valid puny-coded URL ", - "data": "http://xn--nw2a.xn--j6w193g/", - "valid": true - }, - { - "description": "a valid URL with many special characters", - "data": "http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", - "valid": true - }, - { - "description": "a valid URL based on IPv4", - "data": "http://223.255.255.254", - "valid": true - }, - { - "description": "a valid URL with ftp scheme", - "data": "ftp://ftp.is.co.za/rfc/rfc1808.txt", - "valid": true - }, - { - "description": "a valid URL for a simple text file", - "data": "http://www.ietf.org/rfc/rfc2396.txt", - "valid": true - }, - { - "description": "a valid URL ", - "data": "ldap://[2001:db8::7]/c=GB?objectClass?one", - "valid": true - }, - { - "description": "a valid mailto URI", - "data": "mailto:John.Doe@example.com", - "valid": true - }, - { - "description": "a valid newsgroup URI", - "data": "news:comp.infosystems.www.servers.unix", - "valid": true - }, - { - "description": "a valid tel URI", - "data": "tel:+1-816-555-1212", - "valid": true - }, - { - "description": "a valid URN", - "data": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", - "valid": true - }, - { - "description": "an invalid protocol-relative URI Reference", - "data": "//foo.bar/?baz=qux#quux", - "valid": false - }, - { - "description": "an invalid relative URI Reference", - "data": "/abc", - "valid": false - }, - { - "description": "an invalid URI", - "data": "\\\\WINDOWS\\fileshare", - "valid": false - }, - { - "description": "an invalid URI though valid URI reference", - "data": "abc", - "valid": false - }, - { - "description": "an invalid URI with spaces", - "data": "http:// shouldfail.com", - "valid": false - }, - { - "description": "an invalid URI with spaces and missing scheme", - "data": ":// should fail", - "valid": false - } - ] - }, - { - "description": "validation of URI References", - "schema": {"format": "uriref"}, - "tests": [ - { - "description": "a valid URI", - "data": "http://foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid protocol-relative URI Reference", - "data": "//foo.bar/?baz=qux#quux", - "valid": true - }, - { - "description": "a valid relative URI Reference", - "data": "/abc", - "valid": true - }, - { - "description": "an invalid URI Reference", - "data": "\\\\WINDOWS\\fileshare", - "valid": false - }, - { - "description": "a valid URI Reference", - "data": "abc", - "valid": true - }, - { - "description": "a valid URI fragment", - "data": "#fragment", - "valid": true - }, - { - "description": "an invalid URI fragment", - "data": "#frag\\ment", - "valid": false - } - ] - }, - { - "description": "validation of e-mail addresses", - "schema": {"format": "email"}, - "tests": [ - { - "description": "a valid e-mail address", - "data": "joe.bloggs@example.com", - "valid": true - }, - { - "description": "an invalid e-mail address", - "data": "2962", - "valid": false - } - ] - }, - { - "description": "validation of IP addresses", - "schema": {"format": "ipv4"}, - "tests": [ - { - "description": "a valid IP address", - "data": "192.168.0.1", - "valid": true - }, - { - "description": "an IP address with too many components", - "data": "127.0.0.0.1", - "valid": false - }, - { - "description": "an IP address with out-of-range values", - "data": "256.256.256.256", - "valid": false - }, - { - "description": "an IP address without 4 components", - "data": "127.0", - "valid": false - }, - { - "description": "an IP address as an integer", - "data": "0x7f000001", - "valid": false - } - ] - }, - { - "description": "validation of IPv6 addresses", - "schema": {"format": "ipv6"}, - "tests": [ - { - "description": "a valid IPv6 address", - "data": "::1", - "valid": true - }, - { - "description": "an IPv6 address with out-of-range values", - "data": "12345::", - "valid": false - }, - { - "description": "an IPv6 address with too many components", - "data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1", - "valid": false - }, - { - "description": "an IPv6 address containing illegal characters", - "data": "::laptop", - "valid": false - } - ] - }, - { - "description": "validation of host names", - "schema": {"format": "hostname"}, - "tests": [ - { - "description": "a valid host name", - "data": "www.example.com", - "valid": true - }, - { - "description": "a host name starting with an illegal character", - "data": "-a-host-name-that-starts-with--", - "valid": false - }, - { - "description": "a host name containing illegal characters", - "data": "not_a_valid_host_name", - "valid": false - }, - { - "description": "a host name with a component too long", - "data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component", - "valid": false - } - ] - }, - { - "description": "validation of binary data (format: byte) a base64 encoded String", - "schema": { - "format": "byte" - }, - "tests": [ - { - "description": "The String \"This is a base64 encoded String\" base64 encoded", - "data": "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIFN0cmluZw==", - "valid": true - }, - { - "description": "Accepts symbols like: +, /, =", - "data": "sdFd/+==", - "valid": true - }, - { - "description": "a Base64 String must have at least 4 characters", - "data": "VG=", - "valid": false - }, - { - "description": "a Base64 String cannot have whitespaces", - "data": "VG =", - "valid": false - }, - { - "description": "a Base64 String must have only digits, characters and symbols like: +, /, =", - "data": "sdFG$==", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/items.json b/src/test/resources/tck/openapi3/items.json deleted file mode 100644 index fb96ced5..00000000 --- a/src/test/resources/tck/openapi3/items.json +++ /dev/null @@ -1,30 +0,0 @@ -[ - { - "description": "a schema given for items", - "schema": { - "items": {"type": "integer"} - }, - "tests": [ - { - "description": "valid items", - "data": [ 1, 2, 3 ], - "valid": true - }, - { - "description": "wrong type of items", - "data": [1, "x"], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": {"foo" : "bar"}, - "valid": true - }, - { - "description": "wrong type of items (boolean)", - "data": false, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/manual/additionalPropertiesDeepDefault.json b/src/test/resources/tck/openapi3/manual/additionalPropertiesDeepDefault.json deleted file mode 100644 index 318a20fd..00000000 --- a/src/test/resources/tck/openapi3/manual/additionalPropertiesDeepDefault.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "type": "object", - "properties": { - "a": { - "type": "object", - "additionalProperties": { - "type": "object", - "properties": { - "c1": { - "type": "string", - "default": "c1" - }, - "c2": { - "type": "string" - }, - "c3": { - "type": "object", - "properties": { - "d": { - "type": "string" - } - }, - "required": ["d"] - } - }, - "required": ["c2"] - } - } - } -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/manual/allOfDeepDefault.json b/src/test/resources/tck/openapi3/manual/allOfDeepDefault.json deleted file mode 100644 index f048096f..00000000 --- a/src/test/resources/tck/openapi3/manual/allOfDeepDefault.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "allOf": [ - { - "type": "object", - "properties": { - "a": { - "type": "object", - "properties": { - "a": { - "type": "string", - "default": "deep_a" - } - } - }, - "b": { - "type": "object", - "properties": { - "b": { - "type": "string", - "default": "deep_b" - } - } - } - } - }, - { - "type": "object", - "properties": { - "c": { - "type": "string", - "default": "c" - }, - "a": { - "type": "object", - "properties": { - "a": { - "type": "string" - } - } - } - } - } - ] -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/manual/defaultSchema_1.json b/src/test/resources/tck/openapi3/manual/defaultSchema_1.json deleted file mode 100644 index 8ecf1174..00000000 --- a/src/test/resources/tck/openapi3/manual/defaultSchema_1.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "type": "object", - "properties": { - "string": { - "type": "string", - "default": "francesco" - }, - "object": { - "type": "object", - "default": { - "hello": "francesco" - } - }, - "array": { - "type": "array", - "items": { - "type": "string" - }, - "default": [ - "bla" - ] - } - } -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/manual/missingTypeSchema.json b/src/test/resources/tck/openapi3/manual/missingTypeSchema.json deleted file mode 100644 index da6c21b6..00000000 --- a/src/test/resources/tck/openapi3/manual/missingTypeSchema.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "maximum": 10, - "maxLength": 10 -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/maxItems.json b/src/test/resources/tck/openapi3/maxItems.json deleted file mode 100644 index 3b53a6b3..00000000 --- a/src/test/resources/tck/openapi3/maxItems.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "maxItems validation", - "schema": {"maxItems": 2}, - "tests": [ - { - "description": "shorter is valid", - "data": [1], - "valid": true - }, - { - "description": "exact length is valid", - "data": [1, 2], - "valid": true - }, - { - "description": "too long is invalid", - "data": [1, 2, 3], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": "foobar", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/maxLength.json b/src/test/resources/tck/openapi3/maxLength.json deleted file mode 100644 index 811d35b2..00000000 --- a/src/test/resources/tck/openapi3/maxLength.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "maxLength validation", - "schema": {"maxLength": 2}, - "tests": [ - { - "description": "shorter is valid", - "data": "f", - "valid": true - }, - { - "description": "exact length is valid", - "data": "fo", - "valid": true - }, - { - "description": "too long is invalid", - "data": "foo", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 100, - "valid": true - }, - { - "description": "two supplementary Unicode code points is long enough", - "data": "\uD83D\uDCA9\uD83D\uDCA9", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/maxProperties.json b/src/test/resources/tck/openapi3/maxProperties.json deleted file mode 100644 index 513731e4..00000000 --- a/src/test/resources/tck/openapi3/maxProperties.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "description": "maxProperties validation", - "schema": {"maxProperties": 2}, - "tests": [ - { - "description": "shorter is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "exact length is valid", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "too long is invalid", - "data": {"foo": 1, "bar": 2, "baz": 3}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [1, 2, 3], - "valid": true - }, - { - "description": "ignores strings", - "data": "foobar", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/maximum.json b/src/test/resources/tck/openapi3/maximum.json deleted file mode 100644 index 8150984e..00000000 --- a/src/test/resources/tck/openapi3/maximum.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "maximum validation", - "schema": {"maximum": 3.0}, - "tests": [ - { - "description": "below the maximum is valid", - "data": 2.6, - "valid": true - }, - { - "description": "boundary point is valid", - "data": 3.0, - "valid": true - }, - { - "description": "above the maximum is invalid", - "data": 3.5, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/minItems.json b/src/test/resources/tck/openapi3/minItems.json deleted file mode 100644 index ed511881..00000000 --- a/src/test/resources/tck/openapi3/minItems.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "minItems validation", - "schema": {"minItems": 1}, - "tests": [ - { - "description": "longer is valid", - "data": [1, 2], - "valid": true - }, - { - "description": "exact length is valid", - "data": [1], - "valid": true - }, - { - "description": "too short is invalid", - "data": [], - "valid": false - }, - { - "description": "ignores non-arrays", - "data": "", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/minLength.json b/src/test/resources/tck/openapi3/minLength.json deleted file mode 100644 index 3f09158d..00000000 --- a/src/test/resources/tck/openapi3/minLength.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "description": "minLength validation", - "schema": {"minLength": 2}, - "tests": [ - { - "description": "longer is valid", - "data": "foo", - "valid": true - }, - { - "description": "exact length is valid", - "data": "fo", - "valid": true - }, - { - "description": "too short is invalid", - "data": "f", - "valid": false - }, - { - "description": "ignores non-strings", - "data": 1, - "valid": true - }, - { - "description": "one supplementary Unicode code point is not long enough", - "data": "\uD83D\uDCA9", - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/minProperties.json b/src/test/resources/tck/openapi3/minProperties.json deleted file mode 100644 index 49a0726e..00000000 --- a/src/test/resources/tck/openapi3/minProperties.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "description": "minProperties validation", - "schema": {"minProperties": 1}, - "tests": [ - { - "description": "longer is valid", - "data": {"foo": 1, "bar": 2}, - "valid": true - }, - { - "description": "exact length is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "too short is invalid", - "data": {}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores strings", - "data": "", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/minimum.json b/src/test/resources/tck/openapi3/minimum.json deleted file mode 100644 index bd1e95bc..00000000 --- a/src/test/resources/tck/openapi3/minimum.json +++ /dev/null @@ -1,28 +0,0 @@ -[ - { - "description": "minimum validation", - "schema": {"minimum": 1.1}, - "tests": [ - { - "description": "above the minimum is valid", - "data": 2.6, - "valid": true - }, - { - "description": "boundary point is valid", - "data": 1.1, - "valid": true - }, - { - "description": "below the minimum is invalid", - "data": 0.6, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "x", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/multipleOf.json b/src/test/resources/tck/openapi3/multipleOf.json deleted file mode 100644 index eff63143..00000000 --- a/src/test/resources/tck/openapi3/multipleOf.json +++ /dev/null @@ -1,60 +0,0 @@ -[ - { - "description": "by int", - "schema": {"multipleOf": 2}, - "tests": [ - { - "description": "int by int", - "data": 10, - "valid": true - }, - { - "description": "int by int fail", - "data": 7, - "valid": false - }, - { - "description": "ignores non-numbers", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "by number", - "schema": {"multipleOf": 1.5}, - "tests": [ - { - "description": "zero is multiple of anything", - "data": 0, - "valid": true - }, - { - "description": "4.5 is multiple of 1.5", - "data": 4.5, - "valid": true - }, - { - "description": "35 is not multiple of 1.5", - "data": 35, - "valid": false - } - ] - }, - { - "description": "by small number", - "schema": {"multipleOf": 0.0001}, - "tests": [ - { - "description": "0.0075 is multiple of 0.0001", - "data": 0.0002, /* TODO this number hates JVM */ - "valid": true - }, - { - "description": "0.00751 is not multiple of 0.0001", - "data": 0.00021, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/not.json b/src/test/resources/tck/openapi3/not.json deleted file mode 100644 index df5af15b..00000000 --- a/src/test/resources/tck/openapi3/not.json +++ /dev/null @@ -1,72 +0,0 @@ -[ - { - "description": "not", - "schema": { - "not": {"type": "integer"} - }, - "tests": [ - { - "description": "allowed", - "data": "foo", - "valid": true - }, - { - "description": "disallowed", - "data": 1, - "valid": false - } - ] - }, - { - "description": "not more complex schema", - "schema": { - "not": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - }, - "tests": [ - { - "description": "match", - "data": 1, - "valid": true - }, - { - "description": "other match", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "mismatch", - "data": {"foo": "bar"}, - "valid": false - } - ] - }, - { - "description": "forbidden property", - "schema": { - "properties": { - "foo": { - "not": {} - } - } - }, - "tests": [ - { - "description": "property present", - "data": {"foo": 1, "bar": 2}, - "valid": false - }, - { - "description": "property absent", - "data": {"bar": 1, "baz": 2}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/nullable.json b/src/test/resources/tck/openapi3/nullable.json deleted file mode 100644 index 5a902273..00000000 --- a/src/test/resources/tck/openapi3/nullable.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "description": "nullable validation", - "schema": {"nullable": true}, - "tests": [ - { - "description": "not null should be valid", - "data": [1, 2], - "valid": true - }, - { - "description": "null should be valid", - "data": null, - "valid": true - }, - { - "description": "empty array should be valid", - "data": [], - "valid": true - }, - { - "description": "empty object should be valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "nullable with object type validation", - "schema": {"type": "object", "nullable": true}, - "tests": [ - { - "description": "not null array should be invalid", - "data": [1, 2], - "valid": false - }, - { - "description": "null should be valid", - "data": null, - "valid": true - }, - { - "description": "empty object should be valid", - "data": {}, - "valid": true - } - ] - }, - { - "description": "not nullable with object type validation", - "schema": {"nullable": false}, - "tests": [ - { - "description": "not null array should be valid", - "data": [1, 2], - "valid": true - }, - { - "description": "null should be invalid", - "data": null, - "valid": false - }, - { - "description": "empty object should be valid", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/oneOf.json b/src/test/resources/tck/openapi3/oneOf.json deleted file mode 100644 index 3a03ded9..00000000 --- a/src/test/resources/tck/openapi3/oneOf.json +++ /dev/null @@ -1,109 +0,0 @@ -[ - { - "description": "oneOf", - "schema": { - "oneOf": [ - { - "type": "integer" - }, - { - "minimum": 2 - } - ] - }, - "tests": [ - { - "description": "first oneOf valid", - "data": 1, - "valid": true - }, - { - "description": "second oneOf valid", - "data": 2.5, - "valid": true - }, - { - "description": "both oneOf valid", - "data": 3, - "valid": false - }, - { - "description": "neither oneOf valid", - "data": 1.5, - "valid": false - } - ] - }, - { - "description": "oneOf with base schema", - "schema": { - "type": "string", - "oneOf" : [ - { - "minLength": 2 - }, - { - "maxLength": 4 - } - ] - }, - "tests": [ - { - "description": "mismatch base schema", - "data": 3, - "valid": false - }, - { - "description": "one oneOf valid", - "data": "foobar", - "valid": true - }, - { - "description": "both oneOf valid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "oneOf complex types", - "schema": { - "oneOf": [ - { - "properties": { - "bar": {"type": "integer"} - }, - "required": ["bar"] - }, - { - "properties": { - "foo": {"type": "string"} - }, - "required": ["foo"] - } - ] - }, - "tests": [ - { - "description": "first oneOf valid (complex)", - "data": {"bar": 2}, - "valid": true - }, - { - "description": "second oneOf valid (complex)", - "data": {"foo": "baz"}, - "valid": true - }, - { - "description": "both oneOf valid (complex)", - "data": {"foo": "baz", "bar": 2}, - "valid": false - }, - { - "description": "neither oneOf valid (complex)", - "data": {"foo": 2, "bar": "quux"}, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/pattern.json b/src/test/resources/tck/openapi3/pattern.json deleted file mode 100644 index 25e72997..00000000 --- a/src/test/resources/tck/openapi3/pattern.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "description": "pattern validation", - "schema": {"pattern": "^a*$"}, - "tests": [ - { - "description": "a matching pattern is valid", - "data": "aaa", - "valid": true - }, - { - "description": "a non-matching pattern is invalid", - "data": "abc", - "valid": false - }, - { - "description": "ignores non-strings", - "data": true, - "valid": true - } - ] - }, - { - "description": "pattern is not anchored", - "schema": {"pattern": "a+"}, - "tests": [ - { - "description": "matches a substring", - "data": "xxaayy", - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/properties.json b/src/test/resources/tck/openapi3/properties.json deleted file mode 100644 index d8817d4e..00000000 --- a/src/test/resources/tck/openapi3/properties.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "description": "object properties validation", - "schema": { - "properties": { - "foo": {"type": "integer"}, - "bar": {"type": "string"} - } - }, - "tests": [ - { - "description": "both properties present and valid is valid", - "data": {"foo": 1, "bar": "baz"}, - "valid": true - }, - { - "description": "one property invalid is invalid", - "data": {"foo": 1, "bar": {}}, - "valid": false - }, - { - "description": "both properties invalid is invalid", - "data": {"foo": [], "bar": {}}, - "valid": false - }, - { - "description": "doesn't invalidate other properties", - "data": {"quux": []}, - "valid": true - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": - "properties, additionalProperties interaction", - "schema": { - "properties": { - "foo": {"type": "array", "maxItems": 3}, - "bar": {"type": "array"} - }, - "additionalProperties": {"type": "integer"} - }, - "tests": [ - { - "description": "property validates property", - "data": {"foo": [1, 2]}, - "valid": true - }, - { - "description": "property invalidates property", - "data": {"foo": [1, 2, 3, 4]}, - "valid": false - }, - { - "description": "additionalProperty ignores property", - "data": {"bar": []}, - "valid": true - }, - { - "description": "additionalProperty validates others", - "data": {"quux": 3}, - "valid": true - }, - { - "description": "additionalProperty invalidates others", - "data": {"quux": "foo"}, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/ref.json b/src/test/resources/tck/openapi3/ref.json deleted file mode 100644 index 2b7f3eb8..00000000 --- a/src/test/resources/tck/openapi3/ref.json +++ /dev/null @@ -1,318 +0,0 @@ -[ - { - "description": "root pointer ref", - "schema": { - "properties": { - "foo": {"$ref": "#"} - }, - "additionalProperties": false - }, - "tests": [ - { - "description": "match", - "data": {"foo": false}, - "valid": true - }, - { - "description": "recursive match", - "data": {"foo": {"foo": false}}, - "valid": true - }, - { - "description": "mismatch", - "data": {"bar": false}, - "valid": false - }, - { - "description": "recursive mismatch", - "data": {"foo": {"bar": false}}, - "valid": false - } - ] - }, - { - "description": "relative pointer ref to object", - "schema": { - "properties": { - "foo": {"type": "integer"}, - "bar": {"$ref": "#/properties/foo"} - } - }, - "tests": [ - { - "description": "match", - "data": {"bar": 3}, - "valid": true - }, - { - "description": "mismatch", - "data": {"bar": true}, - "valid": false - } - ] - }, - { - "description": "relative pointer ref to array", - "schema": { - "items": {"allOf": [ - {"type": "integer"}, - {"$ref": "#/items/allOf/0"} - ]} - }, - "tests": [ - { - "description": "match array", - "data": [1, 2], - "valid": true - }, - { - "description": "mismatch array", - "data": [1, "foo"], - "valid": false - } - ] - }, - { - "description": "escaped pointer ref", - "schema": { - "properties": { - "tilda": {"$ref": "#/definitions/tilda~0field"}, - "slash": {"$ref": "#/definitions/slash~1field"}, - "percent": {"$ref": "#/definitions/percent%25field"} - }, - "definitions": { - "tilda~field": {"type": "integer"}, - "slash/field": {"type": "integer"}, - "percent%field": {"type": "integer"} - } - }, - "tests": [ - { - "description": "slash invalid", - "data": {"slash": "aoeu"}, - "valid": false - }, - { - "description": "tilda invalid", - "data": {"tilda": "aoeu"}, - "valid": false - }, - { - "description": "percent invalid", - "data": {"percent": "aoeu"}, - "valid": false - }, - { - "description": "slash valid", - "data": {"slash": 123}, - "valid": true - }, - { - "description": "tilda valid", - "data": {"tilda": 123}, - "valid": true - }, - { - "description": "percent valid", - "data": {"percent": 123}, - "valid": true - } - ] - }, - { - "description": "nested refs", - "schema": { - "definitions": { - "a": {"type": "integer"}, - "b": {"$ref": "#/definitions/a"}, - "c": {"$ref": "#/definitions/b"} - }, - "$ref": "#/definitions/c" - }, - "tests": [ - { - "description": "nested ref valid", - "data": 5, - "valid": true - }, - { - "description": "nested ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref overrides any sibling keywords", - "schema": { - "definitions": { - "reffed": { - "type": "array" - } - }, - "properties": { - "foo": { - "$ref": "#/definitions/reffed", - "maxItems": 2 - } - } - }, - "tests": [ - { - "description": "ref valid", - "data": { "foo": [] }, - "valid": true - }, - { - "description": "ref valid, maxItems ignored", - "data": { "foo": [ 1, 2, 3] }, - "valid": true - }, - { - "description": "ref invalid", - "data": { "foo": "string" }, - "valid": false - } - ] - }, - { - "description": "property named $ref that is not a reference", - "schema": { - "properties": { - "$ref": {"type": "string"} - } - }, - "tests": [ - { - "description": "property named $ref valid", - "data": {"$ref": "a"}, - "valid": true - }, - { - "description": "property named $ref invalid", - "data": {"$ref": 2}, - "valid": false - } - ] - }, - { - "description": "$ref to boolean schema true", - "schema": { - "$ref": "#/definitions/bool", - "definitions": { - "bool": true - } - }, - "tests": [ - { - "description": "any value is valid", - "data": "foo", - "valid": true - } - ] - }, - { - "description": "$ref to boolean schema false", - "schema": { - "$ref": "#/definitions/bool", - "definitions": { - "bool": false - } - }, - "tests": [ - { - "description": "any value is invalid", - "data": "foo", - "valid": false - } - ] - }, - { - "description": "Recursive references between schemas", - "schema": { - "$id": "http://localhost:1234/tree", - "description": "tree of nodes", - "type": "object", - "properties": { - "meta": {"type": "string"}, - "nodes": { - "type": "array", - "items": {"$ref": "node"} - } - }, - "required": ["meta", "nodes"], - "definitions": { - "node": { - "$id": "http://localhost:1234/node", - "description": "node", - "type": "object", - "properties": { - "value": {"type": "number"}, - "subtree": {"$ref": "tree"} - }, - "required": ["value"] - } - } - }, - "tests": [ - { - "description": "valid tree", - "data": { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - {"value": 1.1}, - {"value": 1.2} - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - {"value": 2.1}, - {"value": 2.2} - ] - } - } - ] - }, - "valid": true - }, - { - "description": "invalid tree", - "data": { - "meta": "root", - "nodes": [ - { - "value": 1, - "subtree": { - "meta": "child", - "nodes": [ - {"value": "string is invalid"}, - {"value": 1.2} - ] - } - }, - { - "value": 2, - "subtree": { - "meta": "child", - "nodes": [ - {"value": 2.1}, - {"value": 2.2} - ] - } - } - ] - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/refRemote.json b/src/test/resources/tck/openapi3/refRemote.json deleted file mode 100644 index 0baa397b..00000000 --- a/src/test/resources/tck/openapi3/refRemote.json +++ /dev/null @@ -1,171 +0,0 @@ -[ - { - "description": "remote ref", - "schema": {"$ref": "http://localhost:1234/integer.json"}, - "tests": [ - { - "description": "remote ref valid", - "data": 1, - "valid": true - }, - { - "description": "remote ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "fragment within remote ref", - "schema": {"$ref": "http://localhost:1234/subSchemas.json#/definitions/integer"}, - "tests": [ - { - "description": "remote fragment valid", - "data": 1, - "valid": true - }, - { - "description": "remote fragment invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "ref within remote ref", - "schema": { - "$ref": "http://localhost:1234/subSchemas.json#/definitions/refToInteger" - }, - "tests": [ - { - "description": "ref within ref valid", - "data": 1, - "valid": true - }, - { - "description": "ref within ref invalid", - "data": "a", - "valid": false - } - ] - }, - { - "description": "base URI change", - "schema": { - "$id": "http://localhost:1234/", - "items": { - "$id": "folder/", - "items": {"$ref": "folderInteger.json"} - } - }, - "tests": [ - { - "description": "base URI change ref valid", - "data": [[1]], - "valid": true - }, - { - "description": "base URI change ref invalid", - "data": [["a"]], - "valid": false - } - ] - }, - { - "description": "base URI change - change folder", - "schema": { - "$id": "http://localhost:1234/scope_change_defs1.json", - "type" : "object", - "properties": { - "list": {"$ref": "#/definitions/baz"} - }, - "definitions": { - "baz": { - "$id": "folder/", - "type": "array", - "items": {"$ref": "folderInteger.json"} - } - } - }, - "tests": [ - { - "description": "number is valid", - "data": {"list": [1]}, - "valid": true - }, - { - "description": "string is invalid", - "data": {"list": ["a"]}, - "valid": false - } - ] - }, - { - "description": "base URI change - change folder in subschema", - "schema": { - "$id": "http://localhost:1234/scope_change_defs2.json", - "type" : "object", - "properties": { - "list": {"$ref": "#/definitions/baz/definitions/bar"} - }, - "definitions": { - "baz": { - "$id": "folder/", - "definitions": { - "bar": { - "type": "array", - "items": {"$ref": "folderInteger.json"} - } - } - } - } - }, - "tests": [ - { - "description": "number is valid", - "data": {"list": [1]}, - "valid": true - }, - { - "description": "string is invalid", - "data": {"list": ["a"]}, - "valid": false - } - ] - }, - { - "description": "root ref in remote ref", - "schema": { - "$id": "http://localhost:1234/object", - "type": "object", - "properties": { - "name": {"$ref": "name.json#/definitions/orNull"} - } - }, - "tests": [ - { - "description": "string is valid", - "data": { - "name": "foo" - }, - "valid": true - }, - { - "description": "null is valid", - "data": { - "name": null - }, - "valid": true - }, - { - "description": "object is invalid", - "data": { - "name": { - "name": null - } - }, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/remotes/folder/folderInteger.json b/src/test/resources/tck/openapi3/remotes/folder/folderInteger.json deleted file mode 100644 index dbe5c758..00000000 --- a/src/test/resources/tck/openapi3/remotes/folder/folderInteger.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "integer" -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/remotes/integer.json b/src/test/resources/tck/openapi3/remotes/integer.json deleted file mode 100644 index dbe5c758..00000000 --- a/src/test/resources/tck/openapi3/remotes/integer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "integer" -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/remotes/name.json b/src/test/resources/tck/openapi3/remotes/name.json deleted file mode 100644 index 0530372f..00000000 --- a/src/test/resources/tck/openapi3/remotes/name.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "definitions": { - "orNull": { - "nullable": true, - "anyOf": [ - { - "nullable": true, - "type": "number" - }, - {"$ref": "#"} - ] - } - }, - "type": "string" -} diff --git a/src/test/resources/tck/openapi3/remotes/subSchemas.json b/src/test/resources/tck/openapi3/remotes/subSchemas.json deleted file mode 100644 index 271df004..00000000 --- a/src/test/resources/tck/openapi3/remotes/subSchemas.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "definitions": { - "integer": { - "type": "integer" - }, - "refToInteger": { - "$ref": "#/definitions/integer" - } - } -} \ No newline at end of file diff --git a/src/test/resources/tck/openapi3/required.json b/src/test/resources/tck/openapi3/required.json deleted file mode 100644 index bd96907b..00000000 --- a/src/test/resources/tck/openapi3/required.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "description": "required validation", - "schema": { - "properties": { - "foo": {}, - "bar": {} - }, - "required": ["foo"] - }, - "tests": [ - { - "description": "present required property is valid", - "data": {"foo": 1}, - "valid": true - }, - { - "description": "non-present required property is invalid", - "data": {"bar": 1}, - "valid": false - }, - { - "description": "ignores arrays", - "data": [], - "valid": true - }, - { - "description": "ignores strings", - "data": "", - "valid": true - }, - { - "description": "ignores other non-objects", - "data": 12, - "valid": true - } - ] - }, - { - "description": "required default validation", - "schema": { - "properties": { - "foo": {} - } - }, - "tests": [ - { - "description": "not required by default", - "data": {}, - "valid": true - } - ] - }, - { - "description": "required with empty array", - "schema": { - "properties": { - "foo": {} - }, - "required": [] - }, - "tests": [ - { - "description": "property not required", - "data": {}, - "valid": true - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/type.json b/src/test/resources/tck/openapi3/type.json deleted file mode 100644 index 3d1fdca0..00000000 --- a/src/test/resources/tck/openapi3/type.json +++ /dev/null @@ -1,263 +0,0 @@ -[ - { - "description": "integer type matches integers", - "schema": {"type": "integer"}, - "tests": [ - { - "description": "an integer is an integer", - "data": 1, - "valid": true - }, - { - "description": "a float is not an integer", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an integer", - "data": "foo", - "valid": false - }, - { - "description": "a string is still not an integer, even if it looks like one", - "data": "1", - "valid": false - }, - { - "description": "an object is not an integer", - "data": {}, - "valid": false - }, - { - "description": "an array is not an integer", - "data": [], - "valid": false - }, - { - "description": "a boolean is not an integer", - "data": true, - "valid": false - }, - { - "description": "null is not an integer", - "data": null, - "valid": false - } - ] - }, - { - "description": "number type matches numbers", - "schema": {"type": "number"}, - "tests": [ - { - "description": "an integer is a number", - "data": 1, - "valid": true - }, - { - "description": "a float is a number", - "data": 1.1, - "valid": true - }, - { - "description": "a string is not a number", - "data": "foo", - "valid": false - }, - { - "description": "a string is still not a number, even if it looks like one", - "data": "1", - "valid": false - }, - { - "description": "an object is not a number", - "data": {}, - "valid": false - }, - { - "description": "an array is not a number", - "data": [], - "valid": false - }, - { - "description": "a boolean is not a number", - "data": true, - "valid": false - }, - { - "description": "null is not a number", - "data": null, - "valid": false - } - ] - }, - { - "description": "string type matches strings", - "schema": {"type": "string"}, - "tests": [ - { - "description": "1 is not a string", - "data": 1, - "valid": false - }, - { - "description": "a float is not a string", - "data": 1.1, - "valid": false - }, - { - "description": "a string is a string", - "data": "foo", - "valid": true - }, - { - "description": "a string is still a string, even if it looks like a number", - "data": "1", - "valid": true - }, - { - "description": "an object is not a string", - "data": {}, - "valid": false - }, - { - "description": "an array is not a string", - "data": [], - "valid": false - }, - { - "description": "a boolean is not a string", - "data": true, - "valid": false - }, - { - "description": "null is not a string", - "data": null, - "valid": false - } - ] - }, - { - "description": "object type matches objects", - "schema": {"type": "object"}, - "tests": [ - { - "description": "an integer is not an object", - "data": 1, - "valid": false - }, - { - "description": "a float is not an object", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an object", - "data": "foo", - "valid": false - }, - { - "description": "an object is an object", - "data": {}, - "valid": true - }, - { - "description": "an array is not an object", - "data": [], - "valid": false - }, - { - "description": "a boolean is not an object", - "data": true, - "valid": false - }, - { - "description": "null is not an object", - "data": null, - "valid": false - } - ] - }, - { - "description": "array type matches arrays", - "schema": {"type": "array"}, - "tests": [ - { - "description": "an integer is not an array", - "data": 1, - "valid": false - }, - { - "description": "a float is not an array", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not an array", - "data": "foo", - "valid": false - }, - { - "description": "an object is not an array", - "data": {}, - "valid": false - }, - { - "description": "an array is an array", - "data": [], - "valid": true - }, - { - "description": "a boolean is not an array", - "data": true, - "valid": false - }, - { - "description": "null is not an array", - "data": null, - "valid": false - } - ] - }, - { - "description": "boolean type matches booleans", - "schema": {"type": "boolean"}, - "tests": [ - { - "description": "an integer is not a boolean", - "data": 1, - "valid": false - }, - { - "description": "a float is not a boolean", - "data": 1.1, - "valid": false - }, - { - "description": "a string is not a boolean", - "data": "foo", - "valid": false - }, - { - "description": "an object is not a boolean", - "data": {}, - "valid": false - }, - { - "description": "an array is not a boolean", - "data": [], - "valid": false - }, - { - "description": "a boolean is a boolean", - "data": true, - "valid": true - }, - { - "description": "null is not a boolean", - "data": null, - "valid": false - } - ] - } -] diff --git a/src/test/resources/tck/openapi3/uniqueItems.json b/src/test/resources/tck/openapi3/uniqueItems.json deleted file mode 100644 index c1f4ab99..00000000 --- a/src/test/resources/tck/openapi3/uniqueItems.json +++ /dev/null @@ -1,79 +0,0 @@ -[ - { - "description": "uniqueItems validation", - "schema": {"uniqueItems": true}, - "tests": [ - { - "description": "unique array of integers is valid", - "data": [1, 2], - "valid": true - }, - { - "description": "non-unique array of integers is invalid", - "data": [1, 1], - "valid": false - }, - { - "description": "numbers are unique if mathematically unequal", - "data": [1.0, 1.00, 1], - "valid": false - }, - { - "description": "unique array of objects is valid", - "data": [{"foo": "bar"}, {"foo": "baz"}], - "valid": true - }, - { - "description": "non-unique array of objects is invalid", - "data": [{"foo": "bar"}, {"foo": "bar"}], - "valid": false - }, - { - "description": "unique array of nested objects is valid", - "data": [ - {"foo": {"bar" : {"baz" : true}}}, - {"foo": {"bar" : {"baz" : false}}} - ], - "valid": true - }, - { - "description": "non-unique array of nested objects is invalid", - "data": [ - {"foo": {"bar" : {"baz" : true}}}, - {"foo": {"bar" : {"baz" : true}}} - ], - "valid": false - }, - { - "description": "unique array of arrays is valid", - "data": [["foo"], ["bar"]], - "valid": true - }, - { - "description": "non-unique array of arrays is invalid", - "data": [["foo"], ["foo"]], - "valid": false - }, - { - "description": "1 and true are unique", - "data": [1, true], - "valid": true - }, - { - "description": "0 and false are unique", - "data": [0, false], - "valid": true - }, - { - "description": "unique heterogeneous types are valid", - "data": [{}, [1], true, null, 1], - "valid": true - }, - { - "description": "non-unique heterogeneous types are invalid", - "data": [{}, [1], true, null, {}, 1], - "valid": false - } - ] - } -]