diff --git a/pom.xml b/pom.xml
index 56a2da5..798bcac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
es.elixir.bsc.json.schema
jaronuinga
- 0.5.2
+ 0.5.3
jar
@@ -33,8 +33,8 @@
- 11
- 11
+ 17
+ 17
diff --git a/src/main/java/es/elixir/bsc/json/schema/JsonSchemaVersion.java b/src/main/java/es/elixir/bsc/json/schema/JsonSchemaVersion.java
index fa4207d..a3cb050 100644
--- a/src/main/java/es/elixir/bsc/json/schema/JsonSchemaVersion.java
+++ b/src/main/java/es/elixir/bsc/json/schema/JsonSchemaVersion.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -35,7 +35,8 @@ public enum JsonSchemaVersion {
SCHEMA_DRAFT_04("http://json-schema.org/draft-04/schema#"),
SCHEMA_DRAFT_06("http://json-schema.org/draft-06/schema#"),
SCHEMA_DRAFT_07("http://json-schema.org/draft-07/schema#"),
- SCHEMA_DRAFT_2019_09("https://json-schema.org/draft/2019-09/schema");
+ SCHEMA_DRAFT_2019_09("https://json-schema.org/draft/2019-09/schema"),
+ SCHEMA_DRAFT_2020_12("https://json-schema.org/draft/2020-12/schema");
public final String VALUE;
diff --git a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaLocator.java b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaLocator.java
index 5839781..48eb0ed 100644
--- a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaLocator.java
+++ b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaLocator.java
@@ -84,33 +84,43 @@ public JsonValue getSchema(URI uri, String jsonPointer)
JsonValue schema = schemas.get(uri);
if (schema == null) {
- final InputStream in;
- final String scheme = uri.getScheme();
- if ("http".equals(scheme) || "https".equals(scheme)) {
- try {
- final HttpResponse response =
- http_client.send(HttpRequest.newBuilder(uri).build(),
- HttpResponse.BodyHandlers.ofInputStream());
- if (response == null) {
- throw new IOException(String.format("no respnse from %s", uri));
+ try {
+ uri = new URI(uri.getScheme(), uri.getSchemeSpecificPart(), null);
+ schema = schemas.get(uri);
+ if (schema == null) {
+ InputStream in = null;
+ final String scheme = uri.getScheme();
+ if ("http".equals(scheme) || "https".equals(scheme)) {
+ try {
+ final HttpResponse response =
+ http_client.send(HttpRequest.newBuilder(uri).build(),
+ HttpResponse.BodyHandlers.ofInputStream());
+ if (response == null) {
+ throw new IOException(String.format("no respnse from %s", uri));
+ }
+
+ if (response.statusCode() >= 300) {
+ throw new IOException(String.format("error reading from %s %d", uri, response.statusCode()));
+ }
+ in = response.body();
+ } catch (InterruptedException ex) {
+ throw new IOException(String.format("no respnse from %s", uri));
+ }
+ } else {
+ // not http schemas like "file" etc...
+ in = uri.toURL().openStream();
}
- if (response.statusCode() >= 300) {
- throw new IOException(String.format("error reading from %s %d", uri, response.statusCode()));
+ try {
+ final JsonReaderFactory factory = Json.createReaderFactory(Collections.EMPTY_MAP);
+ final JsonReader reader = factory.createReader(in);
+ schema = reader.readValue();
+ setSchema(schema);
+ } finally {
+ in.close();
}
- in = response.body();
- } catch (InterruptedException ex) {
- throw new IOException(String.format("no respnse from %s", uri));
}
- } else {
- // not http schemas like "file" etc...
- in = uri.toURL().openStream();
- }
-
- final JsonReaderFactory factory = Json.createReaderFactory(Collections.EMPTY_MAP);
- final JsonReader reader = factory.createReader(in);
- schema = reader.readValue();
- setSchema(schema);
+ } catch (URISyntaxException ex) {}
}
if ("/".endsWith(jsonPointer)) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaParser.java b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaParser.java
index 20ab970..0005839 100644
--- a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaParser.java
+++ b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaParser.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -33,7 +33,6 @@
import es.elixir.bsc.json.schema.ParsingMessage;
import static es.elixir.bsc.json.schema.model.JsonEnum.ENUM;
import es.elixir.bsc.json.schema.model.JsonType;
-import es.elixir.bsc.json.schema.model.impl.JsonAnyOfImpl;
import es.elixir.bsc.json.schema.model.impl.JsonArraySchemaImpl;
import es.elixir.bsc.json.schema.model.impl.JsonBooleanSchemaImpl;
import es.elixir.bsc.json.schema.model.impl.JsonEnumImpl;
@@ -52,6 +51,7 @@
import es.elixir.bsc.json.schema.model.impl.JsonConstImpl;
import es.elixir.bsc.json.schema.model.impl.JsonReferenceImpl;
import es.elixir.bsc.json.schema.model.impl.AbstractJsonSchemaElement;
+import es.elixir.bsc.json.schema.model.impl.JsonMultitypeSchemaWrapper;
import java.util.Map;
import javax.json.JsonArray;
import javax.json.JsonObject;
@@ -87,8 +87,8 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
}
if (value.getValueType() != ValueType.OBJECT) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.SCHEMA_OBJECT_ERROR,
- new Object[] {value.getValueType()}));
+ throw new JsonSchemaException(new ParsingError(
+ ParsingMessage.SCHEMA_OBJECT_ERROR, value.getValueType()));
}
final JsonObject object = value.asJsonObject();
@@ -97,7 +97,7 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
if (jref != null) {
if (JsonValue.ValueType.STRING != jref.getValueType()) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {JsonReference.REF, jref.getValueType().name(), JsonValue.ValueType.STRING.name()}));
+ JsonReference.REF, jref.getValueType().name(), JsonValue.ValueType.STRING.name()));
}
// before draft 2019-09 $ref ignored any other properties
@@ -110,22 +110,22 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
final ValueType vtype;
if (type_value == null) {
vtype = null;
- } else {
+ } else {
vtype = type_value.getValueType();
switch(vtype) {
case STRING:
- try {
+ try {
type = JsonType.fromValue(((JsonString)type_value).getString());
- } catch(IllegalArgumentException ex) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.UNKNOWN_OBJECT_TYPE,
- new Object[] {((JsonString)type_value).getString()}));
- }
+ } catch(IllegalArgumentException ex) {
+ throw new JsonSchemaException(new ParsingError(
+ ParsingMessage.UNKNOWN_OBJECT_TYPE, ((JsonString)type_value).getString()));
+ }
case ARRAY: break;
- default:
+ default:
throw new JsonSchemaException(new ParsingError(
- ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {"type", type_value.getValueType().name(),
- "either a string or an array"}));
+ ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ "type", type_value.getValueType().name(),
+ "either a string or an array"));
}
}
@@ -143,7 +143,8 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
}
if (type == null) {
- return new JsonAnyOfImpl(parent, locator, jsonPointer, vtype == ValueType.ARRAY ? type_value.asJsonArray() : null)
+ return new JsonMultitypeSchemaWrapper(parent, locator, jsonPointer,
+ vtype == ValueType.ARRAY ? type_value.asJsonArray() : null)
.read(this, object, null);
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaReader.java b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaReader.java
index 0385748..c05a754 100644
--- a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaReader.java
+++ b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonSchemaReader.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -65,8 +65,8 @@ public JsonSchema read(URL url) throws JsonSchemaException {
try {
return read(new DefaultJsonSchemaLocator(url.toURI()));
} catch (URISyntaxException ex) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_REFERENCE,
- new Object[] {url.toString()}));
+ throw new JsonSchemaException(
+ new ParsingError(ParsingMessage.INVALID_REFERENCE, url.toString()));
}
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/JsonDynamicReference.java b/src/main/java/es/elixir/bsc/json/schema/model/JsonDynamicReference.java
new file mode 100644
index 0000000..ffbdd93
--- /dev/null
+++ b/src/main/java/es/elixir/bsc/json/schema/model/JsonDynamicReference.java
@@ -0,0 +1,35 @@
+/**
+ * *****************************************************************************
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * and Barcelona Supercomputing Center (BSC)
+ *
+ * Modifications to the initial code base are copyright of their respective
+ * authors, or their employers as appropriate.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *****************************************************************************
+ */
+
+package es.elixir.bsc.json.schema.model;
+
+/**
+ * @author Dmitry Repchevsky
+ */
+
+public interface JsonDynamicReference extends JsonReference {
+
+ public final static String DYNAMIC_REF = "$dynamicRef";
+}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/JsonSchema.java b/src/main/java/es/elixir/bsc/json/schema/model/JsonSchema.java
index 29a89bf..8eb5aea 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/JsonSchema.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/JsonSchema.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -43,6 +43,7 @@ public interface JsonSchema extends JsonSchemaElement {
public final static String DEFS = "$defs";
public final static String ANCHOR = "$anchor";
public final static String RECURSIVE_ANCHOR = "$recursiveAnchor";
+ public final static String DYNAMIC_ANCHOR = "$dynamicAnchor";
public final static String VOCABULARY = "$vocabulary";
boolean validate(JsonValue value, List errors, JsonSchemaValidationCallback callback) throws ValidationException;
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/JsonSchemaElement.java b/src/main/java/es/elixir/bsc/json/schema/model/JsonSchemaElement.java
index 4a12fc8..0a966f7 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/JsonSchemaElement.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/JsonSchemaElement.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -61,5 +61,5 @@ public interface JsonSchemaElement {
*
* @return stream of child schemas
*/
- public abstract Stream getChildren();
+ Stream getChildren();
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/PrimitiveSchema.java b/src/main/java/es/elixir/bsc/json/schema/model/PrimitiveSchema.java
index 34c3944..aa89d89 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/PrimitiveSchema.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/PrimitiveSchema.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -60,12 +60,4 @@ public interface PrimitiveSchema extends JsonSchema {
T getElse();
JsonReference getReference();
-
- /**
- * $RecursiveAnchor property
- * @see https://json-schema.org/draft/2019-09/json-schema-core.html#recursive-ref
- *
- * @return TRUE when "recursiveAnchor": true
- */
- boolean isRecursiveAnchor();
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonReferenceImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonReferenceImpl.java
index 163d957..5849ac4 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonReferenceImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonReferenceImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -28,12 +28,20 @@
import es.elixir.bsc.json.schema.JsonSchemaException;
import es.elixir.bsc.json.schema.JsonSchemaLocator;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
+import es.elixir.bsc.json.schema.ParsingError;
+import es.elixir.bsc.json.schema.ParsingMessage;
import es.elixir.bsc.json.schema.ValidationError;
import es.elixir.bsc.json.schema.ValidationException;
+import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import es.elixir.bsc.json.schema.model.JsonReference;
+import es.elixir.bsc.json.schema.model.JsonSchemaElement;
+import es.elixir.bsc.json.schema.model.JsonType;
+import javax.json.JsonException;
import java.util.List;
import javax.json.JsonObject;
import javax.json.JsonValue;
+import java.net.URI;
+import java.net.URISyntaxException;
/**
* @author Dmitry Repchevsky
@@ -42,11 +50,51 @@
public abstract class AbstractJsonReferenceImpl extends AbstractJsonSchema
implements JsonReference {
+ protected JsonSchemaElement schema;
+
+ protected URI ref;
+ protected String ref_pointer;
+ protected JsonSchemaLocator ref_locator;
+ protected JsonSubschemaParser parser;
+
public AbstractJsonReferenceImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
String jsonPointer) {
super(parent, locator, jsonPointer);
}
+ protected void read(JsonSubschemaParser parser, JsonObject object,
+ JsonType type, String tag) throws JsonSchemaException {
+
+ this.parser = parser;
+
+ final String jref = object.getString(tag);
+ try {
+ ref = URI.create(jref);
+ final String fragment = ref.getFragment();
+ if (fragment == null) {
+ ref_pointer = "/";
+ ref_locator = getScope().resolve(ref);
+ } else if ("#".equals(jref)) {
+ ref_pointer = "/";
+ ref_locator = getScope();
+ } else if (fragment.startsWith("/")) {
+ ref_pointer = fragment;
+ if (jref.startsWith("#")) {
+ ref_locator = getScope();
+ } else {
+ ref_locator = getScope().resolve(
+ new URI(ref.getScheme(), ref.getSchemeSpecificPart(), null));
+ }
+ } else {
+ ref_pointer = "/";
+ ref_locator = getScope().resolve(ref);
+ }
+ } catch(JsonException | IllegalArgumentException | URISyntaxException ex) {
+ throw new JsonSchemaException(
+ new ParsingError(ParsingMessage.INVALID_REFERENCE, ref));
+ }
+ }
+
@Override
public boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
List evaluated, List errors,
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonSchema.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonSchema.java
index c8ad49d..606cf28 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonSchema.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/AbstractJsonSchema.java
@@ -60,14 +60,14 @@ public AbstractJsonSchema read(JsonSubschemaParser parser, T value,
}
public abstract boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
- List evaluated, List errors,
- JsonSchemaValidationCallback callback)
+ List evaluated, List errors,
+ JsonSchemaValidationCallback callback)
throws ValidationException;
@Override
public boolean validate(JsonValue value, List errors,
JsonSchemaValidationCallback callback)
throws ValidationException {
- return validate("", value, null, new ArrayList(), errors, callback);
+ return validate("/", value, null, new ArrayList(), errors, callback);
}
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/BooleanJsonSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/BooleanJsonSchemaImpl.java
index 807e56e..830f005 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/BooleanJsonSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/BooleanJsonSchemaImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -68,8 +68,8 @@ public BooleanJsonSchemaImpl read(final JsonSubschemaParser parser,
if (schema.getValueType() != ValueType.TRUE &&
schema.getValueType() != ValueType.FALSE) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.SCHEMA_OBJECT_ERROR,
- new Object[] {schema.getValueType()}));
+ throw new JsonSchemaException(new ParsingError(
+ ParsingMessage.SCHEMA_OBJECT_ERROR, schema.getValueType()));
}
evaluation = schema.getValueType() == ValueType.TRUE;
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAllOfImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAllOfImpl.java
index b4097c2..9b2bf34 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAllOfImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAllOfImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -42,7 +42,7 @@
* @author Dmitry Repchevsky
*/
-public class JsonAllOfImpl extends SchemaArrayImpl
+public class JsonAllOfImpl extends SchemaArrayImpl
implements JsonAllOf {
public JsonAllOfImpl(AbstractJsonSchema parent, JsonSchemaLocator locator,
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAnyOfImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAnyOfImpl.java
index 13239b6..aae3683 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAnyOfImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonAnyOfImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -33,66 +33,30 @@
import java.util.ArrayList;
import java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
-import es.elixir.bsc.json.schema.ParsingError;
-import es.elixir.bsc.json.schema.ParsingMessage;
import es.elixir.bsc.json.schema.ValidationException;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import es.elixir.bsc.json.schema.model.JsonType;
-import javax.json.JsonArray;
-import javax.json.JsonString;
import javax.json.JsonValue;
/**
* @author Dmitry Repchevsky
+ *
+ * @param
*/
-public class JsonAnyOfImpl extends SchemaArrayImpl
+public class JsonAnyOfImpl extends SchemaArrayImpl
implements JsonAnyOf {
- private JsonArray types;
-
public JsonAnyOfImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
String jsonPointer) {
super(parent, locator, jsonPointer);
}
- public JsonAnyOfImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
- String jsonPointer, JsonArray types) {
- super(parent, locator, jsonPointer);
-
- this.types = types;
- }
-
@Override
public JsonAnyOfImpl read(final JsonSubschemaParser parser,
- final JsonValue value,
+ final T value,
final JsonType type) throws JsonSchemaException {
-
- if (types == null) {
- for (JsonType val : JsonType.values()) {
- try {
- final AbstractJsonSchema s = parser.parse(getScope(), this, getJsonPointer(), value, val);
- if (s != null) {
- add(s);
- }
- } catch(JsonSchemaException ex) {
- // do nothing
- }
- }
- } else {
- for (JsonValue val : types) {
- if (JsonValue.ValueType.STRING != val.getValueType()) {
-
- }
- try {
- final JsonType t = JsonType.fromValue(((JsonString)val).getString());
- add(parser.parse(getScope(), parent, getJsonPointer(), value, t));
- } catch(IllegalArgumentException ex) {
- throw new JsonSchemaException(
- new ParsingError(ParsingMessage.UNKNOWN_OBJECT_TYPE, val));
- }
- }
- }
+ super.read(parser, value, type);
return this;
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonArraySchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonArraySchemaImpl.java
index a7e1bec..e3fc7f4 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonArraySchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonArraySchemaImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -37,6 +37,7 @@
import java.util.ArrayList;
import java.util.List;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
+import static es.elixir.bsc.json.schema.model.JsonArraySchema.ADDITIONAL_ITEMS;
import es.elixir.bsc.json.schema.model.JsonSchemaElement;
import java.util.HashSet;
import java.util.Set;
@@ -169,7 +170,7 @@ public JsonArraySchemaImpl read(final JsonSubschemaParser parser,
case TRUE: uniqueItems = true; break;
case FALSE: uniqueItems = false; break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {UNIQUE_ITEMS, juniqueItems.getValueType().name(), "must be boolean"}));
+ UNIQUE_ITEMS, juniqueItems.getValueType().name(), "must be boolean"));
}
}
@@ -206,12 +207,12 @@ public JsonArraySchemaImpl read(final JsonSubschemaParser parser,
getItems().add(arr);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {ITEMS + "/" + i, value.getValueType().name(), "either an object or boolean"}));
+ ITEMS + "/" + i, value.getValueType().name(), "either an object or boolean"));
}
}
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {ITEMS, jitems.getValueType().name(), "either an object, boolean or an array"}));
+ ITEMS, jitems.getValueType().name(), "either an object, boolean or an array"));
}
}
@@ -224,7 +225,7 @@ public JsonArraySchemaImpl read(final JsonSubschemaParser parser,
case FALSE: additionalItems = false;
case TRUE: break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {ADDITIONAL_ITEMS, jadditionalItems.getValueType().name(), "either object or boolean"}));
+ ADDITIONAL_ITEMS, jadditionalItems.getValueType().name(), "either object or boolean"));
}
additionalItemsSchema = parser.parse(getScope(), this, getJsonPointer() + "/" + ADDITIONAL_ITEMS, jadditionalItems, null);
}
@@ -239,7 +240,7 @@ public JsonArraySchemaImpl read(final JsonSubschemaParser parser,
case TRUE: unevaluatedItems = true; break;
case FALSE: unevaluatedItems = false; break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {UNEVALUATED_ITEMS, junevaluatedItems.getValueType().name(), "either object or boolean"}));
+ UNEVALUATED_ITEMS, junevaluatedItems.getValueType().name(), "either object or boolean"));
}
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonConstImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonConstImpl.java
index 2c867b2..afe0a02 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonConstImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonConstImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -86,7 +86,7 @@ public boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
return super.validate(jsonPointer, value, parent, evaluated, errors, callback);
}
-
+
protected static boolean equals(JsonValue v1, JsonValue v2) {
if (v1.getValueType() != v2.getValueType()) {
return false;
@@ -94,6 +94,15 @@ protected static boolean equals(JsonValue v1, JsonValue v2) {
switch(v1.getValueType()) {
case NUMBER: return ((JsonNumber)v1).doubleValue() == ((JsonNumber)v2).doubleValue();
+ case ARRAY: if (v1.asJsonArray().size() != v2.asJsonArray().size()) {
+ return false;
+ }
+ for (int i = 0, n = v1.asJsonArray().size(); i < n; i++) {
+ if (!equals(v1.asJsonArray().get(i), v2.asJsonArray().get(i))) {
+ return false;
+ }
+ }
+ return true;
}
return v1.equals(v2);
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDependentPropertiesImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDependentPropertiesImpl.java
index a7a8aa2..f8ceafb 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDependentPropertiesImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDependentPropertiesImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -93,7 +93,7 @@ public JsonDependentProperties read(JsonSchemaParser parser, JsonObject object)
final JsonValue value = entry.getValue();
if (JsonValue.ValueType.ARRAY != value.getValueType()) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_OBJECT_TYPE,
- new Object[] {name + " dependentRequired schema ", value.getValueType().name(), JsonValue.ValueType.ARRAY.name()}));
+ name + " dependentRequired schema ", value.getValueType().name(), JsonValue.ValueType.ARRAY.name()));
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDynamicReferenceImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDynamicReferenceImpl.java
new file mode 100644
index 0000000..d49e6f2
--- /dev/null
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonDynamicReferenceImpl.java
@@ -0,0 +1,116 @@
+/**
+ * *****************************************************************************
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * and Barcelona Supercomputing Center (BSC)
+ *
+ * Modifications to the initial code base are copyright of their respective
+ * authors, or their employers as appropriate.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *****************************************************************************
+ */
+
+package es.elixir.bsc.json.schema.model.impl;
+
+import es.elixir.bsc.json.schema.JsonSchemaException;
+import es.elixir.bsc.json.schema.JsonSchemaLocator;
+import es.elixir.bsc.json.schema.ParsingError;
+import es.elixir.bsc.json.schema.ParsingMessage;
+import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
+import es.elixir.bsc.json.schema.model.JsonDynamicReference;
+import es.elixir.bsc.json.schema.model.JsonSchemaElement;
+import es.elixir.bsc.json.schema.model.JsonType;
+import java.util.stream.Stream;
+import javax.json.JsonObject;
+import javax.json.JsonValue;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * @author Dmitry Repchevsky
+ */
+
+public class JsonDynamicReferenceImpl extends JsonReferenceImpl
+ implements JsonDynamicReference {
+
+ public JsonDynamicReferenceImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
+ String jsonPointer) {
+ super(parent, locator, jsonPointer);
+ }
+
+ @Override
+ public Stream getChildren() {
+ return Stream.of(); // TODO
+ }
+
+ @Override
+ public JsonSchemaElement getSchema() throws JsonSchemaException {
+ if (schema == null) {
+ final String fragment = ref.getFragment();
+ if (fragment != null) {
+ try {
+ AbstractJsonSchemaElement e = getSchema(this, ref);
+ if (e == null) {
+ final JsonValue value = ref_locator.getSchema("/");
+ e = parser.parse(ref_locator, null, "/", value, null);
+ }
+ schema = getSchema(e, ref);
+ if (schema != null) {
+ final URI uri = new URI(null, null, fragment);
+ while ((e = e.getParent()) != null) {
+ final JsonSchemaElement s = getSchema(e, uri);
+ if (s != null) {
+ schema = s;
+ }
+
+ }
+ }
+ } catch (IOException | URISyntaxException ex) {}
+ }
+ }
+
+ if (schema == null && super.getSchema() == null) {
+ throw new JsonSchemaException(
+ new ParsingError(ParsingMessage.UNRESOLVABLE_REFERENCE, ref));
+ }
+
+ return schema;
+ }
+
+ private AbstractJsonSchemaElement getSchema(AbstractJsonSchemaElement e, URI uri)
+ throws IOException, JsonSchemaException {
+ final String fragment = uri.getFragment();
+ final JsonSchemaLocator scope = e.getScope().resolve(uri);
+ final JsonValue value = scope.getSchema("/");
+ if (value instanceof JsonObject jsubschema) {
+ final String anchor = jsubschema.getString(DYNAMIC_ANCHOR, null);
+ if (fragment.equals(anchor)) {
+ return parser.parse(scope, e.getParent(), e.getJsonPointer(), jsubschema, null);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public JsonDynamicReferenceImpl read(JsonSubschemaParser parser,
+ JsonObject object, JsonType type) throws JsonSchemaException {
+
+ super.read(parser, object, type, DYNAMIC_REF);
+
+ return this;
+ }
+}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonIntegerSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonIntegerSchemaImpl.java
index 21202e0..e53b3c9 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonIntegerSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonIntegerSchemaImpl.java
@@ -109,7 +109,7 @@ public boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
return nerrors == errors.size();
}
-
+
public void validate(String jsonPointer, BigInteger num, List errors) {
if (minimum != null) {
if (isExclusiveMinimum != null && isExclusiveMinimum) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonMultitypeSchemaWrapper.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonMultitypeSchemaWrapper.java
new file mode 100644
index 0000000..6392ee3
--- /dev/null
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonMultitypeSchemaWrapper.java
@@ -0,0 +1,120 @@
+/**
+ * *****************************************************************************
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * and Barcelona Supercomputing Center (BSC)
+ *
+ * Modifications to the initial code base are copyright of their respective
+ * authors, or their employers as appropriate.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ * *****************************************************************************
+ */
+
+package es.elixir.bsc.json.schema.model.impl;
+
+import es.elixir.bsc.json.schema.JsonSchemaException;
+import es.elixir.bsc.json.schema.JsonSchemaLocator;
+import es.elixir.bsc.json.schema.ParsingError;
+import es.elixir.bsc.json.schema.ParsingMessage;
+import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
+import es.elixir.bsc.json.schema.model.JsonSchema;
+import es.elixir.bsc.json.schema.model.JsonType;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonString;
+import javax.json.JsonValue;
+import java.net.URI;
+
+/**
+ * The multiple types wrapper which is used when no type or a set of types is defined.
+ * For instance, the wrapper is used when we have something like "type": ["string", "integer"].
+ * It acts as "anyOf", but has it's own scope which is the same as the child elements.
+ *
+ * @author Dmitry Repchevsky
+ */
+
+public class JsonMultitypeSchemaWrapper extends JsonAnyOfImpl {
+
+ private JsonSchemaLocator scope;
+ private final JsonArray types;
+
+ public JsonMultitypeSchemaWrapper(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
+ String jsonPointer, JsonArray types) {
+ super(parent, locator, jsonPointer);
+
+ this.types = types;
+ }
+
+ @Override
+ public JsonSchemaLocator getScope() {
+ return scope;
+ }
+
+ @Override
+ public JsonAnyOfImpl read(final JsonSubschemaParser parser,
+ final JsonObject object,
+ final JsonType type) throws JsonSchemaException {
+
+ JsonValue $id = object.get(JsonSchema.ID);
+ if ($id == null) {
+ $id = object.get("id"); // draft4
+ }
+
+ if ($id == null) {
+ scope = locator;
+ } else if ($id.getValueType() != JsonValue.ValueType.STRING) {
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ "id", $id.getValueType().name(), JsonValue.ValueType.STRING.name()));
+ } else {
+ final String id = ((JsonString)$id).getString();
+ try {
+ scope = locator.resolve(URI.create(id));
+ scope.setSchema(object);
+ } catch(IllegalArgumentException ex) {
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_REFERENCE,
+ new Object[] {id}));
+ }
+ }
+
+ if (types == null) {
+ for (JsonType val : JsonType.values()) {
+ try {
+ final AbstractJsonSchema s = parser.parse(locator, this, getJsonPointer(), object, val);
+ if (s != null) {
+ add(s);
+ }
+ } catch(JsonSchemaException ex) {
+ // do nothing
+ }
+ }
+ } else {
+ for (JsonValue val : types) {
+ if (JsonValue.ValueType.STRING != val.getValueType()) {
+
+ }
+ try {
+ final JsonType t = JsonType.fromValue(((JsonString)val).getString());
+ add(parser.parse(locator, parent, getJsonPointer(), object, t));
+ } catch(IllegalArgumentException ex) {
+ throw new JsonSchemaException(
+ new ParsingError(ParsingMessage.UNKNOWN_OBJECT_TYPE, val));
+ }
+ }
+ }
+
+ return this;
+ }
+}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNumberSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNumberSchemaImpl.java
index aac4ec3..b134bd9 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNumberSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNumberSchemaImpl.java
@@ -94,7 +94,7 @@ public boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
return nerrors == errors.size();
}
-
+
private void validate(String jsonPointer, BigDecimal dec, List errors) {
if (minimum != null) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonObjectSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonObjectSchemaImpl.java
index de42963..fc09a43 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonObjectSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonObjectSchemaImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -41,7 +41,6 @@
import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import es.elixir.bsc.json.schema.model.JsonDependentProperties;
-import es.elixir.bsc.json.schema.model.JsonSchema;
import es.elixir.bsc.json.schema.model.JsonSchemaElement;
import javax.json.Json;
import javax.json.JsonArray;
@@ -55,9 +54,6 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;
import javax.json.JsonNumber;
-import static javax.json.JsonValue.ValueType.FALSE;
-import static javax.json.JsonValue.ValueType.OBJECT;
-import static javax.json.JsonValue.ValueType.TRUE;
/**
* @author Dmitry Repchevsky
@@ -173,44 +169,6 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
final JsonType type) throws JsonSchemaException {
super.read(parser, object, type);
-
- JsonValue jdefs = object.get(JsonSchema.DEFS);
- if (jdefs != null) {
- if (JsonValue.ValueType.OBJECT != jdefs.getValueType()) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {JsonSchema.DEFS, jdefs.getValueType().name(), JsonValue.ValueType.OBJECT.name()}));
- }
- for (Map.Entry entry : jdefs.asJsonObject().entrySet()) {
- final JsonValue subschema = entry.getValue();
- switch(subschema.getValueType()) {
- case OBJECT:
- case TRUE:
- case FALSE: parser.parse(getScope(), parent, getJsonPointer() + "/" + JsonSchema.DEFS + "/" + entry.getKey(), subschema, null);
- break;
- default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {entry.getKey(), subschema.getValueType().name(), JsonValue.ValueType.OBJECT.name()}));
- }
- }
- }
-
- JsonValue jdefinitions = object.get("definitions");
- if (jdefinitions != null) {
- if (JsonValue.ValueType.OBJECT != jdefinitions.getValueType()) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {"definitions", jdefinitions.getValueType().name(), JsonValue.ValueType.OBJECT.name()}));
- }
- for (Map.Entry entry : jdefinitions.asJsonObject().entrySet()) {
- final JsonValue subschema = entry.getValue();
- switch(subschema.getValueType()) {
- case OBJECT:
- case TRUE:
- case FALSE: parser.parse(getScope(), this, getJsonPointer() + "/definitions/" + entry.getKey(), subschema, null);
- break;
- default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {entry.getKey(), subschema.getValueType().name(), JsonValue.ValueType.OBJECT.name()}));
- }
- }
- }
final JsonObject jproperties = JsonSchemaUtil.check(object.get(PROPERTIES), ValueType.OBJECT);
if (jproperties != null) {
@@ -246,7 +204,7 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
case TRUE: additionalProperties = true; break;
case FALSE: additionalProperties = false; break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {ADDITIONAL_PROPERTIES, jadditionalProperties.getValueType().name(), "either object or boolean"}));
+ ADDITIONAL_PROPERTIES, jadditionalProperties.getValueType().name(), "either object or boolean"));
}
}
@@ -257,7 +215,7 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
case TRUE: unevaluatedProperties = true; break;
case FALSE: unevaluatedProperties = false; break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {UNEVALUATED_PROPERTIES, junevaluatedProperties.getValueType().name(), "either object or boolean"}));
+ UNEVALUATED_PROPERTIES, junevaluatedProperties.getValueType().name(), "either object or boolean"));
}
}
@@ -270,7 +228,7 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
case FALSE: propertyNames = new BooleanJsonSchemaImpl(this, getScope(), getJsonPointer() + "/" + PROPERTY_NAMES).read(parser, jpropertyNames, null);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {PROPERTY_NAMES, jpropertyNames.getValueType().name(), "either object or boolean"}));
+ PROPERTY_NAMES, jpropertyNames.getValueType().name(), "either object or boolean"));
}
}
@@ -302,8 +260,8 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
getDependentRequired().put(name, arr);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_OBJECT_TYPE,
- new Object[] {name + " dependentRequired schema ",
- value.getValueType().name(), JsonValue.ValueType.OBJECT.name() + " or " + JsonValue.ValueType.ARRAY.name()}));
+ name + " dependentRequired schema ", value.getValueType().name(),
+ JsonValue.ValueType.OBJECT.name() + " or " + JsonValue.ValueType.ARRAY.name()));
}
}
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonOneOfImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonOneOfImpl.java
index f2d88f7..5d43c19 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonOneOfImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonOneOfImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -42,7 +42,7 @@
* @author Dmitry Repchevsky
*/
-public class JsonOneOfImpl extends SchemaArrayImpl
+public class JsonOneOfImpl extends SchemaArrayImpl
implements JsonOneOf {
public JsonOneOfImpl(AbstractJsonSchema parent, JsonSchemaLocator locator,
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonRecursiveReferenceImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonRecursiveReferenceImpl.java
index 55db172..e26e1fe 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonRecursiveReferenceImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonRecursiveReferenceImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -33,11 +33,11 @@
import es.elixir.bsc.json.schema.model.JsonRecursiveReference;
import es.elixir.bsc.json.schema.model.JsonSchemaElement;
import es.elixir.bsc.json.schema.model.JsonType;
-import es.elixir.bsc.json.schema.model.PrimitiveSchema;
import java.util.stream.Stream;
import javax.json.JsonObject;
import javax.json.JsonString;
import javax.json.JsonValue;
+import java.io.IOException;
/**
* @author Dmitry Repchevsky
@@ -45,8 +45,6 @@
public class JsonRecursiveReferenceImpl extends AbstractJsonReferenceImpl
implements JsonRecursiveReference {
-
- private JsonSchemaElement schema;
public JsonRecursiveReferenceImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
String jsonPointer) {
@@ -61,32 +59,37 @@ public Stream getChildren() {
@Override
public JsonSchemaElement getSchema() throws JsonSchemaException {
if (schema == null) {
- AbstractJsonSchemaElement s = this;
- while ((s = s.getParent()) != null) {
- if ("/".equals(s.getJsonPointer()) && s instanceof PrimitiveSchema) {
- final boolean isRecursiveAnchor = ((PrimitiveSchema)s).isRecursiveAnchor();
+ AbstractJsonSchemaElement e = this;
+ try {
+ while ((e = e.getParent()) != null) {
+ if ("/".equals(e.getJsonPointer())) {
+ final JsonSchemaLocator scope = e.getScope();
+ final JsonValue value = scope.getSchema("/");
+ if (value instanceof JsonObject jsubschema) {
+ final boolean anchor = jsubschema.getBoolean(RECURSIVE_ANCHOR, false);
- // no 'type' or 'type': [] leads to AnyOf[] surrogate wrapper.
- // because we are in a 'root' parent either has different location
- // or be the wrapper.
- if (s.parent != null && s.locator == s.parent.locator) {
- s = s.parent;
- }
+ // no 'type' or 'type': [] leads to JsonMultitypeSchemaWrapper wrapper.
+ // because we are in a 'root' parent either has different location
+ // or be the wrapper.
+ if (e.parent instanceof JsonMultitypeSchemaWrapper) {
+ e = e.parent;
+ }
- if (isRecursiveAnchor) {
- schema = s;
- continue;
- } else if (schema == null) {
- schema = s;
+ if (anchor) {
+ schema = e;
+ continue;
+ } else if (schema == null) {
+ schema = e;
+ }
+ break;
+ }
}
- break;
}
- }
+ } catch (IOException ex) {}
}
return schema;
}
-
@Override
public JsonRecursiveReferenceImpl read(final JsonSubschemaParser parser,
final JsonObject object,
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonReferenceImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonReferenceImpl.java
index 060bb86..f1a550f 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonReferenceImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonReferenceImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,8 +34,6 @@
import es.elixir.bsc.json.schema.model.JsonSchemaElement;
import es.elixir.bsc.json.schema.model.JsonType;
import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
import java.util.stream.Stream;
import javax.json.JsonException;
import javax.json.JsonObject;
@@ -46,13 +44,6 @@
*/
public class JsonReferenceImpl extends AbstractJsonReferenceImpl implements JsonReference {
-
- private JsonSchemaElement schema;
-
- private String ref;
- private String ref_pointer;
- private JsonSchemaLocator ref_locator;
- private JsonSubschemaParser parser;
public JsonReferenceImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
String jsonPointer) {
@@ -103,38 +94,8 @@ public JsonSchemaElement getSchema() throws JsonSchemaException {
public JsonReferenceImpl read(final JsonSubschemaParser parser,
final JsonObject object,
final JsonType type) throws JsonSchemaException {
-
- super.read(parser, object, type);
-
- this.parser = parser;
-
- ref = object.getString(REF);
- try {
- final URI uri = URI.create(ref);
- final String fragment = uri.getFragment();
- if (fragment == null) {
- ref_pointer = "/";
- ref_locator = getScope().resolve(uri);
- } else if ("#".equals(ref)) {
- ref_pointer = "/";
- ref_locator = getScope();
- } else if (fragment.startsWith("/")) {
- ref_pointer = fragment;
- if (ref.startsWith("#")) {
- ref_locator = getScope();
- } else {
- ref_locator = getScope().resolve(
- new URI(uri.getScheme(), uri.getSchemeSpecificPart(), null));
- }
- } else {
- ref_pointer = "/";
- ref_locator = getScope().resolve(uri);
- }
- } catch(JsonException | IllegalArgumentException | URISyntaxException ex) {
- throw new JsonSchemaException(
- new ParsingError(ParsingMessage.INVALID_REFERENCE, ref));
- }
+ super.read(parser, object, type, REF);
return this;
}
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonSchemaUtil.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonSchemaUtil.java
index 2bbdde8..ce9558d 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonSchemaUtil.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonSchemaUtil.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -49,7 +49,7 @@ static U check(JsonValue value, JsonValue.ValueType type)
static U require(JsonValue value, JsonValue.ValueType type) throws JsonSchemaException {
if (value.getValueType() != type) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {"type", value.getValueType().name(), "either a string or an array"}));
+ "type", value.getValueType().name(), "either a string or an array"));
}
return (U)value;
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonStringSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonStringSchemaImpl.java
index 48796ad..4b4ec8a 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonStringSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonStringSchemaImpl.java
@@ -153,7 +153,7 @@ public boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
return nerrors == errors.size();
}
-
+
private void validate(String jsonPointer, String string, List errors) {
if (minLength != null && string.codePointCount(0, string.length()) < minLength) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/NumericSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/NumericSchemaImpl.java
index 688b1c3..82a6398 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/NumericSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/NumericSchemaImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -32,7 +32,6 @@
import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.model.NumericSchema;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
-import es.elixir.bsc.json.schema.model.JsonSchemaElement;
import java.math.BigDecimal;
import javax.json.JsonNumber;
import javax.json.JsonObject;
@@ -151,7 +150,7 @@ public NumericSchemaImpl read(final JsonSubschemaParser parser,
case TRUE: isExclusiveMinimum = true;
case FALSE: break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {EXCLUSIVE_MINIMUM, jexclusiveMinimum.getValueType().name(), "either number or boolean (draft4)"}));
+ EXCLUSIVE_MINIMUM, jexclusiveMinimum.getValueType().name(), "either number or boolean (draft4)"));
}
}
@@ -163,7 +162,7 @@ public NumericSchemaImpl read(final JsonSubschemaParser parser,
case TRUE: isExclusiveMaximum = true;
case FALSE: break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {EXCLUSIVE_MAXIMUM, jexclusiveMaximum.getValueType().name(), "either number or boolean (draft4)"}));
+ EXCLUSIVE_MAXIMUM, jexclusiveMaximum.getValueType().name(), "either number or boolean (draft4)"));
}
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/PrimitiveSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/PrimitiveSchemaImpl.java
index c83ab9a..cd2df03 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/PrimitiveSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/PrimitiveSchemaImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -35,6 +35,7 @@
import es.elixir.bsc.json.schema.ValidationException;
import java.util.List;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
+import es.elixir.bsc.json.schema.model.JsonDynamicReference;
import es.elixir.bsc.json.schema.model.JsonRecursiveReference;
import es.elixir.bsc.json.schema.model.JsonReference;
import es.elixir.bsc.json.schema.model.JsonSchema;
@@ -48,6 +49,7 @@
import javax.json.JsonObject;
import javax.json.JsonString;
import javax.json.JsonValue;
+import java.util.Map;
/**
* Primitive empty Json Schema of any type ("object", "array", "string", etc.)
@@ -79,8 +81,6 @@ public class PrimitiveSchemaImpl extends AbstractJsonSchema
*/
private AbstractJsonReferenceImpl ref;
- private boolean recursiveAnchor;
-
public PrimitiveSchemaImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator,
String jsonPointer) {
super(parent, locator, jsonPointer);
@@ -160,11 +160,6 @@ public JsonReference getReference() {
return ref;
}
- @Override
- public boolean isRecursiveAnchor() {
- return recursiveAnchor;
- }
-
@Override
public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
final JsonObject object,
@@ -179,15 +174,14 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
scope = locator;
} else if ($id.getValueType() != JsonValue.ValueType.STRING) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {"id", $id.getValueType().name(), JsonValue.ValueType.STRING.name()}));
+ "id", $id.getValueType().name(), JsonValue.ValueType.STRING.name()));
} else {
final String id = ((JsonString)$id).getString();
try {
scope = locator.resolve(URI.create(id));
scope.setSchema(object);
} catch(IllegalArgumentException ex) {
- throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_REFERENCE,
- new Object[] {id}));
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_REFERENCE, id));
}
}
@@ -201,19 +195,53 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
setDescription(jdescription.getString());
}
- final JsonString $anchor = JsonSchemaUtil.check(object.get(JsonSchema.ANCHOR), JsonValue.ValueType.STRING);
- if ($anchor != null) {
- final String anchor = $anchor.getString();
+ final JsonString janchor = JsonSchemaUtil.check(object.get(JsonSchema.ANCHOR), JsonValue.ValueType.STRING);
+ if (janchor != null) {
+ final String anchor = janchor.getString();
scope.resolve(URI.create("#" + anchor)).setSchema(object);
}
-
- final JsonValue jrecursiveAnchor = object.get(RECURSIVE_ANCHOR);
- if (jrecursiveAnchor != null) {
- switch(jrecursiveAnchor.getValueType()) {
- case TRUE: recursiveAnchor = true;
- case FALSE: break;
- default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {RECURSIVE_ANCHOR, jrecursiveAnchor.getValueType().name(), "only boolean is allowed"}));
+
+ final JsonString jdynamicanchor = JsonSchemaUtil.check(object.get(JsonSchema.DYNAMIC_ANCHOR), JsonValue.ValueType.STRING);
+ if (jdynamicanchor != null) {
+ final String anchor = jdynamicanchor.getString();
+ scope.resolve(URI.create("#" + anchor)).setSchema(object);
+ }
+
+ JsonValue jdefs = object.get(JsonSchema.DEFS);
+ if (jdefs != null) {
+ if (JsonValue.ValueType.OBJECT != jdefs.getValueType()) {
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ JsonSchema.DEFS, jdefs.getValueType().name(), JsonValue.ValueType.OBJECT.name()));
+ }
+ for (Map.Entry entry : jdefs.asJsonObject().entrySet()) {
+ final JsonValue subschema = entry.getValue();
+ switch(subschema.getValueType()) {
+ case OBJECT:
+ case TRUE:
+ case FALSE: parser.parse(getScope(), parent, getJsonPointer() + "/" + JsonSchema.DEFS + "/" + entry.getKey(), subschema, null);
+ break;
+ default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ entry.getKey(), subschema.getValueType().name(), JsonValue.ValueType.OBJECT.name()));
+ }
+ }
+ }
+
+ JsonValue jdefinitions = object.get("definitions");
+ if (jdefinitions != null) {
+ if (JsonValue.ValueType.OBJECT != jdefinitions.getValueType()) {
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ "definitions", jdefinitions.getValueType().name(), JsonValue.ValueType.OBJECT.name()));
+ }
+ for (Map.Entry entry : jdefinitions.asJsonObject().entrySet()) {
+ final JsonValue subschema = entry.getValue();
+ switch(subschema.getValueType()) {
+ case OBJECT:
+ case TRUE:
+ case FALSE: parser.parse(getScope(), this, getJsonPointer() + "/definitions/" + entry.getKey(), subschema, null);
+ break;
+ default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ entry.getKey(), subschema.getValueType().name(), JsonValue.ValueType.OBJECT.name()));
+ }
}
}
@@ -251,7 +279,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
.read(parser, jnot, null);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {NOT, jnot.getValueType().name(), "either object or boolean"}));
+ NOT, jnot.getValueType().name(), "either object or boolean"));
}
}
@@ -264,7 +292,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case FALSE: _if = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jif, null);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {IF, jif.getValueType().name(), "either object or boolean"}));
+ IF, jif.getValueType().name(), "either object or boolean"));
}
}
@@ -277,7 +305,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case FALSE: _else = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jelse, null);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {ELSE, jelse.getValueType().name(), "either object or boolean"}));
+ ELSE, jelse.getValueType().name(), "either object or boolean"));
}
}
@@ -290,7 +318,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case FALSE: _then = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jthen, null);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {THEN, jthen.getValueType().name(), "either object or boolean"}));
+ THEN, jthen.getValueType().name(), "either object or boolean"));
}
}
@@ -299,24 +327,38 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
parser.getJsonSchemaVersion(object)) <= 0) {
if (JsonValue.ValueType.STRING != jref.getValueType()) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {JsonReference.REF, jref.getValueType().name(), JsonValue.ValueType.STRING.name()}));
+ JsonReference.REF, jref.getValueType().name(), JsonValue.ValueType.STRING.name()));
}
ref = new JsonReferenceImpl(this, scope, getJsonPointer()).read(parser, object, null);
}
+ final JsonValue jdynamic_ref = object.get(JsonDynamicReference.DYNAMIC_REF);
+ if (jdynamic_ref != null) {
+ if (JsonValue.ValueType.STRING != jdynamic_ref.getValueType()) {
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
+ JsonDynamicReference.DYNAMIC_REF, jdynamic_ref.getValueType().name(),
+ JsonValue.ValueType.STRING.name()));
+ }
+
+ if (jref != null) {
+ throw new JsonSchemaException(new ParsingError(ParsingMessage.INCOMPATIBLE_KEYWORDS,
+ String.join(",", List.of(JsonRecursiveReference.REF, JsonDynamicReference.DYNAMIC_REF))));
+ }
+ ref = new JsonDynamicReferenceImpl(this, scope, getJsonPointer()).read(parser, object, null);
+ }
+
final JsonValue jrecursive_ref = object.get(JsonRecursiveReference.RECURSIVE_REF);
if (jrecursive_ref != null) {
if (JsonValue.ValueType.STRING != jrecursive_ref.getValueType()) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
- new Object[] {JsonRecursiveReference.RECURSIVE_REF, jrecursive_ref.getValueType().name(),
- JsonValue.ValueType.STRING.name()}));
+ JsonRecursiveReference.RECURSIVE_REF, jrecursive_ref.getValueType().name(),
+ JsonValue.ValueType.STRING.name()));
}
if (jref != null) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INCOMPATIBLE_KEYWORDS,
- new Object[] {String.join(",",
- List.of(JsonRecursiveReference.REF, JsonRecursiveReference.RECURSIVE_REF))}));
+ String.join(",", List.of(JsonRecursiveReference.REF, JsonRecursiveReference.RECURSIVE_REF))));
}
ref = new JsonRecursiveReferenceImpl(this, scope, getJsonPointer()).read(parser, object, null);
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/SchemaArrayImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/SchemaArrayImpl.java
index aa55d16..39d9467 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/SchemaArrayImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/SchemaArrayImpl.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -40,9 +40,12 @@
/**
* @author Dmitry Repchevsky
+ *
+ * @param
*/
-public abstract class SchemaArrayImpl extends AbstractJsonSchema
+public abstract class SchemaArrayImpl
+ extends AbstractJsonSchema
implements SchemaArray {
private final Set schemas;
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAdditionalPropertiesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAdditionalPropertiesTest.java
index e145c16..a817480 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAdditionalPropertiesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAdditionalPropertiesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -25,6 +25,7 @@
package es.elixir.bsc.json.schema.org.tests;
+import es.elixir.bsc.json.schema.JsonSchemaVersion;
import org.junit.Test;
/**
@@ -37,6 +38,7 @@ public class JsonSchemaAdditionalPropertiesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/additionalProperties.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/additionalProperties.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/additionalProperties.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/additionalProperties.json";
@Test
public void test_draft4() {
@@ -57,4 +59,9 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE, JsonSchemaVersion.SCHEMA_DRAFT_2020_12);
+ }
}
\ No newline at end of file
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAllOfTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAllOfTest.java
index 8bc2501..fa73b57 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAllOfTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAllOfTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -37,6 +37,7 @@ public class JsonSchemaAllOfTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/allOf.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/allOf.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/allOf.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/allOf.json";
@Test
public void test_draft4() {
@@ -57,4 +58,9 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnchorTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnchorTest.java
index ae5ab29..f12e198 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnchorTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnchorTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,15 @@
public class JsonSchemaAnchorTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/anchor.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/anchor.json";
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
\ No newline at end of file
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnyOfTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnyOfTest.java
index 7ab1819..8c3f0ad 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnyOfTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaAnyOfTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -37,6 +37,7 @@ public class JsonSchemaAnyOfTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/anyOf.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/anyOf.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/anyOf.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/anyOf.json";
@Test
public void test_draft4() {
@@ -57,4 +58,10 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
+
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaBooleanSchemaTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaBooleanSchemaTest.java
index 7f64462..730818a 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaBooleanSchemaTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaBooleanSchemaTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,7 @@ public class JsonSchemaBooleanSchemaTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/boolean_schema.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/boolean_schema.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/boolean_schema.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/boolean_schema.json";
@Test
public void test_draft6() {
@@ -51,4 +52,9 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaConstTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaConstTest.java
index 417c8c5..ee5be48 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaConstTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaConstTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,7 @@ public class JsonSchemaConstTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/const.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/const.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/const.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/const.json";
@Test
public void test_draft6() {
@@ -51,4 +52,10 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
+
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaContainsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaContainsTest.java
index c63bfef..c39c182 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaContainsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaContainsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,7 @@ public class JsonSchemaContainsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/contains.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/contains.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/contains.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/contains.json";
@Test
public void test_draft6() {
@@ -51,4 +52,10 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
+
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefaultTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefaultTest.java
index 3205ff9..b491d90 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefaultTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefaultTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -37,6 +37,7 @@ public class JsonSchemaDefaultTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/default.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/default.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/default.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/default.json";
@Test
public void test_draft4() {
@@ -57,4 +58,9 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefsTest.java
index 48ead39..c00364d 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDefsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,15 @@
public class JsonSchemaDefsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/defs.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/defs.json";
@Test
public void test_draft201909() {
- //test(JSON_DRAFT201909_TEST_FILE);
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
}
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentRequiredTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentRequiredTest.java
index af3fc04..8d39794 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentRequiredTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentRequiredTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,10 +34,15 @@
public class JsonSchemaDependentRequiredTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/dependentRequired.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/dependentRequired.json";
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentSchemasTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentSchemasTest.java
index 7b8568a..70354db 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentSchemasTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDependentSchemasTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,10 +34,15 @@
public class JsonSchemaDependentSchemasTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/dependentSchemas.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/dependentSchemas.json";
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDynamicRefTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDynamicRefTest.java
new file mode 100644
index 0000000..9fec99d
--- /dev/null
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaDynamicRefTest.java
@@ -0,0 +1,43 @@
+/**
+ * *****************************************************************************
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * and Barcelona Supercomputing Center (BSC)
+ *
+ * Modifications to the initial code base are copyright of their respective
+ * authors, or their employers as appropriate.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ *****************************************************************************
+ */
+
+package es.elixir.bsc.json.schema.org.tests;
+
+import es.elixir.bsc.json.schema.JsonSchemaVersion;
+import org.junit.Test;
+
+/**
+ * @author Dmitry Repchevsky
+ */
+
+public class JsonSchemaDynamicRefTest extends JsonSchemaOrgTest {
+
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/dynamicRef.json";
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE, JsonSchemaVersion.SCHEMA_DRAFT_2020_12);
+ }
+}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaEnumTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaEnumTest.java
index 23c2b7f..febca45 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaEnumTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaEnumTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,8 @@ public class JsonSchemaEnumTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/enum.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/enum.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/enum.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/enum.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/enum.json";
@Test
public void test_draft4() {
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMaximumTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMaximumTest.java
index d199c7d..d708ff4 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMaximumTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMaximumTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -35,6 +35,8 @@ public class JsonSchemaExclusiveMaximumTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/exclusiveMaximum.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/exclusiveMaximum.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/exclusiveMaximum.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/exclusiveMaximum.json";
@Test
public void test_draft6() {
@@ -45,4 +47,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMinimumTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMinimumTest.java
index 04e7323..ecd586a 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMinimumTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaExclusiveMinimumTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -35,6 +35,8 @@ public class JsonSchemaExclusiveMinimumTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/exclusiveMinimum.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/exclusiveMinimum.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/exclusiveMinimum.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/exclusiveMinimum.json";
@Test
public void test_draft6() {
@@ -45,4 +47,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaFormatTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaFormatTest.java
index 16bdfd1..9de73f6 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaFormatTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaFormatTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,8 @@ public class JsonSchemaFormatTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/format.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/format.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/format.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/format.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/format.json";
@Test
public void test_draft4() {
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+// @Test
+// public void test_draft202012() {
+// test(JSON_DRAFT202012_TEST_FILE);
+// }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIdTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIdTest.java
index 7d69949..b7342e8 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIdTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIdTest.java
@@ -36,7 +36,9 @@ public class JsonSchemaIdTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/id.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/id.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/id.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/id.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/id.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+// @Test
+// public void test_draft202012() {
+// test(JSON_DRAFT202012_TEST_FILE);
+// }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIfThenElseTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIfThenElseTest.java
index 4ac5698..055e5fd 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIfThenElseTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaIfThenElseTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,21 @@
public class JsonSchemaIfThenElseTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/if-then-else.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/if-then-else.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/if-then-else.json";
@Test
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaInfiniteLoopDetectionTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaInfiniteLoopDetectionTest.java
index 5557855..3bfa30c 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaInfiniteLoopDetectionTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaInfiniteLoopDetectionTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaInfiniteLoopDetectionTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/infinite-loop-detection.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/infinite-loop-detection.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/infinite-loop-detection.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/infinite-loop-detection.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/infinite-loop-detection.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaItemsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaItemsTest.java
index 5c44957..0b478b3 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaItemsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaItemsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaItemsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/items.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/items.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/items.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/items.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/items.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+// @Test
+// public void test_draft202012() {
+// test(JSON_DRAFT202012_TEST_FILE);
+// }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxContainsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxContainsTest.java
index d3fd53a..6e3b820 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxContainsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxContainsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,15 @@
public class JsonSchemaMaxContainsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/maxContains.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/maxContains.json";
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxItemsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxItemsTest.java
index 3b4024e..b12668a 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxItemsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxItemsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,8 @@ public class JsonSchemaMaxItemsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/maxItems.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/maxItems.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/maxItems.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/maxItems.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/maxItems.json";
@Test
public void test_draft4() {
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxLengthTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxLengthTest.java
index 5a19c52..19b0eec 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxLengthTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxLengthTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaMaxLengthTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/maxLength.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/maxLength.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/maxLength.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/maxLength.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/maxLength.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxPropertiesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxPropertiesTest.java
index d8bb60c..8d02e35 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxPropertiesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaxPropertiesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,8 @@ public class JsonSchemaMaxPropertiesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/maxProperties.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/maxProperties.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/maxProperties.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/maxProperties.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/maxProperties.json";
@Test
public void test_draft4() {
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaximumTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaximumTest.java
index a8eb1b5..47d6b65 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaximumTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMaximumTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,8 @@ public class JsonSchemaMaximumTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/maximum.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/maximum.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/maximum.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/maximum.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/maximum.json";
@Test
public void test_draft4() {
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinContainsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinContainsTest.java
index 1179ba7..5ee2cf0 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinContainsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinContainsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,15 @@
public class JsonSchemaMinContainsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/minContains.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/minContains.json";
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinItemsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinItemsTest.java
index 1a2cd4d..717a48b 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinItemsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinItemsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,8 @@ public class JsonSchemaMinItemsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/minItems.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/minItems.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/minItems.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/minItems.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/minItems.json";
@Test
public void test_draft4() {
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinLengthTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinLengthTest.java
index a545f88..0974fd3 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinLengthTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinLengthTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaMinLengthTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/minLength.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/minLength.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/minLength.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/minLength.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/minLength.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinPropertiesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinPropertiesTest.java
index 6cb8b92..4fcbc5f 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinPropertiesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinPropertiesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaMinPropertiesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/minProperties.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/minProperties.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/minProperties.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/minProperties.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/minProperties.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinimumTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinimumTest.java
index bed21cb..3975836 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinimumTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMinimumTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaMinimumTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/minimum.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/minimum.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/minimum.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/minimum.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/minimum.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMultipleOfTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMultipleOfTest.java
index d8fd943..6c5bd04 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMultipleOfTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaMultipleOfTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaMultipleOfTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/multipleOf.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/multipleOf.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/multipleOf.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/multipleOf.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/multipleOf.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaNotTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaNotTest.java
index bbcdc02..9cb3f10 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaNotTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaNotTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaNotTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/not.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/not.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/not.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/not.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/not.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOneOfTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOneOfTest.java
index a6b7d03..5aef115 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOneOfTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOneOfTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,6 +36,9 @@ public class JsonSchemaOneOfTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/oneOf.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/oneOf.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/oneOf.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/oneOf.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/oneOf.json";
+
@Test
public void test_draft4() {
@@ -51,4 +54,15 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
+
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOrgTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOrgTest.java
index 0595792..ad6a564 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOrgTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaOrgTest.java
@@ -97,7 +97,8 @@ public void test(String file, JsonSchemaVersion version) {
JsonValue sch = obj.get("schema");
DefaultJsonSchemaLocator locator = new DefaultJsonSchemaLocator(uri.resolve(Integer.toString(j)));
locator.setSchema(sch);
- JsonSchema schema = JsonSchemaReader.getReader(config).read(locator);
+ JsonSchemaReader reader = JsonSchemaReader.getReader(config);
+ JsonSchema schema = reader.read(locator);
JsonArray tests = obj.getJsonArray("tests");
for (int i = 0; i < tests.size(); i++) {
JsonObject test = tests.getJsonObject(i);
@@ -140,7 +141,7 @@ public RemotesServer() {
@Override
public void handle(HttpExchange exchange) throws IOException {
final URI uri = exchange.getRequestURI();
- try (InputStream in = JsonSchemaOrgTest.class.getClassLoader().getResourceAsStream("test/remotes/" + uri.getPath())) {
+ try (InputStream in = JsonSchemaOrgTest.class.getClassLoader().getResourceAsStream("json-schema-org/remotes/" + uri.getPath())) {
if (in != null) {
final byte[] file = in.readAllBytes();
exchange.sendResponseHeaders(200, file.length);
@@ -150,6 +151,8 @@ public void handle(HttpExchange exchange) throws IOException {
}
} catch (IOException ex) {
exchange.sendResponseHeaders(500, 0);
+ } finally {
+ exchange.close();
}
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternPropertiesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternPropertiesTest.java
index 104acc5..7f5d91d 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternPropertiesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternPropertiesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaPatternPropertiesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/patternProperties.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/patternProperties.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/patternProperties.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/patternProperties.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/patternProperties.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternTest.java
index 2777f9c..5a6388d 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPatternTest.java
@@ -36,7 +36,9 @@ public class JsonSchemaPatternTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/pattern.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/pattern.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/pattern.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/pattern.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/pattern.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertiesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertiesTest.java
index 5b08f3e..3802f3a 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertiesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertiesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaPropertiesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/properties.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/properties.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/properties.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/properties.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/properties.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertyNamesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertyNamesTest.java
index 3e0559e..7b802df 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertyNamesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaPropertyNamesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -35,6 +35,9 @@ public class JsonSchemaPropertyNamesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/propertyNames.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/propertyNames.json";
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/propertyNames.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/propertyNames.json";
+
@Test
public void test_draft6() {
@@ -45,4 +48,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRefTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRefTest.java
index 1141322..84b91a8 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRefTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRefTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -38,6 +38,7 @@ public class JsonSchemaRefTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/ref.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/ref.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/ref.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/ref.json";
@Test
public void test_draft4() {
@@ -58,4 +59,9 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE, JsonSchemaVersion.SCHEMA_DRAFT_2019_09);
}
+
+// @Test
+// public void test_draft202012() {
+// test(JSON_DRAFT202012_TEST_FILE, JsonSchemaVersion.SCHEMA_DRAFT_2020_12);
+// }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRequiredTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRequiredTest.java
index 87b2c56..4a30ac2 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRequiredTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaRequiredTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaRequiredTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/required.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/required.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/required.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/required.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/required.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaTypeTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaTypeTest.java
index 30f2647..e6815e8 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaTypeTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaTypeTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -36,7 +36,9 @@ public class JsonSchemaTypeTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT4_TEST_FILE = "json-schema-org/tests/draft4/type.json";
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/type.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/type.json";
-
+ private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/type.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/type.json";
+
@Test
public void test_draft4() {
test(JSON_DRAFT4_TEST_FILE);
@@ -51,4 +53,14 @@ public void test_draft6() {
public void test_draft7() {
test(JSON_DRAFT7_TEST_FILE);
}
+
+ @Test
+ public void test_draft201909() {
+ test(JSON_DRAFT201909_TEST_FILE);
+ }
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedItemsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedItemsTest.java
index 7a99c78..81f79e2 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedItemsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedItemsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,15 @@
public class JsonSchemaUnevaluatedItemsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/unevaluatedItems.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/unevaluatedItems.json";
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+// @Test
+// public void test_draft202012() {
+// test(JSON_DRAFT202012_TEST_FILE);
+// }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedPropertiesTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedPropertiesTest.java
index f13bdb5..68a5879 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedPropertiesTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUnevaluatedPropertiesTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -34,9 +34,16 @@
public class JsonSchemaUnevaluatedPropertiesTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/unevaluatedProperties.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/unevaluatedProperties.json";
+
@Test
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+ @Test
+ public void test_draft202012() {
+ test(JSON_DRAFT202012_TEST_FILE);
+ }
}
diff --git a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUniqueItemsTest.java b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUniqueItemsTest.java
index 3e19a07..5c682e3 100644
--- a/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUniqueItemsTest.java
+++ b/src/test/java/es/elixir/bsc/json/schema/org/tests/JsonSchemaUniqueItemsTest.java
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
- * Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
+ * Copyright (C) 2024 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
@@ -37,6 +37,7 @@ public class JsonSchemaUniqueItemsTest extends JsonSchemaOrgTest {
private final static String JSON_DRAFT6_TEST_FILE = "json-schema-org/tests/draft6/uniqueItems.json";
private final static String JSON_DRAFT7_TEST_FILE = "json-schema-org/tests/draft7/uniqueItems.json";
private final static String JSON_DRAFT201909_TEST_FILE = "json-schema-org/tests/draft2019-09/uniqueItems.json";
+ private final static String JSON_DRAFT202012_TEST_FILE = "json-schema-org/tests/draft2020-12/uniqueItems.json";
@Test
public void test_draft4() {
@@ -57,4 +58,9 @@ public void test_draft7() {
public void test_draft201909() {
test(JSON_DRAFT201909_TEST_FILE);
}
+
+// @Test
+// public void test_draft202012() {
+// test(JSON_DRAFT202012_TEST_FILE);
+// }
}
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/detached-dynamicref.json b/src/test/resources/json-schema-org/remotes/draft-next/detached-dynamicref.json
new file mode 100644
index 0000000..c1a09a5
--- /dev/null
+++ b/src/test/resources/json-schema-org/remotes/draft-next/detached-dynamicref.json
@@ -0,0 +1,13 @@
+{
+ "$id": "http://localhost:1234/draft-next/detached-dynamicref.json",
+ "$schema": "https://json-schema.org/draft/next/schema",
+ "$defs": {
+ "foo": {
+ "$dynamicRef": "#detached"
+ },
+ "detached": {
+ "$dynamicAnchor": "detached",
+ "type": "integer"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/detached-ref.json b/src/test/resources/json-schema-org/remotes/draft-next/detached-ref.json
new file mode 100644
index 0000000..d01aaa1
--- /dev/null
+++ b/src/test/resources/json-schema-org/remotes/draft-next/detached-ref.json
@@ -0,0 +1,13 @@
+{
+ "$id": "http://localhost:1234/draft-next/detached-ref.json",
+ "$schema": "https://json-schema.org/draft/next/schema",
+ "$defs": {
+ "foo": {
+ "$ref": "#detached"
+ },
+ "detached": {
+ "$anchor": "detached",
+ "type": "integer"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-false.json b/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-false.json
index 91c8669..9cbd2a1 100644
--- a/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-false.json
+++ b/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-false.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/next/vocab/core": true,
"https://json-schema.org/draft/next/vocab/format-assertion": false
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/next/meta/core" },
{ "$ref": "https://json-schema.org/draft/next/meta/format-assertion" }
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-true.json b/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-true.json
index a33d143..b3ff69f 100644
--- a/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-true.json
+++ b/src/test/resources/json-schema-org/remotes/draft-next/format-assertion-true.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/next/vocab/core": true,
"https://json-schema.org/draft/next/vocab/format-assertion": true
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/next/meta/core" },
{ "$ref": "https://json-schema.org/draft/next/meta/format-assertion" }
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/metaschema-no-validation.json b/src/test/resources/json-schema-org/remotes/draft-next/metaschema-no-validation.json
index c19c9e8..90e32a6 100644
--- a/src/test/resources/json-schema-org/remotes/draft-next/metaschema-no-validation.json
+++ b/src/test/resources/json-schema-org/remotes/draft-next/metaschema-no-validation.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/next/vocab/applicator": true,
"https://json-schema.org/draft/next/vocab/core": true
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/next/meta/applicator" },
{ "$ref": "https://json-schema.org/draft/next/meta/core" }
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/metaschema-optional-vocabulary.json b/src/test/resources/json-schema-org/remotes/draft-next/metaschema-optional-vocabulary.json
index e78e531..1af0cad 100644
--- a/src/test/resources/json-schema-org/remotes/draft-next/metaschema-optional-vocabulary.json
+++ b/src/test/resources/json-schema-org/remotes/draft-next/metaschema-optional-vocabulary.json
@@ -6,6 +6,7 @@
"https://json-schema.org/draft/next/vocab/core": true,
"http://localhost:1234/draft/next/vocab/custom": false
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/next/meta/validation" },
{ "$ref": "https://json-schema.org/draft/next/meta/core" }
diff --git a/src/test/resources/json-schema-org/remotes/draft-next/subSchemas.json b/src/test/resources/json-schema-org/remotes/draft-next/subSchemas.json
index 575dd00..75b7583 100644
--- a/src/test/resources/json-schema-org/remotes/draft-next/subSchemas.json
+++ b/src/test/resources/json-schema-org/remotes/draft-next/subSchemas.json
@@ -1,9 +1,11 @@
{
"$schema": "https://json-schema.org/draft/next/schema",
- "integer": {
- "type": "integer"
- },
- "refToInteger": {
- "$ref": "#/integer"
+ "$defs": {
+ "integer": {
+ "type": "integer"
+ },
+ "refToInteger": {
+ "$ref": "#/$defs/integer"
+ }
}
}
diff --git a/src/test/resources/json-schema-org/remotes/draft2019-09/detached-ref.json b/src/test/resources/json-schema-org/remotes/draft2019-09/detached-ref.json
index 3bf8260..4a3499f 100644
--- a/src/test/resources/json-schema-org/remotes/draft2019-09/detached-ref.json
+++ b/src/test/resources/json-schema-org/remotes/draft2019-09/detached-ref.json
@@ -1,5 +1,5 @@
{
- "$id": "http://localhost:1234/draft2019-09/detached-ref",
+ "$id": "http://localhost:1234/draft2019-09/detached-ref.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"foo": {
diff --git a/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-no-validation.json b/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-no-validation.json
index 494f0ab..859006c 100644
--- a/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-no-validation.json
+++ b/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-no-validation.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/2019-09/vocab/applicator": true,
"https://json-schema.org/draft/2019-09/vocab/core": true
},
+ "$recursiveAnchor": true,
"allOf": [
{ "$ref": "https://json-schema.org/draft/2019-09/meta/applicator" },
{ "$ref": "https://json-schema.org/draft/2019-09/meta/core" }
diff --git a/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-optional-vocabulary.json b/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-optional-vocabulary.json
index 968597c..3a7502a 100644
--- a/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-optional-vocabulary.json
+++ b/src/test/resources/json-schema-org/remotes/draft2019-09/metaschema-optional-vocabulary.json
@@ -6,6 +6,7 @@
"https://json-schema.org/draft/2019-09/vocab/core": true,
"http://localhost:1234/draft/2019-09/vocab/custom": false
},
+ "$recursiveAnchor": true,
"allOf": [
{ "$ref": "https://json-schema.org/draft/2019-09/meta/validation" },
{ "$ref": "https://json-schema.org/draft/2019-09/meta/core" }
diff --git a/src/test/resources/json-schema-org/remotes/draft2019-09/subSchemas.json b/src/test/resources/json-schema-org/remotes/draft2019-09/subSchemas.json
index 6dea225..fdfee68 100644
--- a/src/test/resources/json-schema-org/remotes/draft2019-09/subSchemas.json
+++ b/src/test/resources/json-schema-org/remotes/draft2019-09/subSchemas.json
@@ -1,9 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
- "integer": {
- "type": "integer"
- },
- "refToInteger": {
- "$ref": "#/integer"
+ "$defs": {
+ "integer": {
+ "type": "integer"
+ },
+ "refToInteger": {
+ "$ref": "#/$defs/integer"
+ }
}
}
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/detached-dynamicref.json b/src/test/resources/json-schema-org/remotes/draft2020-12/detached-dynamicref.json
index 365f869..07cce1d 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/detached-dynamicref.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/detached-dynamicref.json
@@ -1,5 +1,5 @@
{
- "$id": "http://localhost:1234/draft2020-12/detached-dynamicref",
+ "$id": "http://localhost:1234/draft2020-12/detached-dynamicref.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"foo": {
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/detached-ref.json b/src/test/resources/json-schema-org/remotes/draft2020-12/detached-ref.json
index 71aaf43..9c2dca9 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/detached-ref.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/detached-ref.json
@@ -1,5 +1,5 @@
{
- "$id": "http://localhost:1234/draft2020-12/detached-ref",
+ "$id": "http://localhost:1234/draft2020-12/detached-ref.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"foo": {
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-false.json b/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-false.json
index d6dd645..43a711c 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-false.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-false.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/format-assertion": false
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
{ "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" }
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-true.json b/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-true.json
index bb16d58..39c6b0a 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-true.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/format-assertion-true.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/format-assertion": true
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" },
{ "$ref": "https://json-schema.org/draft/2020-12/meta/format-assertion" }
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-no-validation.json b/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-no-validation.json
index 85d74b2..71be8b5 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-no-validation.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-no-validation.json
@@ -5,6 +5,7 @@
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
"https://json-schema.org/draft/2020-12/vocab/core": true
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/meta/applicator" },
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" }
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-optional-vocabulary.json b/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-optional-vocabulary.json
index f38ec28..a6963e5 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-optional-vocabulary.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/metaschema-optional-vocabulary.json
@@ -6,6 +6,7 @@
"https://json-schema.org/draft/2020-12/vocab/core": true,
"http://localhost:1234/draft/2020-12/vocab/custom": false
},
+ "$dynamicAnchor": "meta",
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/meta/validation" },
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" }
diff --git a/src/test/resources/json-schema-org/remotes/draft2020-12/subSchemas.json b/src/test/resources/json-schema-org/remotes/draft2020-12/subSchemas.json
index 5fca21d..1bb4846 100644
--- a/src/test/resources/json-schema-org/remotes/draft2020-12/subSchemas.json
+++ b/src/test/resources/json-schema-org/remotes/draft2020-12/subSchemas.json
@@ -1,9 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
- "integer": {
- "type": "integer"
- },
- "refToInteger": {
- "$ref": "#/integer"
+ "$defs": {
+ "integer": {
+ "type": "integer"
+ },
+ "refToInteger": {
+ "$ref": "#/$defs/integer"
+ }
}
}
diff --git a/src/test/resources/json-schema-org/remotes/draft6/detached-ref.json b/src/test/resources/json-schema-org/remotes/draft6/detached-ref.json
index 0bb7b9c..05ce071 100644
--- a/src/test/resources/json-schema-org/remotes/draft6/detached-ref.json
+++ b/src/test/resources/json-schema-org/remotes/draft6/detached-ref.json
@@ -1,5 +1,5 @@
{
- "$id": "http://localhost:1234/draft6/detached-ref",
+ "$id": "http://localhost:1234/draft6/detached-ref.json",
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"foo": {
diff --git a/src/test/resources/json-schema-org/remotes/draft7/detached-ref.json b/src/test/resources/json-schema-org/remotes/draft7/detached-ref.json
index 0f27eb0..27f2ec8 100644
--- a/src/test/resources/json-schema-org/remotes/draft7/detached-ref.json
+++ b/src/test/resources/json-schema-org/remotes/draft7/detached-ref.json
@@ -1,5 +1,5 @@
{
- "$id": "http://localhost:1234/draft7/detached-ref",
+ "$id": "http://localhost:1234/draft7/detached-ref.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"foo": {
diff --git a/src/test/resources/json-schema-org/remotes/subSchemas.json b/src/test/resources/json-schema-org/remotes/subSchemas.json
index 9f8030b..6e9b3de 100644
--- a/src/test/resources/json-schema-org/remotes/subSchemas.json
+++ b/src/test/resources/json-schema-org/remotes/subSchemas.json
@@ -1,8 +1,10 @@
{
- "integer": {
- "type": "integer"
- },
- "refToInteger": {
- "$ref": "#/integer"
+ "definitions": {
+ "integer": {
+ "type": "integer"
+ },
+ "refToInteger": {
+ "$ref": "#/definitions/integer"
+ }
}
}
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/additionalItems.json b/src/test/resources/json-schema-org/tests/draft2019-09/additionalItems.json
index aa44bcb..9a7ae4f 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/additionalItems.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/additionalItems.json
@@ -182,6 +182,26 @@
}
]
},
+ {
+ "description": "additionalItems with heterogeneous array",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "items": [{}],
+ "additionalItems": false
+ },
+ "tests": [
+ {
+ "description": "heterogeneous invalid instance",
+ "data": [ "foo", "bar", 37 ],
+ "valid": false
+ },
+ {
+ "description": "valid instance",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
{
"description": "additionalItems with null instance elements",
"schema": {
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/anchor.json b/src/test/resources/json-schema-org/tests/draft2019-09/anchor.json
index 5d8c86f..eb0a969 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/anchor.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/anchor.json
@@ -81,64 +81,6 @@
}
]
},
- {
- "description": "$anchor inside an enum is not a real identifier",
- "comment": "the implementation must not be confused by an $anchor buried in the enum",
- "schema": {
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$defs": {
- "anchor_in_enum": {
- "enum": [
- {
- "$anchor": "my_anchor",
- "type": "null"
- }
- ]
- },
- "real_identifier_in_schema": {
- "$anchor": "my_anchor",
- "type": "string"
- },
- "zzz_anchor_in_const": {
- "const": {
- "$anchor": "my_anchor",
- "type": "null"
- }
- }
- },
- "anyOf": [
- { "$ref": "#/$defs/anchor_in_enum" },
- { "$ref": "#my_anchor" }
- ]
- },
- "tests": [
- {
- "description": "exact match to enum, and type matches",
- "data": {
- "$anchor": "my_anchor",
- "type": "null"
- },
- "valid": true
- },
- {
- "description": "in implementations that strip $anchor, this may match either $def",
- "data": {
- "type": "null"
- },
- "valid": false
- },
- {
- "description": "match $ref to $anchor",
- "data": "a string to match #/$defs/anchor_in_enum",
- "valid": true
- },
- {
- "description": "no match on enum or $ref to $anchor",
- "data": 1,
- "valid": false
- }
- ]
- },
{
"description": "same $anchor with different base uri",
"schema": {
@@ -175,38 +117,6 @@
}
]
},
- {
- "description": "non-schema object containing an $anchor property",
- "schema": {
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$defs": {
- "const_not_anchor": {
- "const": {
- "$anchor": "not_a_real_anchor"
- }
- }
- },
- "if": {
- "const": "skip not_a_real_anchor"
- },
- "then": true,
- "else" : {
- "$ref": "#/$defs/const_not_anchor"
- }
- },
- "tests": [
- {
- "description": "skip traversing definition for a valid result",
- "data": "skip not_a_real_anchor",
- "valid": true
- },
- {
- "description": "const at const_not_anchor does not match",
- "data": 1,
- "valid": false
- }
- ]
- },
{
"description": "invalid anchors",
"comment": "Section 8.2.3",
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/dependentSchemas.json b/src/test/resources/json-schema-org/tests/draft2019-09/dependentSchemas.json
index 3577efd..c5b8ea0 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/dependentSchemas.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/dependentSchemas.json
@@ -132,6 +132,7 @@
{
"description": "dependent subschema incompatible with root",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {
"foo": {}
},
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/enum.json b/src/test/resources/json-schema-org/tests/draft2019-09/enum.json
index f9a44a6..1315211 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/enum.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/enum.json
@@ -168,6 +168,30 @@
}
]
},
+ {
+ "description": "enum with [false] does not match [0]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "enum": [[false]]
+ },
+ "tests": [
+ {
+ "description": "[false] is valid",
+ "data": [false],
+ "valid": true
+ },
+ {
+ "description": "[0] is invalid",
+ "data": [0],
+ "valid": false
+ },
+ {
+ "description": "[0.0] is invalid",
+ "data": [0.0],
+ "valid": false
+ }
+ ]
+ },
{
"description": "enum with true does not match 1",
"schema": {
@@ -192,6 +216,30 @@
}
]
},
+ {
+ "description": "enum with [true] does not match [1]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "enum": [[true]]
+ },
+ "tests": [
+ {
+ "description": "[true] is valid",
+ "data": [true],
+ "valid": true
+ },
+ {
+ "description": "[1] is invalid",
+ "data": [1],
+ "valid": false
+ },
+ {
+ "description": "[1.0] is invalid",
+ "data": [1.0],
+ "valid": false
+ }
+ ]
+ },
{
"description": "enum with 0 does not match false",
"schema": {
@@ -216,6 +264,30 @@
}
]
},
+ {
+ "description": "enum with [0] does not match [false]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "enum": [[0]]
+ },
+ "tests": [
+ {
+ "description": "[false] is invalid",
+ "data": [false],
+ "valid": false
+ },
+ {
+ "description": "[0] is valid",
+ "data": [0],
+ "valid": true
+ },
+ {
+ "description": "[0.0] is valid",
+ "data": [0.0],
+ "valid": true
+ }
+ ]
+ },
{
"description": "enum with 1 does not match true",
"schema": {
@@ -240,6 +312,30 @@
}
]
},
+ {
+ "description": "enum with [1] does not match [true]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "enum": [[1]]
+ },
+ "tests": [
+ {
+ "description": "[true] is invalid",
+ "data": [true],
+ "valid": false
+ },
+ {
+ "description": "[1] is valid",
+ "data": [1],
+ "valid": true
+ },
+ {
+ "description": "[1.0] is valid",
+ "data": [1.0],
+ "valid": true
+ }
+ ]
+ },
{
"description": "nul characters in strings",
"schema": {
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/id.json b/src/test/resources/json-schema-org/tests/draft2019-09/id.json
index e2e403f..0ba3138 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/id.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/id.json
@@ -207,88 +207,5 @@
"valid": true
}
]
- },
- {
- "description": "$id inside an enum is not a real identifier",
- "comment": "the implementation must not be confused by an $id buried in the enum",
- "schema": {
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$defs": {
- "id_in_enum": {
- "enum": [
- {
- "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json",
- "type": "null"
- }
- ]
- },
- "real_id_in_schema": {
- "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json",
- "type": "string"
- },
- "zzz_id_in_const": {
- "const": {
- "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json",
- "type": "null"
- }
- }
- },
- "anyOf": [
- { "$ref": "#/$defs/id_in_enum" },
- { "$ref": "https://localhost:1234/draft2019-09/id/my_identifier.json" }
- ]
- },
- "tests": [
- {
- "description": "exact match to enum, and type matches",
- "data": {
- "$id": "https://localhost:1234/draft2019-09/id/my_identifier.json",
- "type": "null"
- },
- "valid": true
- },
- {
- "description": "match $ref to $id",
- "data": "a string to match #/$defs/id_in_enum",
- "valid": true
- },
- {
- "description": "no match on enum or $ref to $id",
- "data": 1,
- "valid": false
- }
- ]
- },
- {
- "description": "non-schema object containing an $id property",
- "schema": {
- "$schema": "https://json-schema.org/draft/2019-09/schema",
- "$defs": {
- "const_not_id": {
- "const": {
- "$id": "not_a_real_id"
- }
- }
- },
- "if": {
- "const": "skip not_a_real_id"
- },
- "then": true,
- "else" : {
- "$ref": "#/$defs/const_not_id"
- }
- },
- "tests": [
- {
- "description": "skip traversing definition for a valid result",
- "data": "skip not_a_real_id",
- "valid": true
- },
- {
- "description": "const at const_not_id does not match",
- "data": 1,
- "valid": false
- }
- ]
}
]
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/minLength.json b/src/test/resources/json-schema-org/tests/draft2019-09/minLength.json
index 19dec2c..1278266 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/minLength.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/minLength.json
@@ -27,7 +27,7 @@
"valid": true
},
{
- "description": "one supplementary Unicode code point is not long enough",
+ "description": "one grapheme is not long enough",
"data": "\uD83D\uDCA9",
"valid": false
}
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/not.json b/src/test/resources/json-schema-org/tests/draft2019-09/not.json
index 62c9af9..d90728c 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/not.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/not.json
@@ -97,25 +97,173 @@
]
},
{
- "description": "not with boolean schema true",
+ "description": "forbid everything with empty schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "not": {}
+ },
+ "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
+ }
+ ]
+ },
+ {
+ "description": "forbid everything with boolean schema true",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"not": true
},
"tests": [
{
- "description": "any value is invalid",
+ "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
}
]
},
{
- "description": "not with boolean schema false",
+ "description": "allow everything with boolean schema false",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"not": false
},
+ "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": "double negation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "not": { "not": {} }
+ },
"tests": [
{
"description": "any value is valid",
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/ref.json b/src/test/resources/json-schema-org/tests/draft2019-09/ref.json
index 7d85041..ea56990 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/ref.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/ref.json
@@ -862,6 +862,7 @@
{
"description": "URN ref with nested pointer ref",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
"$defs": {
"foo": {
@@ -887,6 +888,7 @@
{
"description": "ref to if",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "http://example.com/ref/if",
"if": {
"$id": "http://example.com/ref/if",
@@ -909,6 +911,7 @@
{
"description": "ref to then",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "http://example.com/ref/then",
"then": {
"$id": "http://example.com/ref/then",
@@ -931,6 +934,7 @@
{
"description": "ref to else",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$ref": "http://example.com/ref/else",
"else": {
"$id": "http://example.com/ref/else",
@@ -953,6 +957,7 @@
{
"description": "ref with absolute-path-reference",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://example.com/ref/absref.json",
"$defs": {
"a": {
@@ -982,6 +987,7 @@
{
"description": "$id with file URI still resolves pointers - *nix",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "file:///folder/file.json",
"$defs": {
"foo": {
@@ -1006,6 +1012,7 @@
{
"description": "$id with file URI still resolves pointers - windows",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "file:///c:/folder/file.json",
"$defs": {
"foo": {
@@ -1030,6 +1037,7 @@
{
"description": "empty tokens in $ref json-pointer",
"schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"": {
"$defs": {
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/refRemote.json b/src/test/resources/json-schema-org/tests/draft2019-09/refRemote.json
index 79107f9..072894c 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/refRemote.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/refRemote.json
@@ -22,7 +22,7 @@
"description": "fragment within remote ref",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
- "$ref": "http://localhost:1234/draft2019-09/subSchemas-defs.json#/$defs/integer"
+ "$ref": "http://localhost:1234/draft2019-09/subSchemas.json#/$defs/integer"
},
"tests": [
{
@@ -60,7 +60,7 @@
"description": "ref within remote ref",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
- "$ref": "http://localhost:1234/draft2019-09/subSchemas-defs.json#/$defs/refToInteger"
+ "$ref": "http://localhost:1234/draft2019-09/subSchemas.json#/$defs/refToInteger"
},
"tests": [
{
@@ -265,7 +265,10 @@
},
{
"description": "remote HTTP ref with different $id",
- "schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$ref": "http://localhost:1234/different-id-ref-string.json"
+ },
"tests": [
{
"description": "number is invalid",
@@ -281,7 +284,10 @@
},
{
"description": "remote HTTP ref with different URN $id",
- "schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$ref": "http://localhost:1234/urn-ref-string.json"
+ },
"tests": [
{
"description": "number is invalid",
@@ -297,7 +303,10 @@
},
{
"description": "remote HTTP ref with nested absolute ref",
- "schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"
+ },
"tests": [
{
"description": "number is invalid",
@@ -310,5 +319,24 @@
"valid": true
}
]
+ },
+ {
+ "description": "$ref to $ref finds detached $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$ref": "http://localhost:1234/draft2019-09/detached-ref.json#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
}
]
diff --git a/src/test/resources/json-schema-org/tests/draft2019-09/unevaluatedItems.json b/src/test/resources/json-schema-org/tests/draft2019-09/unevaluatedItems.json
index 53565a0..8e2ee4b 100644
--- a/src/test/resources/json-schema-org/tests/draft2019-09/unevaluatedItems.json
+++ b/src/test/resources/json-schema-org/tests/draft2019-09/unevaluatedItems.json
@@ -480,6 +480,82 @@
}
]
},
+ {
+ "description": "unevaluatedItems before $ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "unevaluatedItems": false,
+ "items": [
+ { "type": "string" }
+ ],
+ "$ref": "#/$defs/bar",
+ "$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 with $recursiveRef",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
+ "$id": "https://example.com/unevaluated-items-with-recursive-ref/extended-tree",
+
+ "$recursiveAnchor": true,
+
+ "$ref": "./tree",
+ "items": [
+ true,
+ true,
+ { "type": "string" }
+ ],
+
+ "$defs": {
+ "tree": {
+ "$id": "./tree",
+ "$recursiveAnchor": true,
+
+ "type": "array",
+ "items": [
+ { "type": "number" },
+ {
+ "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
+ "unevaluatedItems": false,
+ "$recursiveRef": "#"
+ }
+ ]
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "with no unevaluated items",
+ "data": [1, [2, [], "b"], "a"],
+ "valid": true
+ },
+ {
+ "description": "with unevaluated items",
+ "data": [1, [2, [], "b", "too many"], "a"],
+ "valid": false
+ }
+ ]
+ },
{
"description": "unevaluatedItems can't see inside cousins",
"schema": {
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/additionalProperties.json b/src/test/resources/json-schema-org/tests/draft2020-12/additionalProperties.json
new file mode 100644
index 0000000..29e69c1
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/additionalProperties.json
@@ -0,0 +1,156 @@
+[
+ {
+ "description":
+ "additionalProperties being false does not allow other properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 with schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {"foo": {}, "bar": {}}
+ },
+ "tests": [
+ {
+ "description": "additional properties are allowed",
+ "data": {"foo": 1, "bar": 2, "quux": true},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "additionalProperties does not look in applicators",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {"properties": {"foo": {}}}
+ ],
+ "additionalProperties": {"type": "boolean"}
+ },
+ "tests": [
+ {
+ "description": "properties defined in allOf are not examined",
+ "data": {"foo": 1, "bar": true},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "additionalProperties with null valued instance properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "additionalProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null values",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/allOf.json b/src/test/resources/json-schema-org/tests/draft2020-12/allOf.json
new file mode 100644
index 0000000..9e87903
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/allOf.json
@@ -0,0 +1,312 @@
+[
+ {
+ "description": "allOf",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [true, true]
+ },
+ "tests": [
+ {
+ "description": "any value is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "allOf with boolean schemas, some false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [true, false]
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "allOf with boolean schemas, all false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [false, false]
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "allOf with one empty schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {}
+ ]
+ },
+ "tests": [
+ {
+ "description": "any data is valid",
+ "data": 1,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "allOf with two empty schemas",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {},
+ {}
+ ]
+ },
+ "tests": [
+ {
+ "description": "any data is valid",
+ "data": 1,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "allOf with the first empty schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/anchor.json b/src/test/resources/json-schema-org/tests/draft2020-12/anchor.json
new file mode 100644
index 0000000..83a7166
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/anchor.json
@@ -0,0 +1,145 @@
+[
+ {
+ "description": "Location-independent identifier",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/bar#foo",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/root",
+ "$ref": "http://localhost:1234/draft2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "same $anchor with different base uri",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/foobar",
+ "$defs": {
+ "A": {
+ "$id": "child1",
+ "allOf": [
+ {
+ "$id": "child2",
+ "$anchor": "my_anchor",
+ "type": "number"
+ },
+ {
+ "$anchor": "my_anchor",
+ "type": "string"
+ }
+ ]
+ }
+ },
+ "$ref": "child1#my_anchor"
+ },
+ "tests": [
+ {
+ "description": "$ref resolves to /$defs/A/allOf/1",
+ "data": "a",
+ "valid": true
+ },
+ {
+ "description": "$ref does not resolve to /$defs/A/allOf/0",
+ "data": 1,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "invalid anchors",
+ "comment": "Section 8.2.2",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
+ },
+ "tests": [
+ {
+ "description": "MUST start with a letter (and not #)",
+ "data": { "$anchor" : "#foo" },
+ "valid": false
+ },
+ {
+ "description": "JSON pointers are not valid",
+ "data": { "$anchor" : "/a/b" },
+ "valid": false
+ },
+ {
+ "description": "invalid with valid beginning",
+ "data": { "$anchor" : "foo#something" },
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/anyOf.json b/src/test/resources/json-schema-org/tests/draft2020-12/anyOf.json
new file mode 100644
index 0000000..89b192d
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/anyOf.json
@@ -0,0 +1,203 @@
+[
+ {
+ "description": "anyOf",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "anyOf": [true, true]
+ },
+ "tests": [
+ {
+ "description": "any value is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "anyOf with boolean schemas, some true",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "anyOf": [true, false]
+ },
+ "tests": [
+ {
+ "description": "any value is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "anyOf with boolean schemas, all false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "anyOf": [false, false]
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "anyOf complex types",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/boolean_schema.json b/src/test/resources/json-schema-org/tests/draft2020-12/boolean_schema.json
new file mode 100644
index 0000000..6d40f23
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/boolean_schema.json
@@ -0,0 +1,104 @@
+[
+ {
+ "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/json-schema-org/tests/draft2020-12/const.json b/src/test/resources/json-schema-org/tests/draft2020-12/const.json
new file mode 100644
index 0000000..50be86a
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/const.json
@@ -0,0 +1,387 @@
+[
+ {
+ "description": "const validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 [false] does not match [0]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "const": [false]
+ },
+ "tests": [
+ {
+ "description": "[false] is valid",
+ "data": [false],
+ "valid": true
+ },
+ {
+ "description": "[0] is invalid",
+ "data": [0],
+ "valid": false
+ },
+ {
+ "description": "[0.0] is invalid",
+ "data": [0.0],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "const with [true] does not match [1]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "const": [true]
+ },
+ "tests": [
+ {
+ "description": "[true] is valid",
+ "data": [true],
+ "valid": true
+ },
+ {
+ "description": "[1] is invalid",
+ "data": [1],
+ "valid": false
+ },
+ {
+ "description": "[1.0] is invalid",
+ "data": [1.0],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "const with {\"a\": false} does not match {\"a\": 0}",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "const": {"a": false}
+ },
+ "tests": [
+ {
+ "description": "{\"a\": false} is valid",
+ "data": {"a": false},
+ "valid": true
+ },
+ {
+ "description": "{\"a\": 0} is invalid",
+ "data": {"a": 0},
+ "valid": false
+ },
+ {
+ "description": "{\"a\": 0.0} is invalid",
+ "data": {"a": 0.0},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "const with {\"a\": true} does not match {\"a\": 1}",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "const": {"a": true}
+ },
+ "tests": [
+ {
+ "description": "{\"a\": true} is valid",
+ "data": {"a": true},
+ "valid": true
+ },
+ {
+ "description": "{\"a\": 1} is invalid",
+ "data": {"a": 1},
+ "valid": false
+ },
+ {
+ "description": "{\"a\": 1.0} is invalid",
+ "data": {"a": 1.0},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "const with 0 does not match other zero-like types",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/contains.json b/src/test/resources/json-schema-org/tests/draft2020-12/contains.json
new file mode 100644
index 0000000..08a00a7
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/contains.json
@@ -0,0 +1,176 @@
+[
+ {
+ "description": "contains keyword validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "contains with false if subschema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contains": {
+ "if": false,
+ "else": true
+ }
+ },
+ "tests": [
+ {
+ "description": "any non-empty array is valid",
+ "data": ["foo"],
+ "valid": true
+ },
+ {
+ "description": "empty array is invalid",
+ "data": [],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "contains with null instance elements",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contains": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null items",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/content.json b/src/test/resources/json-schema-org/tests/draft2020-12/content.json
new file mode 100644
index 0000000..698f780
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/content.json
@@ -0,0 +1,131 @@
+[
+ {
+ "description": "validation of string-encoded content based on media type",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contentMediaType": "application/json"
+ },
+ "tests": [
+ {
+ "description": "a valid JSON document",
+ "data": "{\"foo\": \"bar\"}",
+ "valid": true
+ },
+ {
+ "description": "an invalid JSON document; validates true",
+ "data": "{:}",
+ "valid": true
+ },
+ {
+ "description": "ignores non-strings",
+ "data": 100,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "validation of binary string-encoding",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contentEncoding": "base64"
+ },
+ "tests": [
+ {
+ "description": "a valid base64 string",
+ "data": "eyJmb28iOiAiYmFyIn0K",
+ "valid": true
+ },
+ {
+ "description": "an invalid base64 string (% is not a valid character); validates true",
+ "data": "eyJmb28iOi%iYmFyIn0K",
+ "valid": true
+ },
+ {
+ "description": "ignores non-strings",
+ "data": 100,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "validation of binary-encoded media type documents",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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; validates true",
+ "data": "ezp9Cg==",
+ "valid": true
+ },
+ {
+ "description": "an invalid base64 string that is valid JSON; validates true",
+ "data": "{}",
+ "valid": true
+ },
+ {
+ "description": "ignores non-strings",
+ "data": 100,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "validation of binary-encoded media type documents with schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contentMediaType": "application/json",
+ "contentEncoding": "base64",
+ "contentSchema": { "type": "object", "required": ["foo"], "properties": { "foo": { "type": "string" } } }
+ },
+ "tests": [
+ {
+ "description": "a valid base64-encoded JSON document",
+ "data": "eyJmb28iOiAiYmFyIn0K",
+ "valid": true
+ },
+ {
+ "description": "another valid base64-encoded JSON document",
+ "data": "eyJib28iOiAyMCwgImZvbyI6ICJiYXoifQ==",
+ "valid": true
+ },
+ {
+ "description": "an invalid base64-encoded JSON document; validates true",
+ "data": "eyJib28iOiAyMH0=",
+ "valid": true
+ },
+ {
+ "description": "an empty object as a base64-encoded JSON document; validates true",
+ "data": "e30=",
+ "valid": true
+ },
+ {
+ "description": "an empty array as a base64-encoded JSON document",
+ "data": "W10=",
+ "valid": true
+ },
+ {
+ "description": "a validly-encoded invalid JSON document; validates true",
+ "data": "ezp9Cg==",
+ "valid": true
+ },
+ {
+ "description": "an invalid base64 string that is valid JSON; validates true",
+ "data": "{}",
+ "valid": true
+ },
+ {
+ "description": "ignores non-strings",
+ "data": 100,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/default.json b/src/test/resources/json-schema-org/tests/draft2020-12/default.json
new file mode 100644
index 0000000..ceb3ae2
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/default.json
@@ -0,0 +1,82 @@
+[
+ {
+ "description": "invalid type for default",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "the default keyword does not do anything if the property is missing",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "properties": {
+ "alpha": {
+ "type": "number",
+ "maximum": 3,
+ "default": 5
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "an explicit property value is checked against maximum (passing)",
+ "data": { "alpha": 1 },
+ "valid": true
+ },
+ {
+ "description": "an explicit property value is checked against maximum (failing)",
+ "data": { "alpha": 5 },
+ "valid": false
+ },
+ {
+ "description": "missing properties are not filled in with the default",
+ "data": {},
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/defs.json b/src/test/resources/json-schema-org/tests/draft2020-12/defs.json
new file mode 100644
index 0000000..da2a503
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/defs.json
@@ -0,0 +1,21 @@
+[
+ {
+ "description": "validate definition against metaschema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
+ },
+ "tests": [
+ {
+ "description": "valid definition schema",
+ "data": {"$defs": {"foo": {"type": "integer"}}},
+ "valid": true
+ },
+ {
+ "description": "invalid definition schema",
+ "data": {"$defs": {"foo": {"type": 1}}},
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/dependentRequired.json b/src/test/resources/json-schema-org/tests/draft2020-12/dependentRequired.json
new file mode 100644
index 0000000..2baa38e
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/dependentRequired.json
@@ -0,0 +1,152 @@
+[
+ {
+ "description": "single dependency",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/dependentSchemas.json b/src/test/resources/json-schema-org/tests/draft2020-12/dependentSchemas.json
new file mode 100644
index 0000000..1c5f057
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/dependentSchemas.json
@@ -0,0 +1,171 @@
+[
+ {
+ "description": "single dependency",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "ignores arrays",
+ "data": ["bar"],
+ "valid": true
+ },
+ {
+ "description": "ignores strings",
+ "data": "foobar",
+ "valid": true
+ },
+ {
+ "description": "ignores other non-objects",
+ "data": 12,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "boolean subschemas",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "dependent subschema incompatible with root",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "foo": {}
+ },
+ "dependentSchemas": {
+ "foo": {
+ "properties": {
+ "bar": {}
+ },
+ "additionalProperties": false
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "matches root",
+ "data": {"foo": 1},
+ "valid": false
+ },
+ {
+ "description": "matches dependency",
+ "data": {"bar": 1},
+ "valid": true
+ },
+ {
+ "description": "matches both",
+ "data": {"foo": 1, "bar": 2},
+ "valid": false
+ },
+ {
+ "description": "no dependency",
+ "data": {"baz": 1},
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/dynamicRef.json b/src/test/resources/json-schema-org/tests/draft2020-12/dynamicRef.json
new file mode 100644
index 0000000..bff26ad
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/dynamicRef.json
@@ -0,0 +1,760 @@
+[
+ {
+ "description": "A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamicRef-dynamicAnchor-same-schema/root",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "An array of strings is valid",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "An array containing non-strings is invalid",
+ "data": ["foo", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamicRef-anchor-same-schema/root",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "foo": {
+ "$anchor": "items",
+ "type": "string"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "An array of strings is valid",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "An array containing non-strings is invalid",
+ "data": ["foo", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/ref-dynamicAnchor-same-schema/root",
+ "type": "array",
+ "items": { "$ref": "#items" },
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "An array of strings is valid",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "An array containing non-strings is invalid",
+ "data": ["foo", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/typical-dynamic-resolution/root",
+ "$ref": "list",
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ },
+ "list": {
+ "$id": "list",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "items": {
+ "$comment": "This is only needed to satisfy the bookending requirement",
+ "$dynamicAnchor": "items"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "An array of strings is valid",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "An array containing non-strings is invalid",
+ "data": ["foo", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef without anchor in fragment behaves identical to $ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamicRef-without-anchor/root",
+ "$ref": "list",
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ },
+ "list": {
+ "$id": "list",
+ "type": "array",
+ "items": { "$dynamicRef": "#/$defs/items" },
+ "$defs": {
+ "items": {
+ "$comment": "This is only needed to satisfy the bookending requirement",
+ "$dynamicAnchor": "items",
+ "type": "number"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "An array of strings is invalid",
+ "data": ["foo", "bar"],
+ "valid": false
+ },
+ {
+ "description": "An array of numbers is valid",
+ "data": [24, 42],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamic-resolution-with-intermediate-scopes/root",
+ "$ref": "intermediate-scope",
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ },
+ "intermediate-scope": {
+ "$id": "intermediate-scope",
+ "$ref": "list"
+ },
+ "list": {
+ "$id": "list",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "items": {
+ "$comment": "This is only needed to satisfy the bookending requirement",
+ "$dynamicAnchor": "items"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "An array of strings is valid",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "An array containing non-strings is invalid",
+ "data": ["foo", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "An $anchor with the same name as a $dynamicAnchor is not used for dynamic scope resolution",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamic-resolution-ignores-anchors/root",
+ "$ref": "list",
+ "$defs": {
+ "foo": {
+ "$anchor": "items",
+ "type": "string"
+ },
+ "list": {
+ "$id": "list",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "items": {
+ "$comment": "This is only needed to satisfy the bookending requirement",
+ "$dynamicAnchor": "items"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "Any array is valid",
+ "data": ["foo", 42],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef without a matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamic-resolution-without-bookend/root",
+ "$ref": "list",
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ },
+ "list": {
+ "$id": "list",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "items": {
+ "$comment": "This is only needed to give the reference somewhere to resolve to when it behaves like $ref",
+ "$anchor": "items"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "Any array is valid",
+ "data": ["foo", 42],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef with a non-matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/unmatched-dynamic-anchor/root",
+ "$ref": "list",
+ "$defs": {
+ "foo": {
+ "$dynamicAnchor": "items",
+ "type": "string"
+ },
+ "list": {
+ "$id": "list",
+ "type": "array",
+ "items": { "$dynamicRef": "#items" },
+ "$defs": {
+ "items": {
+ "$comment": "This is only needed to give the reference somewhere to resolve to when it behaves like $ref",
+ "$anchor": "items",
+ "$dynamicAnchor": "foo"
+ }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "Any array is valid",
+ "data": ["foo", 42],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/relative-dynamic-reference/root",
+ "$dynamicAnchor": "meta",
+ "type": "object",
+ "properties": {
+ "foo": { "const": "pass" }
+ },
+ "$ref": "extended",
+ "$defs": {
+ "extended": {
+ "$id": "extended",
+ "$dynamicAnchor": "meta",
+ "type": "object",
+ "properties": {
+ "bar": { "$ref": "bar" }
+ }
+ },
+ "bar": {
+ "$id": "bar",
+ "type": "object",
+ "properties": {
+ "baz": { "$dynamicRef": "extended#meta" }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "The recursive part is valid against the root",
+ "data": {
+ "foo": "pass",
+ "bar": {
+ "baz": { "foo": "pass" }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "The recursive part is not valid against the root",
+ "data": {
+ "foo": "pass",
+ "bar": {
+ "baz": { "foo": "fail" }
+ }
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "A $dynamicRef that initially resolves to a schema without a matching $dynamicAnchor behaves like a normal $ref to $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/relative-dynamic-reference-without-bookend/root",
+ "$dynamicAnchor": "meta",
+ "type": "object",
+ "properties": {
+ "foo": { "const": "pass" }
+ },
+ "$ref": "extended",
+ "$defs": {
+ "extended": {
+ "$id": "extended",
+ "$anchor": "meta",
+ "type": "object",
+ "properties": {
+ "bar": { "$ref": "bar" }
+ }
+ },
+ "bar": {
+ "$id": "bar",
+ "type": "object",
+ "properties": {
+ "baz": { "$dynamicRef": "extended#meta" }
+ }
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "The recursive part doesn't need to validate against the root",
+ "data": {
+ "foo": "pass",
+ "bar": {
+ "baz": { "foo": "fail" }
+ }
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "multiple dynamic paths to the $dynamicRef keyword",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main",
+ "if": {
+ "properties": {
+ "kindOfList": { "const": "numbers" }
+ },
+ "required": ["kindOfList"]
+ },
+ "then": { "$ref": "numberList" },
+ "else": { "$ref": "stringList" },
+
+ "$defs": {
+ "genericList": {
+ "$id": "genericList",
+ "properties": {
+ "list": {
+ "items": { "$dynamicRef": "#itemType" }
+ }
+ },
+ "$defs": {
+ "defaultItemType": {
+ "$comment": "Only needed to satisfy bookending requirement",
+ "$dynamicAnchor": "itemType"
+ }
+ }
+ },
+ "numberList": {
+ "$id": "numberList",
+ "$defs": {
+ "itemType": {
+ "$dynamicAnchor": "itemType",
+ "type": "number"
+ }
+ },
+ "$ref": "genericList"
+ },
+ "stringList": {
+ "$id": "stringList",
+ "$defs": {
+ "itemType": {
+ "$dynamicAnchor": "itemType",
+ "type": "string"
+ }
+ },
+ "$ref": "genericList"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "number list with number values",
+ "data": {
+ "kindOfList": "numbers",
+ "list": [1.1]
+ },
+ "valid": true
+ },
+ {
+ "description": "number list with string values",
+ "data": {
+ "kindOfList": "numbers",
+ "list": ["foo"]
+ },
+ "valid": false
+ },
+ {
+ "description": "string list with number values",
+ "data": {
+ "kindOfList": "strings",
+ "list": [1.1]
+ },
+ "valid": false
+ },
+ {
+ "description": "string list with string values",
+ "data": {
+ "kindOfList": "strings",
+ "list": ["foo"]
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "after leaving a dynamic scope, it is not used by a $dynamicRef",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main",
+ "if": {
+ "$id": "first_scope",
+ "$defs": {
+ "thingy": {
+ "$comment": "this is first_scope#thingy",
+ "$dynamicAnchor": "thingy",
+ "type": "number"
+ }
+ }
+ },
+ "then": {
+ "$id": "second_scope",
+ "$ref": "start",
+ "$defs": {
+ "thingy": {
+ "$comment": "this is second_scope#thingy, the final destination of the $dynamicRef",
+ "$dynamicAnchor": "thingy",
+ "type": "null"
+ }
+ }
+ },
+ "$defs": {
+ "start": {
+ "$comment": "this is the landing spot from $ref",
+ "$id": "start",
+ "$dynamicRef": "inner_scope#thingy"
+ },
+ "thingy": {
+ "$comment": "this is the first stop for the $dynamicRef",
+ "$id": "inner_scope",
+ "$dynamicAnchor": "thingy",
+ "type": "string"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "string matches /$defs/thingy, but the $dynamicRef does not stop here",
+ "data": "a string",
+ "valid": false
+ },
+ {
+ "description": "first_scope is not in dynamic scope for the $dynamicRef",
+ "data": 42,
+ "valid": false
+ },
+ {
+ "description": "/then/$defs/thingy is the final stop for the $dynamicRef",
+ "data": null,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "strict-tree schema, guards against misspelled properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/strict-tree.json",
+ "$dynamicAnchor": "node",
+
+ "$ref": "tree.json",
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "instance with misspelled field",
+ "data": {
+ "children": [{
+ "daat": 1
+ }]
+ },
+ "valid": false
+ },
+ {
+ "description": "instance with correct field",
+ "data": {
+ "children": [{
+ "data": 1
+ }]
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "tests for implementation dynamic anchor and reference link",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/strict-extendible.json",
+ "$ref": "extendible-dynamic-ref.json",
+ "$defs": {
+ "elements": {
+ "$dynamicAnchor": "elements",
+ "properties": {
+ "a": true
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "incorrect parent schema",
+ "data": {
+ "a": true
+ },
+ "valid": false
+ },
+ {
+ "description": "incorrect extended schema",
+ "data": {
+ "elements": [
+ { "b": 1 }
+ ]
+ },
+ "valid": false
+ },
+ {
+ "description": "correct extended schema",
+ "data": {
+ "elements": [
+ { "a": 1 }
+ ]
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "$ref and $dynamicAnchor are independent of order - $defs first",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/strict-extendible-allof-defs-first.json",
+ "allOf": [
+ {
+ "$ref": "extendible-dynamic-ref.json"
+ },
+ {
+ "$defs": {
+ "elements": {
+ "$dynamicAnchor": "elements",
+ "properties": {
+ "a": true
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ }
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "incorrect parent schema",
+ "data": {
+ "a": true
+ },
+ "valid": false
+ },
+ {
+ "description": "incorrect extended schema",
+ "data": {
+ "elements": [
+ { "b": 1 }
+ ]
+ },
+ "valid": false
+ },
+ {
+ "description": "correct extended schema",
+ "data": {
+ "elements": [
+ { "a": 1 }
+ ]
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "$ref and $dynamicAnchor are independent of order - $ref first",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/strict-extendible-allof-ref-first.json",
+ "allOf": [
+ {
+ "$defs": {
+ "elements": {
+ "$dynamicAnchor": "elements",
+ "properties": {
+ "a": true
+ },
+ "required": ["a"],
+ "additionalProperties": false
+ }
+ }
+ },
+ {
+ "$ref": "extendible-dynamic-ref.json"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "incorrect parent schema",
+ "data": {
+ "a": true
+ },
+ "valid": false
+ },
+ {
+ "description": "incorrect extended schema",
+ "data": {
+ "elements": [
+ { "b": 1 }
+ ]
+ },
+ "valid": false
+ },
+ {
+ "description": "correct extended schema",
+ "data": {
+ "elements": [
+ { "a": 1 }
+ ]
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "$ref to $dynamicRef finds detached $dynamicAnchor",
+ "schema": {
+ "$ref": "http://localhost:1234/draft2020-12/detached-dynamicref.json#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "$dynamicRef points to a boolean schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "true": true,
+ "false": false
+ },
+ "properties": {
+ "true": {
+ "$dynamicRef": "#/$defs/true"
+ },
+ "false": {
+ "$dynamicRef": "#/$defs/false"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "follow $dynamicRef to a true schema",
+ "data": { "true": 1 },
+ "valid": true
+ },
+ {
+ "description": "follow $dynamicRef to a false schema",
+ "data": { "false": 1 },
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/enum.json b/src/test/resources/json-schema-org/tests/draft2020-12/enum.json
new file mode 100644
index 0000000..c8f35ea
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/enum.json
@@ -0,0 +1,358 @@
+[
+ {
+ "description": "simple enum validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "valid object matches",
+ "data": {"foo": 12},
+ "valid": true
+ },
+ {
+ "description": "extra properties in object is invalid",
+ "data": {"foo": 12, "boo": 42},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "heterogeneous enum-with-null validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 [false] does not match [0]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "enum": [[false]]
+ },
+ "tests": [
+ {
+ "description": "[false] is valid",
+ "data": [false],
+ "valid": true
+ },
+ {
+ "description": "[0] is invalid",
+ "data": [0],
+ "valid": false
+ },
+ {
+ "description": "[0.0] is invalid",
+ "data": [0.0],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "enum with true does not match 1",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 [true] does not match [1]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "enum": [[true]]
+ },
+ "tests": [
+ {
+ "description": "[true] is valid",
+ "data": [true],
+ "valid": true
+ },
+ {
+ "description": "[1] is invalid",
+ "data": [1],
+ "valid": false
+ },
+ {
+ "description": "[1.0] is invalid",
+ "data": [1.0],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "enum with 0 does not match false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 [0] does not match [false]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "enum": [[0]]
+ },
+ "tests": [
+ {
+ "description": "[false] is invalid",
+ "data": [false],
+ "valid": false
+ },
+ {
+ "description": "[0] is valid",
+ "data": [0],
+ "valid": true
+ },
+ {
+ "description": "[0.0] is valid",
+ "data": [0.0],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "enum with 1 does not match true",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "enum with [1] does not match [true]",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "enum": [[1]]
+ },
+ "tests": [
+ {
+ "description": "[true] is invalid",
+ "data": [true],
+ "valid": false
+ },
+ {
+ "description": "[1] is valid",
+ "data": [1],
+ "valid": true
+ },
+ {
+ "description": "[1.0] is valid",
+ "data": [1.0],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "nul characters in strings",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/exclusiveMaximum.json b/src/test/resources/json-schema-org/tests/draft2020-12/exclusiveMaximum.json
new file mode 100644
index 0000000..05db233
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/exclusiveMaximum.json
@@ -0,0 +1,31 @@
+[
+ {
+ "description": "exclusiveMaximum validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/exclusiveMinimum.json b/src/test/resources/json-schema-org/tests/draft2020-12/exclusiveMinimum.json
new file mode 100644
index 0000000..00af9d7
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/exclusiveMinimum.json
@@ -0,0 +1,31 @@
+[
+ {
+ "description": "exclusiveMinimum validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/format.json b/src/test/resources/json-schema-org/tests/draft2020-12/format.json
new file mode 100644
index 0000000..01adcbd
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/format.json
@@ -0,0 +1,838 @@
+[
+ {
+ "description": "email format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "email"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid email string is only an annotation by default",
+ "data": "2962",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "idn-email format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "idn-email"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid idn-email string is only an annotation by default",
+ "data": "2962",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "regex format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "regex"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid regex string is only an annotation by default",
+ "data": "^(abc]",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "ipv4 format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "ipv4"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid ipv4 string is only an annotation by default",
+ "data": "127.0.0.0.1",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "ipv6 format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "ipv6"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid ipv6 string is only an annotation by default",
+ "data": "12345::",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "idn-hostname format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "idn-hostname"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid idn-hostname string is only an annotation by default",
+ "data": "〮실례.테스트",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "hostname format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "hostname"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid hostname string is only an annotation by default",
+ "data": "-a-host-name-that-starts-with--",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "date format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "date"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid date string is only an annotation by default",
+ "data": "06/19/1963",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "date-time format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "date-time"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid date-time string is only an annotation by default",
+ "data": "1990-02-31T15:59:60.123-08:00",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "time format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "time"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid time string is only an annotation by default",
+ "data": "08:30:06 PST",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "json-pointer format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "json-pointer"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid json-pointer string is only an annotation by default",
+ "data": "/foo/bar~",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "relative-json-pointer format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "relative-json-pointer"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid relative-json-pointer string is only an annotation by default",
+ "data": "/foo/bar",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "iri format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "iri"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid iri string is only an annotation by default",
+ "data": "http://2001:0db8:85a3:0000:0000:8a2e:0370:7334",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "iri-reference format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "iri-reference"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid iri-reference string is only an annotation by default",
+ "data": "\\\\WINDOWS\\filëßåré",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uri format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "uri"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid uri string is only an annotation by default",
+ "data": "//foo.bar/?baz=qux#quux",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uri-reference format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "uri-reference"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid uri-reference string is only an annotation by default",
+ "data": "\\\\WINDOWS\\fileshare",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uri-template format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "uri-template"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid uri-template string is only an annotation by default",
+ "data": "http://example.com/dictionary/{term:1}/{term",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uuid format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "uuid"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid uuid string is only an annotation by default",
+ "data": "2eb8aa08-aa98-11ea-b4aa-73b441d1638",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "duration format",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "format": "duration"
+ },
+ "tests": [
+ {
+ "description": "all string formats ignore integers",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore floats",
+ "data": 13.7,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore objects",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore booleans",
+ "data": false,
+ "valid": true
+ },
+ {
+ "description": "all string formats ignore nulls",
+ "data": null,
+ "valid": true
+ },
+ {
+ "description": "invalid duration string is only an annotation by default",
+ "data": "PT1D",
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/id.json b/src/test/resources/json-schema-org/tests/draft2020-12/id.json
new file mode 100644
index 0000000..59265c4
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/id.json
@@ -0,0 +1,211 @@
+[
+ {
+ "description": "Invalid use of fragments in location-independent $id",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/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/draft2020-12/bar#foo",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/bar#foo",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier path with absolute URI",
+ "data": {
+ "$ref": "http://localhost:1234/draft2020-12/bar#/a/b",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/bar#/a/b",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": false
+ },
+ {
+ "description": "Identifier name with base URI change in subschema",
+ "data": {
+ "$id": "http://localhost:1234/draft2020-12/root",
+ "$ref": "http://localhost:1234/draft2020-12/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/draft2020-12/root",
+ "$ref": "http://localhost:1234/draft2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
+ },
+ "tests": [
+ {
+ "description": "Identifier name with absolute URI",
+ "data": {
+ "$ref": "http://localhost:1234/draft2020-12/bar",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/bar#",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Identifier name with base URI change in subschema",
+ "data": {
+ "$id": "http://localhost:1234/draft2020-12/root",
+ "$ref": "http://localhost:1234/draft2020-12/nested.json#/$defs/B",
+ "$defs": {
+ "A": {
+ "$id": "nested.json",
+ "$defs": {
+ "B": {
+ "$id": "#",
+ "type": "integer"
+ }
+ }
+ }
+ }
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "Unnormalized $ids are allowed but discouraged",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
+ },
+ "tests": [
+ {
+ "description": "Unnormalized identifier",
+ "data": {
+ "$ref": "http://localhost:1234/draft2020-12/foo/baz",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Unnormalized identifier and no ref",
+ "data": {
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Unnormalized identifier with empty fragment",
+ "data": {
+ "$ref": "http://localhost:1234/draft2020-12/foo/baz",
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz#",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "Unnormalized identifier with empty fragment and no ref",
+ "data": {
+ "$defs": {
+ "A": {
+ "$id": "http://localhost:1234/draft2020-12/foo/bar/../baz#",
+ "type": "integer"
+ }
+ }
+ },
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/if-then-else.json b/src/test/resources/json-schema-org/tests/draft2020-12/if-then-else.json
new file mode 100644
index 0000000..1c35d7e
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/if-then-else.json
@@ -0,0 +1,268 @@
+[
+ {
+ "description": "ignore if without then or else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "if appears at the end when serialized (keyword processing sequence)",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "then": { "const": "yes" },
+ "else": { "const": "other" },
+ "if": { "maxLength": 4 }
+ },
+ "tests": [
+ {
+ "description": "yes redirects to then and passes",
+ "data": "yes",
+ "valid": true
+ },
+ {
+ "description": "other redirects to else and passes",
+ "data": "other",
+ "valid": true
+ },
+ {
+ "description": "no redirects to then and fails",
+ "data": "no",
+ "valid": false
+ },
+ {
+ "description": "invalid redirects to else and fails",
+ "data": "invalid",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/infinite-loop-detection.json b/src/test/resources/json-schema-org/tests/draft2020-12/infinite-loop-detection.json
new file mode 100644
index 0000000..46f157a
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/infinite-loop-detection.json
@@ -0,0 +1,37 @@
+[
+ {
+ "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "int": { "type": "integer" }
+ },
+ "allOf": [
+ {
+ "properties": {
+ "foo": {
+ "$ref": "#/$defs/int"
+ }
+ }
+ },
+ {
+ "additionalProperties": {
+ "$ref": "#/$defs/int"
+ }
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "passing case",
+ "data": { "foo": 1 },
+ "valid": true
+ },
+ {
+ "description": "failing case",
+ "data": { "foo": "a string" },
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/items.json b/src/test/resources/json-schema-org/tests/draft2020-12/items.json
new file mode 100644
index 0000000..6a3e1cf
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/items.json
@@ -0,0 +1,304 @@
+[
+ {
+ "description": "a schema given for items",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "items with boolean schema (true)",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 and subitems",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "item": {
+ "type": "array",
+ "items": false,
+ "prefixItems": [
+ { "$ref": "#/$defs/sub-item" },
+ { "$ref": "#/$defs/sub-item" }
+ ]
+ },
+ "sub-item": {
+ "type": "object",
+ "required": ["foo"]
+ }
+ },
+ "type": "array",
+ "items": false,
+ "prefixItems": [
+ { "$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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "prefixItems with no additional items allowed",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{}, {}, {}],
+ "items": 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": "items does not look in applicators, valid case",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ { "prefixItems": [ { "minimum": 3 } ] }
+ ],
+ "items": { "minimum": 5 }
+ },
+ "tests": [
+ {
+ "description": "prefixItems in allOf does not constrain items, invalid case",
+ "data": [ 3, 5 ],
+ "valid": false
+ },
+ {
+ "description": "prefixItems in allOf does not constrain items, valid case",
+ "data": [ 5, 5 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "prefixItems validation adjusts the starting index for items",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [ { "type": "string" } ],
+ "items": { "type": "integer" }
+ },
+ "tests": [
+ {
+ "description": "valid items",
+ "data": [ "x", 2, 3 ],
+ "valid": true
+ },
+ {
+ "description": "wrong type of second item",
+ "data": [ "x", "y" ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "items with heterogeneous array",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{}],
+ "items": false
+ },
+ "tests": [
+ {
+ "description": "heterogeneous invalid instance",
+ "data": [ "foo", "bar", 37 ],
+ "valid": false
+ },
+ {
+ "description": "valid instance",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "items with null instance elements",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "items": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null elements",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/maxContains.json b/src/test/resources/json-schema-org/tests/draft2020-12/maxContains.json
new file mode 100644
index 0000000..8cd3ca7
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/maxContains.json
@@ -0,0 +1,102 @@
+[
+ {
+ "description": "maxContains without contains is ignored",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "maxContains with contains, value with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contains": {"const": 1},
+ "maxContains": 1.0
+ },
+ "tests": [
+ {
+ "description": "one element matches, valid maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "too many elements match, invalid maxContains",
+ "data": [ 1, 1 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "minContains < maxContains",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/maxItems.json b/src/test/resources/json-schema-org/tests/draft2020-12/maxItems.json
new file mode 100644
index 0000000..f6a6b7c
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/maxItems.json
@@ -0,0 +1,50 @@
+[
+ {
+ "description": "maxItems validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "maxItems validation with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "maxItems": 2.0
+ },
+ "tests": [
+ {
+ "description": "shorter is valid",
+ "data": [1],
+ "valid": true
+ },
+ {
+ "description": "too long is invalid",
+ "data": [1, 2, 3],
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/maxLength.json b/src/test/resources/json-schema-org/tests/draft2020-12/maxLength.json
new file mode 100644
index 0000000..7462726
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/maxLength.json
@@ -0,0 +1,55 @@
+[
+ {
+ "description": "maxLength validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 graphemes is long enough",
+ "data": "\uD83D\uDCA9\uD83D\uDCA9",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "maxLength validation with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "maxLength": 2.0
+ },
+ "tests": [
+ {
+ "description": "shorter is valid",
+ "data": "f",
+ "valid": true
+ },
+ {
+ "description": "too long is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/maxProperties.json b/src/test/resources/json-schema-org/tests/draft2020-12/maxProperties.json
new file mode 100644
index 0000000..73ae731
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/maxProperties.json
@@ -0,0 +1,79 @@
+[
+ {
+ "description": "maxProperties validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 validation with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "maxProperties": 2.0
+ },
+ "tests": [
+ {
+ "description": "shorter is valid",
+ "data": {"foo": 1},
+ "valid": true
+ },
+ {
+ "description": "too long is invalid",
+ "data": {"foo": 1, "bar": 2, "baz": 3},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "maxProperties = 0 means the object is empty",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/maximum.json b/src/test/resources/json-schema-org/tests/draft2020-12/maximum.json
new file mode 100644
index 0000000..b99a541
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/maximum.json
@@ -0,0 +1,60 @@
+[
+ {
+ "description": "maximum validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/minContains.json b/src/test/resources/json-schema-org/tests/draft2020-12/minContains.json
new file mode 100644
index 0000000..ee72d7d
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/minContains.json
@@ -0,0 +1,224 @@
+[
+ {
+ "description": "minContains without contains is ignored",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "minContains=2 with contains with a decimal value",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contains": {"const": 1},
+ "minContains": 2.0
+ },
+ "tests": [
+ {
+ "description": "one element matches, invalid minContains",
+ "data": [ 1 ],
+ "valid": false
+ },
+ {
+ "description": "both elements match, valid minContains",
+ "data": [ 1, 1 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "maxContains = minContains",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contains": {"const": 1},
+ "minContains": 0
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "minContains = 0 makes contains always pass",
+ "data": [ 2 ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "minContains = 0 with maxContains",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "contains": {"const": 1},
+ "minContains": 0,
+ "maxContains": 1
+ },
+ "tests": [
+ {
+ "description": "empty data",
+ "data": [ ],
+ "valid": true
+ },
+ {
+ "description": "not more than maxContains",
+ "data": [ 1 ],
+ "valid": true
+ },
+ {
+ "description": "too many",
+ "data": [ 1, 1 ],
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/minItems.json b/src/test/resources/json-schema-org/tests/draft2020-12/minItems.json
new file mode 100644
index 0000000..9d6a8b6
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/minItems.json
@@ -0,0 +1,50 @@
+[
+ {
+ "description": "minItems validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "minItems validation with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "minItems": 1.0
+ },
+ "tests": [
+ {
+ "description": "longer is valid",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "too short is invalid",
+ "data": [],
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/minLength.json b/src/test/resources/json-schema-org/tests/draft2020-12/minLength.json
new file mode 100644
index 0000000..5076c5a
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/minLength.json
@@ -0,0 +1,55 @@
+[
+ {
+ "description": "minLength validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 grapheme is not long enough",
+ "data": "\uD83D\uDCA9",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "minLength validation with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "minLength": 2.0
+ },
+ "tests": [
+ {
+ "description": "longer is valid",
+ "data": "foo",
+ "valid": true
+ },
+ {
+ "description": "too short is invalid",
+ "data": "f",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/minProperties.json b/src/test/resources/json-schema-org/tests/draft2020-12/minProperties.json
new file mode 100644
index 0000000..a753ad3
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/minProperties.json
@@ -0,0 +1,60 @@
+[
+ {
+ "description": "minProperties validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "minProperties validation with a decimal",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "minProperties": 1.0
+ },
+ "tests": [
+ {
+ "description": "longer is valid",
+ "data": {"foo": 1, "bar": 2},
+ "valid": true
+ },
+ {
+ "description": "too short is invalid",
+ "data": {},
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/minimum.json b/src/test/resources/json-schema-org/tests/draft2020-12/minimum.json
new file mode 100644
index 0000000..dc44052
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/minimum.json
@@ -0,0 +1,75 @@
+[
+ {
+ "description": "minimum validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/multipleOf.json b/src/test/resources/json-schema-org/tests/draft2020-12/multipleOf.json
new file mode 100644
index 0000000..92d6979
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/multipleOf.json
@@ -0,0 +1,97 @@
+[
+ {
+ "description": "by int",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "multipleOf": 0.0001
+ },
+ "tests": [
+ {
+ "description": "0.0075 is multiple of 0.0001",
+ "data": 0.0075,
+ "valid": true
+ },
+ {
+ "description": "0.00751 is not multiple of 0.0001",
+ "data": 0.00751,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "float division = inf",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "integer", "multipleOf": 0.123456789
+ },
+ "tests": [
+ {
+ "description": "always invalid, but naive implementations may raise an overflow error",
+ "data": 1e308,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "small multiple of large integer",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "integer", "multipleOf": 1e-8
+ },
+ "tests": [
+ {
+ "description": "any integer is a multiple of 1e-8",
+ "data": 12391239123,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/not.json b/src/test/resources/json-schema-org/tests/draft2020-12/not.json
new file mode 100644
index 0000000..d0f2b6e
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/not.json
@@ -0,0 +1,301 @@
+[
+ {
+ "description": "not",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "not": {"type": "integer"}
+ },
+ "tests": [
+ {
+ "description": "allowed",
+ "data": "foo",
+ "valid": true
+ },
+ {
+ "description": "disallowed",
+ "data": 1,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "not multiple types",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "forbid everything with empty schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "not": {}
+ },
+ "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
+ }
+ ]
+ },
+ {
+ "description": "forbid everything with boolean schema true",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "not": true
+ },
+ "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
+ }
+ ]
+ },
+ {
+ "description": "allow everything with boolean schema false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "not": false
+ },
+ "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": "double negation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "not": { "not": {} }
+ },
+ "tests": [
+ {
+ "description": "any value is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "collect annotations inside a 'not', even if collection is disabled",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "not": {
+ "$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
+ "anyOf": [
+ true,
+ { "properties": { "foo": true } }
+ ],
+ "unevaluatedProperties": false
+ }
+ },
+ "tests": [
+ {
+ "description": "unevaluated property",
+ "data": { "bar": 1 },
+ "valid": true
+ },
+ {
+ "description": "annotations are still collected inside a 'not'",
+ "data": { "foo": 1 },
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/oneOf.json b/src/test/resources/json-schema-org/tests/draft2020-12/oneOf.json
new file mode 100644
index 0000000..416c8e5
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/oneOf.json
@@ -0,0 +1,293 @@
+[
+ {
+ "description": "oneOf",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "oneOf": [true, true, true]
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "oneOf with boolean schemas, one true",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "oneOf": [true, true, false]
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "oneOf with boolean schemas, all false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "oneOf": [false, false, false]
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "oneOf complex types",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/pattern.json b/src/test/resources/json-schema-org/tests/draft2020-12/pattern.json
new file mode 100644
index 0000000..af0b8d8
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/pattern.json
@@ -0,0 +1,65 @@
+[
+ {
+ "description": "pattern validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "pattern": "a+"
+ },
+ "tests": [
+ {
+ "description": "matches a substring",
+ "data": "xxaayy",
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/patternProperties.json b/src/test/resources/json-schema-org/tests/draft2020-12/patternProperties.json
new file mode 100644
index 0000000..81829c7
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/patternProperties.json
@@ -0,0 +1,176 @@
+[
+ {
+ "description":
+ "patternProperties validates properties matching a regex",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "object with a property matching both true and false is invalid",
+ "data": {"foobar":1},
+ "valid": false
+ },
+ {
+ "description": "empty object is valid",
+ "data": {},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "patternProperties with null valued instance properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "patternProperties": {
+ "^.*bar$": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null values",
+ "data": {"foobar": null},
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/prefixItems.json b/src/test/resources/json-schema-org/tests/draft2020-12/prefixItems.json
new file mode 100644
index 0000000..0adfc06
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/prefixItems.json
@@ -0,0 +1,104 @@
+[
+ {
+ "description": "a schema given for prefixItems",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ {"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": "prefixItems with boolean schemas",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [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": "additional items are allowed by default",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{"type": "integer"}]
+ },
+ "tests": [
+ {
+ "description": "only the first item is validated",
+ "data": [1, "foo", false],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "prefixItems with null instance elements",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "allows null elements",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/properties.json b/src/test/resources/json-schema-org/tests/draft2020-12/properties.json
new file mode 100644
index 0000000..eb66fa8
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/properties.json
@@ -0,0 +1,242 @@
+[
+ {
+ "description": "object properties validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "properties with null valued instance properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "foo": {"type": "null"}
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null values",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "properties whose names are Javascript object property names",
+ "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "__proto__": {"type": "number"},
+ "toString": {
+ "properties": { "length": { "type": "string" } }
+ },
+ "constructor": {"type": "number"}
+ }
+ },
+ "tests": [
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores other non-objects",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "none of the properties mentioned",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "__proto__ not valid",
+ "data": { "__proto__": "foo" },
+ "valid": false
+ },
+ {
+ "description": "toString not valid",
+ "data": { "toString": { "length": 37 } },
+ "valid": false
+ },
+ {
+ "description": "constructor not valid",
+ "data": { "constructor": { "length": 37 } },
+ "valid": false
+ },
+ {
+ "description": "all present and valid",
+ "data": {
+ "__proto__": 12,
+ "toString": { "length": "foo" },
+ "constructor": 37
+ },
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/propertyNames.json b/src/test/resources/json-schema-org/tests/draft2020-12/propertyNames.json
new file mode 100644
index 0000000..7ecfb7e
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/propertyNames.json
@@ -0,0 +1,85 @@
+[
+ {
+ "description": "propertyNames validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/ref.json b/src/test/resources/json-schema-org/tests/draft2020-12/ref.json
new file mode 100644
index 0000000..8d15fa4
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/ref.json
@@ -0,0 +1,1067 @@
+[
+ {
+ "description": "root pointer ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ {"type": "integer"},
+ {"$ref": "#/prefixItems/0"}
+ ]
+ },
+ "tests": [
+ {
+ "description": "match array",
+ "data": [1, 2],
+ "valid": true
+ },
+ {
+ "description": "mismatch array",
+ "data": [1, "foo"],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "escaped pointer ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "#/$defs/bool",
+ "$defs": {
+ "bool": true
+ }
+ },
+ "tests": [
+ {
+ "description": "any value is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "$ref to boolean schema false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "#/$defs/bool",
+ "$defs": {
+ "bool": false
+ }
+ },
+ "tests": [
+ {
+ "description": "any value is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "Recursive references between schemas",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/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/draft2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "naive replacement of $ref with its destination is not correct",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "a_string": { "type": "string" }
+ },
+ "enum": [
+ { "$ref": "#/$defs/a_string" }
+ ]
+ },
+ "tests": [
+ {
+ "description": "do not evaluate the $ref inside the enum, matching any string",
+ "data": "this is a string",
+ "valid": false
+ },
+ {
+ "description": "do not evaluate the $ref inside the enum, definition exact match",
+ "data": { "type": "string" },
+ "valid": false
+ },
+ {
+ "description": "match the enum exactly",
+ "data": { "$ref": "#/$defs/a_string" },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "refs with relative uris and defs",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://example.com/schema-relative-uri-defs1.json",
+ "properties": {
+ "foo": {
+ "$id": "schema-relative-uri-defs2.json",
+ "$defs": {
+ "inner": {
+ "properties": {
+ "bar": { "type": "string" }
+ }
+ }
+ },
+ "$ref": "#/$defs/inner"
+ }
+ },
+ "$ref": "schema-relative-uri-defs2.json"
+ },
+ "tests": [
+ {
+ "description": "invalid on inner field",
+ "data": {
+ "foo": {
+ "bar": 1
+ },
+ "bar": "a"
+ },
+ "valid": false
+ },
+ {
+ "description": "invalid on outer field",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "valid on both fields",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": "a"
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "relative refs with absolute uris and defs",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://example.com/schema-refs-absolute-uris-defs1.json",
+ "properties": {
+ "foo": {
+ "$id": "http://example.com/schema-refs-absolute-uris-defs2.json",
+ "$defs": {
+ "inner": {
+ "properties": {
+ "bar": { "type": "string" }
+ }
+ }
+ },
+ "$ref": "#/$defs/inner"
+ }
+ },
+ "$ref": "schema-refs-absolute-uris-defs2.json"
+ },
+ "tests": [
+ {
+ "description": "invalid on inner field",
+ "data": {
+ "foo": {
+ "bar": 1
+ },
+ "bar": "a"
+ },
+ "valid": false
+ },
+ {
+ "description": "invalid on outer field",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "valid on both fields",
+ "data": {
+ "foo": {
+ "bar": "a"
+ },
+ "bar": "a"
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "$id must be resolved against nearest parent, not just immediate parent",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://example.com/a.json",
+ "$defs": {
+ "x": {
+ "$id": "http://example.com/b/c.json",
+ "not": {
+ "$defs": {
+ "y": {
+ "$id": "d.json",
+ "type": "number"
+ }
+ }
+ }
+ }
+ },
+ "allOf": [
+ {
+ "$ref": "http://example.com/b/d.json"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "order of evaluation: $id and $ref",
+ "schema": {
+ "$comment": "$id must be evaluated before $ref to get the proper $ref destination",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://example.com/draft2020-12/ref-and-id1/base.json",
+ "$ref": "int.json",
+ "$defs": {
+ "bigint": {
+ "$comment": "canonical uri: https://example.com/ref-and-id1/int.json",
+ "$id": "int.json",
+ "maximum": 10
+ },
+ "smallint": {
+ "$comment": "canonical uri: https://example.com/ref-and-id1-int.json",
+ "$id": "/draft2020-12/ref-and-id1-int.json",
+ "maximum": 2
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "data is valid against first definition",
+ "data": 5,
+ "valid": true
+ },
+ {
+ "description": "data is invalid against first definition",
+ "data": 50,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "order of evaluation: $id and $anchor and $ref",
+ "schema": {
+ "$comment": "$id must be evaluated before $ref to get the proper $ref destination",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://example.com/draft2020-12/ref-and-id2/base.json",
+ "$ref": "#bigint",
+ "$defs": {
+ "bigint": {
+ "$comment": "canonical uri: /ref-and-id2/base.json#/$defs/bigint; another valid uri for this location: /ref-and-id2/base.json#bigint",
+ "$anchor": "bigint",
+ "maximum": 10
+ },
+ "smallint": {
+ "$comment": "canonical uri: https://example.com/ref-and-id2#/$defs/smallint; another valid uri for this location: https://example.com/ref-and-id2/#bigint",
+ "$id": "https://example.com/draft2020-12/ref-and-id2/",
+ "$anchor": "bigint",
+ "maximum": 2
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "data is valid against first definition",
+ "data": 5,
+ "valid": true
+ },
+ {
+ "description": "data is invalid against first definition",
+ "data": 50,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "simple URN base URI with $ref via the URN",
+ "schema": {
+ "$comment": "URIs do not have to have HTTP(s) schemes",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed",
+ "minimum": 30,
+ "properties": {
+ "foo": {"$ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed"}
+ }
+ },
+ "tests": [
+ {
+ "description": "valid under the URN IDed schema",
+ "data": {"foo": 37},
+ "valid": true
+ },
+ {
+ "description": "invalid under the URN IDed schema",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "simple URN base URI with JSON pointer",
+ "schema": {
+ "$comment": "URIs do not have to have HTTP(s) schemes",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed",
+ "properties": {
+ "foo": {"$ref": "#/$defs/bar"}
+ },
+ "$defs": {
+ "bar": {"type": "string"}
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": {"foo": "bar"},
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN base URI with NSS",
+ "schema": {
+ "$comment": "RFC 8141 §2.2",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:example:1/406/47452/2",
+ "properties": {
+ "foo": {"$ref": "#/$defs/bar"}
+ },
+ "$defs": {
+ "bar": {"type": "string"}
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": {"foo": "bar"},
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN base URI with r-component",
+ "schema": {
+ "$comment": "RFC 8141 §2.3.1",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk",
+ "properties": {
+ "foo": {"$ref": "#/$defs/bar"}
+ },
+ "$defs": {
+ "bar": {"type": "string"}
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": {"foo": "bar"},
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN base URI with q-component",
+ "schema": {
+ "$comment": "RFC 8141 §2.3.2",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:example:weather?=op=map&lat=39.56&lon=-104.85&datetime=1969-07-21T02:56:15Z",
+ "properties": {
+ "foo": {"$ref": "#/$defs/bar"}
+ },
+ "$defs": {
+ "bar": {"type": "string"}
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": {"foo": "bar"},
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN base URI with f-component",
+ "schema": {
+ "$comment": "RFC 8141 §2.3.3, but we don't allow fragments",
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
+ },
+ "tests": [
+ {
+ "description": "is invalid",
+ "data": {"$id": "urn:example:foo-bar-baz-qux#somepart"},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN base URI with URN and JSON pointer ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed",
+ "properties": {
+ "foo": {"$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/$defs/bar"}
+ },
+ "$defs": {
+ "bar": {"type": "string"}
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": {"foo": "bar"},
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN base URI with URN and anchor ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed",
+ "properties": {
+ "foo": {"$ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something"}
+ },
+ "$defs": {
+ "bar": {
+ "$anchor": "something",
+ "type": "string"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": {"foo": "bar"},
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": {"foo": 12},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "URN ref with nested pointer ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {
+ "foo": {
+ "$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
+ "$defs": {"bar": {"type": "string"}},
+ "$ref": "#/$defs/bar"
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": "bar",
+ "valid": true
+ },
+ {
+ "description": "a non-string is invalid",
+ "data": 12,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "ref to if",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://example.com/ref/if",
+ "if": {
+ "$id": "http://example.com/ref/if",
+ "type": "integer"
+ }
+ },
+ "tests": [
+ {
+ "description": "a non-integer is invalid due to the $ref",
+ "data": "foo",
+ "valid": false
+ },
+ {
+ "description": "an integer is valid",
+ "data": 12,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "ref to then",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://example.com/ref/then",
+ "then": {
+ "$id": "http://example.com/ref/then",
+ "type": "integer"
+ }
+ },
+ "tests": [
+ {
+ "description": "a non-integer is invalid due to the $ref",
+ "data": "foo",
+ "valid": false
+ },
+ {
+ "description": "an integer is valid",
+ "data": 12,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "ref to else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://example.com/ref/else",
+ "else": {
+ "$id": "http://example.com/ref/else",
+ "type": "integer"
+ }
+ },
+ "tests": [
+ {
+ "description": "a non-integer is invalid due to the $ref",
+ "data": "foo",
+ "valid": false
+ },
+ {
+ "description": "an integer is valid",
+ "data": 12,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "ref with absolute-path-reference",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://example.com/ref/absref.json",
+ "$defs": {
+ "a": {
+ "$id": "http://example.com/ref/absref/foobar.json",
+ "type": "number"
+ },
+ "b": {
+ "$id": "http://example.com/absref/foobar.json",
+ "type": "string"
+ }
+ },
+ "$ref": "/absref/foobar.json"
+ },
+ "tests": [
+ {
+ "description": "a string is valid",
+ "data": "foo",
+ "valid": true
+ },
+ {
+ "description": "an integer is invalid",
+ "data": 12,
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "$id with file URI still resolves pointers - *nix",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "file:///folder/file.json",
+ "$defs": {
+ "foo": {
+ "type": "number"
+ }
+ },
+ "$ref": "#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "$id with file URI still resolves pointers - windows",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "file:///c:/folder/file.json",
+ "$defs": {
+ "foo": {
+ "type": "number"
+ }
+ },
+ "$ref": "#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "empty tokens in $ref json-pointer",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "": {
+ "$defs": {
+ "": { "type": "number" }
+ }
+ }
+ },
+ "allOf": [
+ {
+ "$ref": "#/$defs//$defs/"
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/refRemote.json b/src/test/resources/json-schema-org/tests/draft2020-12/refRemote.json
new file mode 100644
index 0000000..047ac74
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/refRemote.json
@@ -0,0 +1,342 @@
+[
+ {
+ "description": "remote ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/subSchemas.json#/$defs/integer"
+ },
+ "tests": [
+ {
+ "description": "remote fragment valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "remote fragment invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "anchor within remote ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#foo"
+ },
+ "tests": [
+ {
+ "description": "remote anchor valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "remote anchor invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "ref within remote ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/subSchemas.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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/",
+ "items": {
+ "$id": "baseUriChange/",
+ "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/scope_change_defs1.json",
+ "type" : "object",
+ "properties": {"list": {"$ref": "baseUriChangeFolder/"}},
+ "$defs": {
+ "baz": {
+ "$id": "baseUriChangeFolder/",
+ "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/scope_change_defs2.json",
+ "type" : "object",
+ "properties": {"list": {"$ref": "baseUriChangeFolderInSubschema/#/$defs/bar"}},
+ "$defs": {
+ "baz": {
+ "$id": "baseUriChangeFolderInSubschema/",
+ "$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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "remote ref with ref to defs",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/schema-remote-ref-ref-defs1.json",
+ "$ref": "ref-and-defs.json"
+ },
+ "tests": [
+ {
+ "description": "invalid",
+ "data": {
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "valid",
+ "data": {
+ "bar": "a"
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "Location-independent identifier in remote ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/locationIndependentIdentifier.json#/$defs/refToInteger"
+ },
+ "tests": [
+ {
+ "description": "integer is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "string is invalid",
+ "data": "foo",
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "retrieved nested refs resolve relative to their URI not $id",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "http://localhost:1234/draft2020-12/some-id",
+ "properties": {
+ "name": {"$ref": "nested/foo-ref-string.json"}
+ }
+ },
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": {
+ "name": {"foo": 1}
+ },
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": {
+ "name": {"foo": "a"}
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with different $id",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/different-id-ref-string.json"
+ },
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with different URN $id",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/urn-ref-string.json"
+ },
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "remote HTTP ref with nested absolute ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"
+ },
+ "tests": [
+ {
+ "description": "number is invalid",
+ "data": 1,
+ "valid": false
+ },
+ {
+ "description": "string is valid",
+ "data": "foo",
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "$ref to $ref finds detached $anchor",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "http://localhost:1234/draft2020-12/detached-ref.json#/$defs/foo"
+ },
+ "tests": [
+ {
+ "description": "number is valid",
+ "data": 1,
+ "valid": true
+ },
+ {
+ "description": "non-number is invalid",
+ "data": "a",
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/required.json b/src/test/resources/json-schema-org/tests/draft2020-12/required.json
new file mode 100644
index 0000000..b7cb99a
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/required.json
@@ -0,0 +1,158 @@
+[
+ {
+ "description": "required validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "foo": {}
+ }
+ },
+ "tests": [
+ {
+ "description": "not required by default",
+ "data": {},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "required with empty array",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "foo": {}
+ },
+ "required": []
+ },
+ "tests": [
+ {
+ "description": "property not required",
+ "data": {},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "required with escaped characters",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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
+ }
+ ]
+ },
+ {
+ "description": "required properties whose names are Javascript object property names",
+ "comment": "Ensure JS implementations don't universally consider e.g. __proto__ to always be present in an object.",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "required": ["__proto__", "toString", "constructor"]
+ },
+ "tests": [
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores other non-objects",
+ "data": 12,
+ "valid": true
+ },
+ {
+ "description": "none of the properties mentioned",
+ "data": {},
+ "valid": false
+ },
+ {
+ "description": "__proto__ present",
+ "data": { "__proto__": "foo" },
+ "valid": false
+ },
+ {
+ "description": "toString present",
+ "data": { "toString": { "length": 37 } },
+ "valid": false
+ },
+ {
+ "description": "constructor present",
+ "data": { "constructor": { "length": 37 } },
+ "valid": false
+ },
+ {
+ "description": "all present",
+ "data": {
+ "__proto__": 12,
+ "toString": { "length": "foo" },
+ "constructor": 37
+ },
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/type.json b/src/test/resources/json-schema-org/tests/draft2020-12/type.json
new file mode 100644
index 0000000..2123c40
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/type.json
@@ -0,0 +1,501 @@
+[
+ {
+ "description": "integer type matches integers",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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/json-schema-org/tests/draft2020-12/unevaluatedItems.json b/src/test/resources/json-schema-org/tests/draft2020-12/unevaluatedItems.json
new file mode 100644
index 0000000..ee0cb65
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/unevaluatedItems.json
@@ -0,0 +1,799 @@
+[
+ {
+ "description": "unevaluatedItems true",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedItems": true
+ },
+ "tests": [
+ {
+ "description": "with no unevaluated items",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "with unevaluated items",
+ "data": ["foo"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems false",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "with no unevaluated items",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "with unevaluated items",
+ "data": ["foo"],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems as schema",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "items": { "type": "string" },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "unevaluatedItems doesn't apply",
+ "data": ["foo", "bar"],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with tuple",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "with no unevaluated items",
+ "data": ["foo"],
+ "valid": true
+ },
+ {
+ "description": "with unevaluated items",
+ "data": ["foo", "bar"],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with items and prefixItems",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "items": true,
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "unevaluatedItems doesn't apply",
+ "data": ["foo", 42],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with items",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "items": {"type": "number"},
+ "unevaluatedItems": {"type": "string"}
+ },
+ "tests": [
+ {
+ "description": "valid under items",
+ "comment": "no elements are considered by unevaluatedItems",
+ "data": [5, 6, 7, 8],
+ "valid": true
+ },
+ {
+ "description": "invalid under items",
+ "data": ["foo", "bar", "baz"],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with nested tuple",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "allOf": [
+ {
+ "prefixItems": [
+ true,
+ { "type": "number" }
+ ]
+ }
+ ],
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "with no unevaluated items",
+ "data": ["foo", 42],
+ "valid": true
+ },
+ {
+ "description": "with unevaluated items",
+ "data": ["foo", 42, true],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with nested items",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedItems": {"type": "boolean"},
+ "anyOf": [
+ { "items": {"type": "string"} },
+ true
+ ]
+ },
+ "tests": [
+ {
+ "description": "with only (valid) additional items",
+ "data": [true, false],
+ "valid": true
+ },
+ {
+ "description": "with no additional items",
+ "data": ["yes", "no"],
+ "valid": true
+ },
+ {
+ "description": "with invalid additional item",
+ "data": ["yes", false],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with nested prefixItems and items",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "items": 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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {
+ "prefixItems": [
+ { "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "const": "foo" }
+ ],
+ "anyOf": [
+ {
+ "prefixItems": [
+ true,
+ { "const": "bar" }
+ ]
+ },
+ {
+ "prefixItems": [
+ true,
+ true,
+ { "const": "baz" }
+ ]
+ }
+ ],
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "when one schema matches and has no unevaluated items",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "when one schema matches and has unevaluated items",
+ "data": ["foo", "bar", 42],
+ "valid": false
+ },
+ {
+ "description": "when two schemas match and has no unevaluated items",
+ "data": ["foo", "bar", "baz"],
+ "valid": true
+ },
+ {
+ "description": "when two schemas match and has unevaluated items",
+ "data": ["foo", "bar", "baz", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with oneOf",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "const": "foo" }
+ ],
+ "oneOf": [
+ {
+ "prefixItems": [
+ true,
+ { "const": "bar" }
+ ]
+ },
+ {
+ "prefixItems": [
+ true,
+ { "const": "baz" }
+ ]
+ }
+ ],
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "with no unevaluated items",
+ "data": ["foo", "bar"],
+ "valid": true
+ },
+ {
+ "description": "with unevaluated items",
+ "data": ["foo", "bar", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with not",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "const": "foo" }
+ ],
+ "not": {
+ "not": {
+ "prefixItems": [
+ true,
+ { "const": "bar" }
+ ]
+ }
+ },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "with unevaluated items",
+ "data": ["foo", "bar"],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with if/then/else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [
+ { "const": "foo" }
+ ],
+ "if": {
+ "prefixItems": [
+ true,
+ { "const": "bar" }
+ ]
+ },
+ "then": {
+ "prefixItems": [
+ true,
+ true,
+ { "const": "then" }
+ ]
+ },
+ "else": {
+ "prefixItems": [
+ true,
+ true,
+ true,
+ { "const": "else" }
+ ]
+ },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "when if matches and it has no unevaluated items",
+ "data": ["foo", "bar", "then"],
+ "valid": true
+ },
+ {
+ "description": "when if matches and it has unevaluated items",
+ "data": ["foo", "bar", "then", "else"],
+ "valid": false
+ },
+ {
+ "description": "when if doesn't match and it has no unevaluated items",
+ "data": ["foo", 42, 42, "else"],
+ "valid": true
+ },
+ {
+ "description": "when if doesn't match and it has unevaluated items",
+ "data": ["foo", 42, 42, "else", 42],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with boolean schemas",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$ref": "#/$defs/bar",
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "unevaluatedItems": false,
+ "$defs": {
+ "bar": {
+ "prefixItems": [
+ 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 before $ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedItems": false,
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "$ref": "#/$defs/bar",
+ "$defs": {
+ "bar": {
+ "prefixItems": [
+ 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 with $dynamicRef",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://example.com/unevaluated-items-with-dynamic-ref/derived",
+
+ "$ref": "./baseSchema",
+
+ "$defs": {
+ "derived": {
+ "$dynamicAnchor": "addons",
+ "prefixItems": [
+ true,
+ { "type": "string" }
+ ]
+ },
+ "baseSchema": {
+ "$id": "./baseSchema",
+
+ "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
+ "unevaluatedItems": false,
+ "type": "array",
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "$dynamicRef": "#addons",
+
+ "$defs": {
+ "defaultAddons": {
+ "$comment": "Needed to satisfy the bookending requirement",
+ "$dynamicAnchor": "addons"
+ }
+ }
+ }
+ }
+ },
+ "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {
+ "prefixItems": [ true ]
+ },
+ { "unevaluatedItems": false }
+ ]
+ },
+ "tests": [
+ {
+ "description": "always fails",
+ "data": [ 1 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "item is evaluated in an uncle schema to unevaluatedItems",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "properties": {
+ "foo": {
+ "prefixItems": [
+ { "type": "string" }
+ ],
+ "unevaluatedItems": false
+ }
+ },
+ "anyOf": [
+ {
+ "properties": {
+ "foo": {
+ "prefixItems": [
+ true,
+ { "type": "string" }
+ ]
+ }
+ }
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "no extra items",
+ "data": {
+ "foo": [
+ "test"
+ ]
+ },
+ "valid": true
+ },
+ {
+ "description": "uncle keyword evaluation is not significant",
+ "data": {
+ "foo": [
+ "test",
+ "test"
+ ]
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems depends on adjacent contains",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [true],
+ "contains": {"type": "string"},
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "second item is evaluated by contains",
+ "data": [ 1, "foo" ],
+ "valid": true
+ },
+ {
+ "description": "contains fails, second item is not evaluated",
+ "data": [ 1, 2 ],
+ "valid": false
+ },
+ {
+ "description": "contains passes, second item is not evaluated",
+ "data": [ 1, 2, "foo" ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems depends on multiple nested contains",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ { "contains": { "multipleOf": 2 } },
+ { "contains": { "multipleOf": 3 } }
+ ],
+ "unevaluatedItems": { "multipleOf": 5 }
+ },
+ "tests": [
+ {
+ "description": "5 not evaluated, passes unevaluatedItems",
+ "data": [ 2, 3, 4, 5, 6 ],
+ "valid": true
+ },
+ {
+ "description": "7 not evaluated, fails unevaluatedItems",
+ "data": [ 2, 3, 4, 7, 8 ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems and contains interact to control item dependency relationship",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "if": {
+ "contains": {"const": "a"}
+ },
+ "then": {
+ "if": {
+ "contains": {"const": "b"}
+ },
+ "then": {
+ "if": {
+ "contains": {"const": "c"}
+ }
+ }
+ },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "empty array is valid",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "only a's are valid",
+ "data": [ "a", "a" ],
+ "valid": true
+ },
+ {
+ "description": "a's and b's are valid",
+ "data": [ "a", "b", "a", "b", "a" ],
+ "valid": true
+ },
+ {
+ "description": "a's, b's and c's are valid",
+ "data": [ "c", "a", "c", "c", "b", "a" ],
+ "valid": true
+ },
+ {
+ "description": "only b's are invalid",
+ "data": [ "b", "b" ],
+ "valid": false
+ },
+ {
+ "description": "only c's are invalid",
+ "data": [ "c", "c" ],
+ "valid": false
+ },
+ {
+ "description": "only b's and c's are invalid",
+ "data": [ "c", "b", "c", "b", "c" ],
+ "valid": false
+ },
+ {
+ "description": "only a's and c's are invalid",
+ "data": [ "c", "a", "c", "a", "c" ],
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "non-array instances are valid",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "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 strings",
+ "data": "foo",
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems with null instance elements",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedItems": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null elements",
+ "data": [ null ],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedItems can see annotations from if without then and else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "if": {
+ "prefixItems": [{"const": "a"}]
+ },
+ "unevaluatedItems": false
+ },
+ "tests": [
+ {
+ "description": "valid in case if is evaluated",
+ "data": [ "a" ],
+ "valid": true
+ },
+ {
+ "description": "invalid in case if is evaluated",
+ "data": [ "b" ],
+ "valid": false
+ }
+
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/unevaluatedProperties.json b/src/test/resources/json-schema-org/tests/draft2020-12/unevaluatedProperties.json
new file mode 100644
index 0000000..b8a2306
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/unevaluatedProperties.json
@@ -0,0 +1,1568 @@
+[
+ {
+ "description": "unevaluatedProperties true",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 not",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "not": {
+ "not": {
+ "properties": {
+ "bar": { "const": "bar" }
+ },
+ "required": ["bar"]
+ }
+ },
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "with unevaluated properties",
+ "data": {
+ "foo": "foo",
+ "bar": "bar"
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties with if/then/else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 if/then/else, then not defined",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "if": {
+ "properties": {
+ "foo": { "const": "then" }
+ },
+ "required": ["foo"]
+ },
+ "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": false
+ },
+ {
+ "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 if/then/else, else not defined",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "if": {
+ "properties": {
+ "foo": { "const": "then" }
+ },
+ "required": ["foo"]
+ },
+ "then": {
+ "properties": {
+ "bar": { "type": "string" }
+ },
+ "required": ["bar"]
+ },
+ "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": false
+ },
+ {
+ "description": "when if is false and has unevaluated properties",
+ "data": {
+ "foo": "else",
+ "baz": "baz"
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties with dependentSchemas",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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 before $ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "unevaluatedProperties": false,
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "$ref": "#/$defs/bar",
+ "$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 with $dynamicRef",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived",
+
+ "$ref": "./baseSchema",
+
+ "$defs": {
+ "derived": {
+ "$dynamicAnchor": "addons",
+ "properties": {
+ "bar": { "type": "string" }
+ }
+ },
+ "baseSchema": {
+ "$id": "./baseSchema",
+
+ "$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
+ "unevaluatedProperties": false,
+ "type": "object",
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "$dynamicRef": "#addons",
+
+ "$defs": {
+ "defaultAddons": {
+ "$comment": "Needed to satisfy the bookending requirement",
+ "$dynamicAnchor": "addons"
+ }
+ }
+ }
+ }
+ },
+ "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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {
+ "properties": {
+ "foo": true
+ }
+ },
+ {
+ "unevaluatedProperties": false
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "always fails",
+ "data": {
+ "foo": 1
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties can't see inside cousins (reverse order)",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "allOf": [
+ {
+ "unevaluatedProperties": false
+ },
+ {
+ "properties": {
+ "foo": true
+ }
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "always fails",
+ "data": {
+ "foo": 1
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "nested unevaluatedProperties, outer false, inner true, properties outside",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "allOf": [
+ {
+ "unevaluatedProperties": true
+ }
+ ],
+ "unevaluatedProperties": false
+ },
+ "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": "nested unevaluatedProperties, outer false, inner true, properties inside",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "allOf": [
+ {
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "unevaluatedProperties": true
+ }
+ ],
+ "unevaluatedProperties": false
+ },
+ "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": "nested unevaluatedProperties, outer true, inner false, properties outside",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "allOf": [
+ {
+ "unevaluatedProperties": false
+ }
+ ],
+ "unevaluatedProperties": true
+ },
+ "tests": [
+ {
+ "description": "with no nested unevaluated properties",
+ "data": {
+ "foo": "foo"
+ },
+ "valid": false
+ },
+ {
+ "description": "with nested unevaluated properties",
+ "data": {
+ "foo": "foo",
+ "bar": "bar"
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "nested unevaluatedProperties, outer true, inner false, properties inside",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "allOf": [
+ {
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "unevaluatedProperties": false
+ }
+ ],
+ "unevaluatedProperties": true
+ },
+ "tests": [
+ {
+ "description": "with no nested unevaluated properties",
+ "data": {
+ "foo": "foo"
+ },
+ "valid": true
+ },
+ {
+ "description": "with nested unevaluated properties",
+ "data": {
+ "foo": "foo",
+ "bar": "bar"
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "cousin unevaluatedProperties, true and false, true with properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "allOf": [
+ {
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "unevaluatedProperties": true
+ },
+ {
+ "unevaluatedProperties": false
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "with no nested unevaluated properties",
+ "data": {
+ "foo": "foo"
+ },
+ "valid": false
+ },
+ {
+ "description": "with nested unevaluated properties",
+ "data": {
+ "foo": "foo",
+ "bar": "bar"
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "cousin unevaluatedProperties, true and false, false with properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "allOf": [
+ {
+ "unevaluatedProperties": true
+ },
+ {
+ "properties": {
+ "foo": { "type": "string" }
+ },
+ "unevaluatedProperties": false
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "with no nested unevaluated properties",
+ "data": {
+ "foo": "foo"
+ },
+ "valid": true
+ },
+ {
+ "description": "with nested unevaluated properties",
+ "data": {
+ "foo": "foo",
+ "bar": "bar"
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "property is evaluated in an uncle schema to unevaluatedProperties",
+ "comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "properties": {
+ "foo": {
+ "type": "object",
+ "properties": {
+ "bar": {
+ "type": "string"
+ }
+ },
+ "unevaluatedProperties": false
+ }
+ },
+ "anyOf": [
+ {
+ "properties": {
+ "foo": {
+ "properties": {
+ "faz": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "no extra properties",
+ "data": {
+ "foo": {
+ "bar": "test"
+ }
+ },
+ "valid": true
+ },
+ {
+ "description": "uncle keyword evaluation is not significant",
+ "data": {
+ "foo": {
+ "bar": "test",
+ "faz": "test"
+ }
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "in-place applicator siblings, allOf has unevaluated",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "allOf": [
+ {
+ "properties": {
+ "foo": true
+ },
+ "unevaluatedProperties": false
+ }
+ ],
+ "anyOf": [
+ {
+ "properties": {
+ "bar": true
+ }
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "base case: both properties present",
+ "data": {
+ "foo": 1,
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "in place applicator siblings, bar is missing",
+ "data": {
+ "foo": 1
+ },
+ "valid": true
+ },
+ {
+ "description": "in place applicator siblings, foo is missing",
+ "data": {
+ "bar": 1
+ },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "in-place applicator siblings, anyOf has unevaluated",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "allOf": [
+ {
+ "properties": {
+ "foo": true
+ }
+ }
+ ],
+ "anyOf": [
+ {
+ "properties": {
+ "bar": true
+ },
+ "unevaluatedProperties": false
+ }
+ ]
+ },
+ "tests": [
+ {
+ "description": "base case: both properties present",
+ "data": {
+ "foo": 1,
+ "bar": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "in place applicator siblings, bar is missing",
+ "data": {
+ "foo": 1
+ },
+ "valid": false
+ },
+ {
+ "description": "in place applicator siblings, foo is missing",
+ "data": {
+ "bar": 1
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties + single cyclic ref",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "type": "object",
+ "properties": {
+ "x": { "$ref": "#" }
+ },
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "Empty is valid",
+ "data": {},
+ "valid": true
+ },
+ {
+ "description": "Single is valid",
+ "data": { "x": {} },
+ "valid": true
+ },
+ {
+ "description": "Unevaluated on 1st level is invalid",
+ "data": { "x": {}, "y": {} },
+ "valid": false
+ },
+ {
+ "description": "Nested is valid",
+ "data": { "x": { "x": {} } },
+ "valid": true
+ },
+ {
+ "description": "Unevaluated on 2nd level is invalid",
+ "data": { "x": { "x": {}, "y": {} } },
+ "valid": false
+ },
+ {
+ "description": "Deep nested is valid",
+ "data": { "x": { "x": { "x": {} } } },
+ "valid": true
+ },
+ {
+ "description": "Unevaluated on 3rd level is invalid",
+ "data": { "x": { "x": { "x": {}, "y": {} } } },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties + ref inside allOf / oneOf",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "one": {
+ "properties": { "a": true }
+ },
+ "two": {
+ "required": ["x"],
+ "properties": { "x": true }
+ }
+ },
+ "allOf": [
+ { "$ref": "#/$defs/one" },
+ { "properties": { "b": true } },
+ {
+ "oneOf": [
+ { "$ref": "#/$defs/two" },
+ {
+ "required": ["y"],
+ "properties": { "y": true }
+ }
+ ]
+ }
+ ],
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "Empty is invalid (no x or y)",
+ "data": {},
+ "valid": false
+ },
+ {
+ "description": "a and b are invalid (no x or y)",
+ "data": { "a": 1, "b": 1 },
+ "valid": false
+ },
+ {
+ "description": "x and y are invalid",
+ "data": { "x": 1, "y": 1 },
+ "valid": false
+ },
+ {
+ "description": "a and x are valid",
+ "data": { "a": 1, "x": 1 },
+ "valid": true
+ },
+ {
+ "description": "a and y are valid",
+ "data": { "a": 1, "y": 1 },
+ "valid": true
+ },
+ {
+ "description": "a and b and x are valid",
+ "data": { "a": 1, "b": 1, "x": 1 },
+ "valid": true
+ },
+ {
+ "description": "a and b and y are valid",
+ "data": { "a": 1, "b": 1, "y": 1 },
+ "valid": true
+ },
+ {
+ "description": "a and b and x and y are invalid",
+ "data": { "a": 1, "b": 1, "x": 1, "y": 1 },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "dynamic evalation inside nested refs",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "$defs": {
+ "one": {
+ "oneOf": [
+ { "$ref": "#/$defs/two" },
+ { "required": ["b"], "properties": { "b": true } },
+ { "required": ["xx"], "patternProperties": { "x": true } },
+ { "required": ["all"], "unevaluatedProperties": true }
+ ]
+ },
+ "two": {
+ "oneOf": [
+ { "required": ["c"], "properties": { "c": true } },
+ { "required": ["d"], "properties": { "d": true } }
+ ]
+ }
+ },
+ "oneOf": [
+ { "$ref": "#/$defs/one" },
+ { "required": ["a"], "properties": { "a": true } }
+ ],
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "Empty is invalid",
+ "data": {},
+ "valid": false
+ },
+ {
+ "description": "a is valid",
+ "data": { "a": 1 },
+ "valid": true
+ },
+ {
+ "description": "b is valid",
+ "data": { "b": 1 },
+ "valid": true
+ },
+ {
+ "description": "c is valid",
+ "data": { "c": 1 },
+ "valid": true
+ },
+ {
+ "description": "d is valid",
+ "data": { "d": 1 },
+ "valid": true
+ },
+ {
+ "description": "a + b is invalid",
+ "data": { "a": 1, "b": 1 },
+ "valid": false
+ },
+ {
+ "description": "a + c is invalid",
+ "data": { "a": 1, "c": 1 },
+ "valid": false
+ },
+ {
+ "description": "a + d is invalid",
+ "data": { "a": 1, "d": 1 },
+ "valid": false
+ },
+ {
+ "description": "b + c is invalid",
+ "data": { "b": 1, "c": 1 },
+ "valid": false
+ },
+ {
+ "description": "b + d is invalid",
+ "data": { "b": 1, "d": 1 },
+ "valid": false
+ },
+ {
+ "description": "c + d is invalid",
+ "data": { "c": 1, "d": 1 },
+ "valid": false
+ },
+ {
+ "description": "xx is valid",
+ "data": { "xx": 1 },
+ "valid": true
+ },
+ {
+ "description": "xx + foox is valid",
+ "data": { "xx": 1, "foox": 1 },
+ "valid": true
+ },
+ {
+ "description": "xx + foo is invalid",
+ "data": { "xx": 1, "foo": 1 },
+ "valid": false
+ },
+ {
+ "description": "xx + a is invalid",
+ "data": { "xx": 1, "a": 1 },
+ "valid": false
+ },
+ {
+ "description": "xx + b is invalid",
+ "data": { "xx": 1, "b": 1 },
+ "valid": false
+ },
+ {
+ "description": "xx + c is invalid",
+ "data": { "xx": 1, "c": 1 },
+ "valid": false
+ },
+ {
+ "description": "xx + d is invalid",
+ "data": { "xx": 1, "d": 1 },
+ "valid": false
+ },
+ {
+ "description": "all is valid",
+ "data": { "all": 1 },
+ "valid": true
+ },
+ {
+ "description": "all + foo is valid",
+ "data": { "all": 1, "foo": 1 },
+ "valid": true
+ },
+ {
+ "description": "all + a is invalid",
+ "data": { "all": 1, "a": 1 },
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "non-object instances are valid",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "ignores booleans",
+ "data": true,
+ "valid": true
+ },
+ {
+ "description": "ignores integers",
+ "data": 123,
+ "valid": true
+ },
+ {
+ "description": "ignores floats",
+ "data": 1.0,
+ "valid": true
+ },
+ {
+ "description": "ignores arrays",
+ "data": [],
+ "valid": true
+ },
+ {
+ "description": "ignores strings",
+ "data": "foo",
+ "valid": true
+ },
+ {
+ "description": "ignores null",
+ "data": null,
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties with null valued instance properties",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "unevaluatedProperties": {
+ "type": "null"
+ }
+ },
+ "tests": [
+ {
+ "description": "allows null valued properties",
+ "data": {"foo": null},
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties not affected by propertyNames",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "propertyNames": {"maxLength": 1},
+ "unevaluatedProperties": {
+ "type": "number"
+ }
+ },
+ "tests": [
+ {
+ "description": "allows only number properties",
+ "data": {"a": 1},
+ "valid": true
+ },
+ {
+ "description": "string property is invalid",
+ "data": {"a": "b"},
+ "valid": false
+ }
+ ]
+ },
+ {
+ "description": "unevaluatedProperties can see annotations from if without then and else",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "if": {
+ "patternProperties": {
+ "foo": {
+ "type": "string"
+ }
+ }
+ },
+ "unevaluatedProperties": false
+ },
+ "tests": [
+ {
+ "description": "valid in case if is evaluated",
+ "data": {
+ "foo": "a"
+ },
+ "valid": true
+ },
+ {
+ "description": "invalid in case if is evaluated",
+ "data": {
+ "bar": "a"
+ },
+ "valid": false
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft2020-12/uniqueItems.json b/src/test/resources/json-schema-org/tests/draft2020-12/uniqueItems.json
new file mode 100644
index 0000000..4ea3bf9
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/uniqueItems.json
@@ -0,0 +1,419 @@
+[
+ {
+ "description": "uniqueItems validation",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": "non-unique array of more than two integers is invalid",
+ "data": [1, 2, 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 strings is valid",
+ "data": ["foo", "bar", "baz"],
+ "valid": true
+ },
+ {
+ "description": "non-unique array of strings is invalid",
+ "data": ["foo", "bar", "foo"],
+ "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": "property order of array of objects is ignored",
+ "data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "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": "non-unique array of more than two arrays is invalid",
+ "data": [["foo"], ["bar"], ["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": "{\"a\": false} and {\"a\": 0} are unique",
+ "data": [{"a": false}, {"a": 0}],
+ "valid": true
+ },
+ {
+ "description": "{\"a\": true} and {\"a\": 1} are unique",
+ "data": [{"a": true}, {"a": 1}],
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "uniqueItems with an array of items",
+ "schema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{"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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": true,
+ "items": 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": {
+ "$schema": "https://json-schema.org/draft/2020-12/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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{"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": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "prefixItems": [{"type": "boolean"}, {"type": "boolean"}],
+ "uniqueItems": false,
+ "items": 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/json-schema-org/tests/draft2020-12/vocabulary.json b/src/test/resources/json-schema-org/tests/draft2020-12/vocabulary.json
new file mode 100644
index 0000000..1acb96a
--- /dev/null
+++ b/src/test/resources/json-schema-org/tests/draft2020-12/vocabulary.json
@@ -0,0 +1,57 @@
+[
+ {
+ "description": "schema that uses custom metaschema with with no validation vocabulary",
+ "schema": {
+ "$id": "https://schema/using/no/validation",
+ "$schema": "http://localhost:1234/draft2020-12/metaschema-no-validation.json",
+ "properties": {
+ "badProperty": false,
+ "numberProperty": {
+ "minimum": 10
+ }
+ }
+ },
+ "tests": [
+ {
+ "description": "applicator vocabulary still works",
+ "data": {
+ "badProperty": "this property should not exist"
+ },
+ "valid": false
+ },
+ {
+ "description": "no validation: valid number",
+ "data": {
+ "numberProperty": 20
+ },
+ "valid": true
+ },
+ {
+ "description": "no validation: invalid number, but it still validates",
+ "data": {
+ "numberProperty": 1
+ },
+ "valid": true
+ }
+ ]
+ },
+ {
+ "description": "ignore unrecognized optional vocabulary",
+ "schema": {
+ "$schema": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json",
+ "type": "number"
+ },
+ "tests": [
+ {
+ "description": "string value",
+ "data": "foobar",
+ "valid": false
+ },
+ {
+ "description": "number value",
+ "data": 20,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/src/test/resources/json-schema-org/tests/draft6/refRemote.json b/src/test/resources/json-schema-org/tests/draft6/refRemote.json
index c2b2002..cdaadfd 100644
--- a/src/test/resources/json-schema-org/tests/draft6/refRemote.json
+++ b/src/test/resources/json-schema-org/tests/draft6/refRemote.json
@@ -1,105 +1,4 @@
[
- {
- "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": "baseUriChange/",
- "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": "baseUriChangeFolder/",
- "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": {
@@ -125,114 +24,6 @@
"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
- }
- ]
- },
- {
- "description": "remote ref with ref to definitions",
- "schema": {
- "$id": "http://localhost:1234/schema-remote-ref-ref-defs1.json",
- "allOf": [
- { "$ref": "ref-and-definitions.json" }
- ]
- },
- "tests": [
- {
- "description": "invalid",
- "data": {
- "bar": 1
- },
- "valid": false
- },
- {
- "description": "valid",
- "data": {
- "bar": "a"
- },
- "valid": true
- }
- ]
- },
- {
- "description": "Location-independent identifier in remote ref",
- "schema": {
- "$ref": "http://localhost:1234/locationIndependentIdentifierPre2019.json#/definitions/refToInteger"
- },
- "tests": [
- {
- "description": "integer is valid",
- "data": 1,
- "valid": true
- },
- {
- "description": "string is invalid",
- "data": "foo",
- "valid": false
- }
- ]
- },
- {
- "description": "retrieved nested refs resolve relative to their URI not $id",
- "schema": {
- "$id": "http://localhost:1234/some-id",
- "properties": {
- "name": {"$ref": "nested/foo-ref-string.json"}
- }
- },
- "tests": [
- {
- "description": "number is invalid",
- "data": {
- "name": {"foo": 1}
- },
- "valid": false
- },
- {
- "description": "string is valid",
- "data": {
- "name": {"foo": "a"}
- },
- "valid": true
}
]
}