diff --git a/pom.xml b/pom.xml
index 798bcac..a324280 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
es.elixir.bsc.json.schema
jaronuinga
- 0.5.3
+ 0.5.4
jar
diff --git a/src/main/java/es/elixir/bsc/json/schema/ValidationError.java b/src/main/java/es/elixir/bsc/json/schema/ValidationError.java
index 950fd3b..0cf7245 100644
--- a/src/main/java/es/elixir/bsc/json/schema/ValidationError.java
+++ b/src/main/java/es/elixir/bsc/json/schema/ValidationError.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
@@ -39,16 +39,15 @@ public class ValidationError {
public final String path;
public final String message;
- public ValidationError(final String message) {
+ public ValidationError(String message) {
this(null, null, null, message);
}
- public ValidationError(final URI id, final String pointer, final String message) {
+ public ValidationError(URI id, String pointer, String message) {
this(id, pointer, null, message);
}
- public ValidationError(final URI id, final String pointer,
- final String path, final String message) {
+ public ValidationError(URI id, String pointer, String path, String message) {
this.code = -1;
this.id = id;
@@ -57,8 +56,8 @@ public ValidationError(final URI id, final String pointer,
this.message = message;
}
- public ValidationError(final URI id, final String pointer,
- final String path, final ValidationMessage message, Object... args) {
+ public ValidationError(URI id, String pointer, String path,
+ ValidationMessage message, Object... args) {
this.code = message.CODE;
this.id = id;
diff --git a/src/main/java/es/elixir/bsc/json/schema/ValidationMessage.java b/src/main/java/es/elixir/bsc/json/schema/ValidationMessage.java
index 96cd661..de07453 100644
--- a/src/main/java/es/elixir/bsc/json/schema/ValidationMessage.java
+++ b/src/main/java/es/elixir/bsc/json/schema/ValidationMessage.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
@@ -97,7 +97,7 @@ public enum ValidationMessage {
public final int CODE;
public final String VALUE;
- private ValidationMessage(final int code, final String value) {
+ private ValidationMessage(int code, String value) {
CODE = code;
VALUE = value;
}
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 0005839..fa0ed22 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
@@ -52,6 +52,7 @@
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.io.IOException;
import java.util.Map;
import javax.json.JsonArray;
import javax.json.JsonObject;
@@ -83,7 +84,7 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
if (value.getValueType() == ValueType.TRUE ||
value.getValueType() == ValueType.FALSE) {
- return new BooleanJsonSchemaImpl(parent, locator, jsonPointer).read(this, value, type);
+ return new BooleanJsonSchemaImpl(parent, locator, jsonPointer).read(this, value);
}
if (value.getValueType() != ValueType.OBJECT) {
@@ -101,8 +102,8 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
}
// before draft 2019-09 $ref ignored any other properties
- if (JsonSchemaVersion.SCHEMA_DRAFT_2019_09.compareTo(getJsonSchemaVersion(object)) > 0) {
- return new JsonReferenceImpl(parent, locator, jsonPointer).read(this, object, null);
+ if (JsonSchemaVersion.SCHEMA_DRAFT_2019_09.compareTo(getJsonSchemaVersion(locator)) > 0) {
+ return new JsonReferenceImpl(parent, locator, jsonPointer).read(this, object);
}
}
@@ -110,12 +111,12 @@ 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 {
- type = JsonType.fromValue(((JsonString)type_value).getString());
+ type = JsonType.fromValue(((JsonString)type_value).getString());
} catch(IllegalArgumentException ex) {
throw new JsonSchemaException(new ParsingError(
ParsingMessage.UNKNOWN_OBJECT_TYPE, ((JsonString)type_value).getString()));
@@ -134,29 +135,29 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
if (jenum.isEmpty()) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.EMPTY_ENUM));
}
- return new JsonEnumImpl(parent, locator, jsonPointer).read(this, object, type);
+ return new JsonEnumImpl(parent, locator, jsonPointer).read(this, object);
}
final JsonValue jconst = object.get(CONST);
if (jconst != null) {
- return new JsonConstImpl(parent, locator, jsonPointer).read(this, object, type);
+ return new JsonConstImpl(parent, locator, jsonPointer).read(this, object);
}
if (type == null) {
return new JsonMultitypeSchemaWrapper(parent, locator, jsonPointer,
vtype == ValueType.ARRAY ? type_value.asJsonArray() : null)
- .read(this, object, null);
+ .read(this, object);
}
final AbstractJsonSchema schema;
switch(type) {
- case OBJECT: schema = new JsonObjectSchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
- case ARRAY: schema = new JsonArraySchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
- case STRING: schema = new JsonStringSchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
- case NUMBER: schema = new JsonNumberSchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
- case INTEGER: schema = new JsonIntegerSchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
- case BOOLEAN: schema = new JsonBooleanSchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
- case NULL: schema = new JsonNullSchemaImpl(parent, locator, jsonPointer).read(this, object, type); break;
+ case OBJECT: schema = new JsonObjectSchemaImpl(parent, locator, jsonPointer).read(this, object); break;
+ case ARRAY: schema = new JsonArraySchemaImpl(parent, locator, jsonPointer).read(this, object); break;
+ case STRING: schema = new JsonStringSchemaImpl(parent, locator, jsonPointer).read(this, object); break;
+ case NUMBER: schema = new JsonNumberSchemaImpl(parent, locator, jsonPointer).read(this, object); break;
+ case INTEGER: schema = new JsonIntegerSchemaImpl(parent, locator, jsonPointer).read(this, object); break;
+ case BOOLEAN: schema = new JsonBooleanSchemaImpl(parent, locator, jsonPointer).read(this, object); break;
+ case NULL: schema = new JsonNullSchemaImpl(parent, locator, jsonPointer).read(this, object); break;
default: return null;
}
@@ -164,13 +165,19 @@ public AbstractJsonSchema parse(JsonSchemaLocator locator, AbstractJsonSchemaEle
}
@Override
- public JsonSchemaVersion getJsonSchemaVersion(JsonObject object) {
- final JsonValue jversion = object.get(JsonSchema.SCHEMA);
- if (jversion != null && jversion.getValueType() == JsonValue.ValueType.STRING) {
- try {
- return JsonSchemaVersion.fromValue(((JsonString)jversion).getString());
- } catch(IllegalArgumentException ex) {}
- }
+ public JsonSchemaVersion getJsonSchemaVersion(JsonSchemaLocator locator) {
+ final JsonValue schema;
+ try {
+ schema = locator.getSchema("/");
+ if (JsonValue.ValueType.OBJECT == schema.getValueType()) {
+ final JsonValue jversion = schema.asJsonObject().get(JsonSchema.SCHEMA);
+ if (jversion != null && jversion.getValueType() == JsonValue.ValueType.STRING) {
+ try {
+ return JsonSchemaVersion.fromValue(((JsonString)jversion).getString());
+ } catch(IllegalArgumentException ex) {}
+ }
+ }
+ } catch (IOException ex) {}
final Object version = properties.get(JsonSchemaParserConfig.JSON_SCHEMA_VERSION);
if (version instanceof JsonSchemaVersion) {
@@ -179,4 +186,5 @@ public JsonSchemaVersion getJsonSchemaVersion(JsonObject object) {
return JsonSchemaVersion.SCHEMA_DRAFT_07; // default
}
+
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonStringFormatValidator.java b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonStringFormatValidator.java
index 666212e..11e7c1a 100644
--- a/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonStringFormatValidator.java
+++ b/src/main/java/es/elixir/bsc/json/schema/impl/DefaultJsonStringFormatValidator.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
@@ -45,9 +45,8 @@ public class DefaultJsonStringFormatValidator implements JsonStringFormatValidat
private final static Pattern IP4_PATTERN = Pattern.compile("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
private final static Pattern IP6_PATTERN = Pattern.compile("^((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*::((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4}))*|((?:[0-9A-Fa-f]{1,4}))((?::[0-9A-Fa-f]{1,4})){7}$");
- public static void validate(final String jsonPointer,
- final JsonStringSchema schema,
- final String value) throws ValidationException {
+ public static void validate(String jsonPointer, JsonStringSchema schema,
+ String value) throws ValidationException {
final String format = schema.getFormat();
switch(format) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/impl/JsonSubschemaParser.java b/src/main/java/es/elixir/bsc/json/schema/impl/JsonSubschemaParser.java
index de0bde7..a940d23 100644
--- a/src/main/java/es/elixir/bsc/json/schema/impl/JsonSubschemaParser.java
+++ b/src/main/java/es/elixir/bsc/json/schema/impl/JsonSubschemaParser.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.model.impl.AbstractJsonSchema;
import es.elixir.bsc.json.schema.model.impl.AbstractJsonSchemaElement;
import java.util.Map;
-import javax.json.JsonObject;
import javax.json.JsonValue;
/**
@@ -56,7 +55,7 @@ public interface JsonSubschemaParser extends JsonSchemaParser {
*/
Map getJsonSchemaParserProperties();
- JsonSchemaVersion getJsonSchemaVersion(JsonObject object);
+ JsonSchemaVersion getJsonSchemaVersion(JsonSchemaLocator locator);
@Override
default AbstractJsonSchema parse(JsonSchemaLocator locator, JsonValue schema)
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 5849ac4..645708f 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
@@ -35,7 +35,6 @@
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;
@@ -62,8 +61,8 @@ public AbstractJsonReferenceImpl(AbstractJsonSchemaElement parent, JsonSchemaLoc
super(parent, locator, jsonPointer);
}
- protected void read(JsonSubschemaParser parser, JsonObject object,
- JsonType type, String tag) throws JsonSchemaException {
+ protected void read(JsonSubschemaParser parser, JsonObject object, String tag)
+ throws JsonSchemaException {
this.parser = parser;
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 606cf28..a3c8534 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
@@ -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.ValidationException;
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 java.util.ArrayList;
import java.util.List;
import javax.json.JsonValue;
@@ -54,8 +53,8 @@ public AbstractJsonSchema(AbstractJsonSchemaElement parent, JsonSchemaLocator lo
super(parent, locator, jsonPointer);
}
- public AbstractJsonSchema read(JsonSubschemaParser parser, T value,
- JsonType type) throws JsonSchemaException {
+ public AbstractJsonSchema read(JsonSubschemaParser parser, T value)
+ throws JsonSchemaException {
return this;
}
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 830f005..41f5207 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
@@ -36,7 +36,6 @@
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import es.elixir.bsc.json.schema.model.BooleanJsonSchema;
import es.elixir.bsc.json.schema.model.JsonSchemaElement;
-import es.elixir.bsc.json.schema.model.JsonType;
import javax.json.JsonValue;
import javax.json.JsonValue.ValueType;
import java.util.List;
@@ -62,9 +61,8 @@ public Stream getChildren() {
}
@Override
- public BooleanJsonSchemaImpl read(final JsonSubschemaParser parser,
- final JsonValue schema,
- final JsonType type) throws JsonSchemaException {
+ public BooleanJsonSchemaImpl read(JsonSubschemaParser parser, JsonValue schema)
+ throws JsonSchemaException {
if (schema.getValueType() != ValueType.TRUE &&
schema.getValueType() != ValueType.FALSE) {
@@ -78,7 +76,10 @@ public BooleanJsonSchemaImpl read(final JsonSubschemaParser parser,
}
@Override
- public boolean validate(String jsonPointer, JsonValue value, JsonValue parent, List evaluated, List errors, JsonSchemaValidationCallback callback) throws ValidationException {
+ public boolean validate(String jsonPointer, JsonValue value, JsonValue parent,
+ List evaluated, List errors, JsonSchemaValidationCallback callback)
+ throws ValidationException {
+
if (!evaluation) {
errors.add(new ValidationError(getId(), getJsonPointer(), jsonPointer,
ValidationMessage.UNEVALUATED_BOOLEAN_SCHEMA_MSG));
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 9b2bf34..b3259e0 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
@@ -33,7 +33,6 @@
import java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
-import es.elixir.bsc.json.schema.model.JsonType;
import javax.json.JsonValue;
import java.util.ArrayList;
import javax.json.JsonArray;
@@ -51,11 +50,10 @@ public JsonAllOfImpl(AbstractJsonSchema parent, JsonSchemaLocator locator,
}
@Override
- public JsonAllOfImpl read(final JsonSubschemaParser parser,
- final JsonArray schema,
- final JsonType type) throws JsonSchemaException {
+ public JsonAllOfImpl read(JsonSubschemaParser parser, JsonArray schema)
+ throws JsonSchemaException {
- super.read(parser, schema, type);
+ super.read(parser, schema);
return this;
}
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 aae3683..7f77f03 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
@@ -35,7 +35,6 @@
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
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.JsonValue;
/**
@@ -53,10 +52,10 @@ public JsonAnyOfImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator locator
}
@Override
- public JsonAnyOfImpl read(final JsonSubschemaParser parser,
- final T value,
- final JsonType type) throws JsonSchemaException {
- super.read(parser, value, type);
+ public JsonAnyOfImpl read(JsonSubschemaParser parser, T value)
+ throws JsonSchemaException {
+
+ super.read(parser, value);
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 e3fc7f4..f339715 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
@@ -33,7 +33,6 @@
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.model.JsonType;
import java.util.ArrayList;
import java.util.List;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
@@ -148,11 +147,10 @@ public Long getMaxContains() {
}
@Override
- public JsonArraySchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonArraySchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonNumber min = JsonSchemaUtil.check(object.getJsonNumber(MIN_ITEMS), JsonValue.ValueType.NUMBER);
if (min != null) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonBooleanSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonBooleanSchemaImpl.java
index 55cbebf..94e24f4 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonBooleanSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonBooleanSchemaImpl.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 java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
import es.elixir.bsc.json.schema.ValidationMessage;
-import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import javax.json.JsonObject;
import javax.json.JsonValue;
@@ -50,11 +49,10 @@ public JsonBooleanSchemaImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator
}
@Override
- public JsonBooleanSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonBooleanSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
return this;
}
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 afe0a02..f184e4d 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
@@ -32,7 +32,6 @@
import es.elixir.bsc.json.schema.ValidationMessage;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import es.elixir.bsc.json.schema.model.JsonConst;
-import es.elixir.bsc.json.schema.model.JsonType;
import javax.json.JsonObject;
import javax.json.JsonValue;
import java.util.List;
@@ -62,11 +61,10 @@ public void setValue(JsonValue value) {
}
@Override
- public JsonConstImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonConstImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
value = object.get(CONST);
@@ -86,7 +84,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;
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
index d49e6f2..3dbbeea 100644
--- 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
@@ -32,7 +32,6 @@
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;
@@ -107,9 +106,9 @@ private AbstractJsonSchemaElement getSchema(AbstractJsonSchemaElement e, URI uri
@Override
public JsonDynamicReferenceImpl read(JsonSubschemaParser parser,
- JsonObject object, JsonType type) throws JsonSchemaException {
+ JsonObject object) throws JsonSchemaException {
- super.read(parser, object, type, DYNAMIC_REF);
+ super.read(parser, object, DYNAMIC_REF);
return this;
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonEnumImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonEnumImpl.java
index 755a0a5..91f4bbe 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonEnumImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonEnumImpl.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
@@ -31,7 +31,6 @@
import es.elixir.bsc.json.schema.ValidationError;
import es.elixir.bsc.json.schema.ValidationMessage;
import es.elixir.bsc.json.schema.model.JsonEnum;
-import es.elixir.bsc.json.schema.model.JsonType;
import java.util.List;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import javax.json.JsonObject;
@@ -61,11 +60,10 @@ public void setValues(List values) {
}
@Override
- public JsonEnumImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonEnumImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
values = JsonSchemaUtil.check(object.get(ENUM), JsonValue.ValueType.ARRAY);
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 e53b3c9..18ddb72 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
@@ -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,6 @@
import java.math.BigInteger;
import java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
-import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import java.math.BigDecimal;
import javax.json.JsonNumber;
@@ -57,11 +56,10 @@ public JsonIntegerSchemaImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator
}
@Override
- public JsonIntegerSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonIntegerSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonNumber min = JsonSchemaUtil.check(object.getJsonNumber(MINIMUM), JsonValue.ValueType.NUMBER);
if (min != null) {
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
index 6392ee3..f77d11b 100644
--- 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
@@ -30,13 +30,20 @@
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.JsonArraySchema;
+import es.elixir.bsc.json.schema.model.JsonObjectSchema;
import es.elixir.bsc.json.schema.model.JsonSchema;
+import es.elixir.bsc.json.schema.model.JsonSchemaElement;
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;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
/**
* The multiple types wrapper which is used when no type or a set of types is defined.
@@ -58,15 +65,22 @@ public JsonMultitypeSchemaWrapper(AbstractJsonSchemaElement parent, JsonSchemaLo
this.types = types;
}
+ @Override
+ public Stream getChildren() {
+ return StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED),false)
+ .filter(s -> s instanceof JsonObjectSchema || s instanceof JsonArraySchema)
+ .flatMap(JsonSchemaElement::getChildren);
+ }
+
@Override
public JsonSchemaLocator getScope() {
return scope;
}
@Override
- public JsonAnyOfImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonAnyOfImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
JsonValue $id = object.get(JsonSchema.ID);
if ($id == null) {
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNotImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNotImpl.java
index 82c5adc..730ef72 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNotImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNotImpl.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,6 @@
import es.elixir.bsc.json.schema.model.JsonSchemaElement;
import java.util.ArrayList;
import java.util.List;
-import es.elixir.bsc.json.schema.model.JsonType;
import java.util.stream.Stream;
import javax.json.JsonValue;
@@ -69,11 +68,10 @@ public void setJsonSchema(AbstractJsonSchema schema) {
}
@Override
- public JsonNotImpl read(final JsonSubschemaParser parser,
- final JsonValue value,
- final JsonType type) throws JsonSchemaException {
- this.schema = parser.parse(getScope(), null, getJsonPointer(), value, null);
+ public JsonNotImpl read(JsonSubschemaParser parser, JsonValue value)
+ throws JsonSchemaException {
+ this.schema = parser.parse(getScope(), null, getJsonPointer(), value, null);
return this;
}
diff --git a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNullSchemaImpl.java b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNullSchemaImpl.java
index edd889e..fae8388 100644
--- a/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNullSchemaImpl.java
+++ b/src/main/java/es/elixir/bsc/json/schema/model/impl/JsonNullSchemaImpl.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 java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
import es.elixir.bsc.json.schema.ValidationMessage;
-import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import javax.json.JsonObject;
import javax.json.JsonValue;
@@ -50,11 +49,10 @@ public JsonNullSchemaImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator lo
}
@Override
- public JsonNullSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonNullSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
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 b134bd9..a9fc347 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
@@ -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 java.math.BigDecimal;
import java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
-import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import javax.json.JsonNumber;
import javax.json.JsonObject;
@@ -52,11 +51,10 @@ public JsonNumberSchemaImpl(AbstractJsonSchemaElement parent, JsonSchemaLocator
}
@Override
- public JsonNumberSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonNumberSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonNumber min = JsonSchemaUtil.check(object.getJsonNumber(MINIMUM), JsonValue.ValueType.NUMBER);
if (min != 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 fc09a43..bf6e32d 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
@@ -38,7 +38,6 @@
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.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.JsonSchemaElement;
@@ -164,11 +163,10 @@ public AbstractJsonSchema getPropertyNames() {
}
@Override
- public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonObjectSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonObject jproperties = JsonSchemaUtil.check(object.get(PROPERTIES), ValueType.OBJECT);
if (jproperties != null) {
@@ -211,7 +209,7 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
final JsonValue junevaluatedProperties = object.get(UNEVALUATED_PROPERTIES);
if (junevaluatedProperties != null) {
switch(junevaluatedProperties.getValueType()) {
- case OBJECT: unevaluatedPropertiesSchema = parser.parse(getScope(), this, getJsonPointer() + "/" + UNEVALUATED_PROPERTIES, junevaluatedProperties, type); break;
+ case OBJECT: unevaluatedPropertiesSchema = parser.parse(getScope(), this, getJsonPointer() + "/" + UNEVALUATED_PROPERTIES, junevaluatedProperties, null); break;
case TRUE: unevaluatedProperties = true; break;
case FALSE: unevaluatedProperties = false; break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
@@ -222,10 +220,10 @@ public JsonObjectSchemaImpl read(final JsonSubschemaParser parser,
final JsonValue jpropertyNames = object.get(PROPERTY_NAMES);
if (jpropertyNames != null) {
switch(jpropertyNames.getValueType()) {
- case OBJECT: propertyNames = new JsonStringSchemaImpl(this, getScope(), getJsonPointer() + "/" + PROPERTY_NAMES).read(parser, jpropertyNames.asJsonObject(), null);
+ case OBJECT: propertyNames = new JsonStringSchemaImpl(this, getScope(), getJsonPointer() + "/" + PROPERTY_NAMES).read(parser, jpropertyNames.asJsonObject());
break;
case TRUE:
- case FALSE: propertyNames = new BooleanJsonSchemaImpl(this, getScope(), getJsonPointer() + "/" + PROPERTY_NAMES).read(parser, jpropertyNames, null);
+ case FALSE: propertyNames = new BooleanJsonSchemaImpl(this, getScope(), getJsonPointer() + "/" + PROPERTY_NAMES).read(parser, jpropertyNames);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
PROPERTY_NAMES, jpropertyNames.getValueType().name(), "either object or boolean"));
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 5d43c19..fb4f22c 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
@@ -34,7 +34,6 @@
import java.util.List;
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
-import es.elixir.bsc.json.schema.model.JsonType;
import javax.json.JsonArray;
import javax.json.JsonValue;
@@ -51,11 +50,10 @@ public JsonOneOfImpl(AbstractJsonSchema parent, JsonSchemaLocator locator,
}
@Override
- public JsonOneOfImpl read(final JsonSubschemaParser parser,
- final JsonArray schema,
- final JsonType type) throws JsonSchemaException {
+ public JsonOneOfImpl read(JsonSubschemaParser parser, JsonArray schema)
+ throws JsonSchemaException {
- super.read(parser, schema, type);
+ super.read(parser, schema);
return this;
}
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 e26e1fe..fd5f915 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
@@ -32,7 +32,6 @@
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
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 java.util.stream.Stream;
import javax.json.JsonObject;
import javax.json.JsonString;
@@ -90,12 +89,12 @@ public JsonSchemaElement getSchema() throws JsonSchemaException {
return schema;
}
+
@Override
- public JsonRecursiveReferenceImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonRecursiveReferenceImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonString jrecursive_ref = JsonSchemaUtil.check(object.get(RECURSIVE_REF), JsonValue.ValueType.STRING);
if (!"#".equals(jrecursive_ref.getString())) {
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 f1a550f..73f4595 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
@@ -91,11 +91,10 @@ public JsonSchemaElement getSchema() throws JsonSchemaException {
}
@Override
- public JsonReferenceImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonReferenceImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type, REF);
+ super.read(parser, object, REF);
return this;
}
}
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 4b4ec8a..d01c6ce 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
@@ -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,7 +34,6 @@
import es.elixir.bsc.json.schema.JsonSchemaValidationCallback;
import es.elixir.bsc.json.schema.ValidationException;
import es.elixir.bsc.json.schema.impl.DefaultJsonStringFormatValidator;
-import es.elixir.bsc.json.schema.model.JsonType;
import java.util.regex.Pattern;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import javax.json.JsonNumber;
@@ -102,11 +101,10 @@ public void setFormat(String format) {
}
@Override
- public JsonStringSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public JsonStringSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonNumber min = JsonSchemaUtil.check(object.getJsonNumber(MIN_LENGTH), JsonValue.ValueType.NUMBER);
if (min != null) {
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 82a6398..2681bb2 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
@@ -29,7 +29,6 @@
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.model.JsonType;
import es.elixir.bsc.json.schema.model.NumericSchema;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
import java.math.BigDecimal;
@@ -131,11 +130,10 @@ public void setExclusiveMaximum(Number exclusiveMaximum) {
}
@Override
- public NumericSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public NumericSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
- super.read(parser, object, type);
+ super.read(parser, object);
final JsonNumber mul = JsonSchemaUtil.check(object.getJsonNumber(MULTIPLE_OF), JsonValue.ValueType.NUMBER);
if (mul != null) {
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 cd2df03..772a61a 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
@@ -40,7 +40,6 @@
import es.elixir.bsc.json.schema.model.JsonReference;
import es.elixir.bsc.json.schema.model.JsonSchema;
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.net.URI;
import java.util.ArrayList;
@@ -95,7 +94,8 @@ public Stream getChildren() {
not != null ? not.getChildren() : null,
_if != null ? _if.getChildren() : null,
_then != null ? _then.getChildren() : null,
- _else != null ? _else.getChildren() : null)
+ _else != null ? _else.getChildren() : null,
+ ref != null ? ref.getChildren() : null)
.flatMap(c -> c);
}
@@ -161,9 +161,8 @@ public JsonReference getReference() {
}
@Override
- public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
- final JsonObject object,
- final JsonType type) throws JsonSchemaException {
+ public PrimitiveSchemaImpl read(JsonSubschemaParser parser, JsonObject object)
+ throws JsonSchemaException {
JsonValue $id = object.get(JsonSchema.ID);
if ($id == null) {
@@ -248,7 +247,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
final JsonArray jallOf = JsonSchemaUtil.check(object.get(ALL_OF), JsonValue.ValueType.ARRAY);
if (jallOf != null) {
final JsonAllOfImpl _allOf = new JsonAllOfImpl(this, scope, getJsonPointer() + "/" + ALL_OF)
- .read(parser, jallOf, type);
+ .read(parser, jallOf);
if (allOf == null) {
allOf = _allOf;
} else {
@@ -261,13 +260,13 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
final JsonArray janyOf = JsonSchemaUtil.check(object.get(ANY_OF), JsonValue.ValueType.ARRAY);
if (janyOf != null) {
anyOf = new JsonAnyOfImpl(this, scope, getJsonPointer() + "/" + ANY_OF);
- anyOf.read(parser, janyOf, type);
+ anyOf.read(parser, janyOf);
}
final JsonArray joneOf = JsonSchemaUtil.check(object.get(ONE_OF), JsonValue.ValueType.ARRAY);
if (joneOf != null) {
oneOf = new JsonOneOfImpl(this, scope, getJsonPointer() + "/" + ONE_OF);
- oneOf.read(parser, joneOf, type);
+ oneOf.read(parser, joneOf);
}
final JsonValue jnot = object.get(NOT);
@@ -276,7 +275,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case OBJECT:
case TRUE:
case FALSE: not = new JsonNotImpl(this, scope, getJsonPointer() + "/" + NOT)
- .read(parser, jnot, null);
+ .read(parser, jnot);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
NOT, jnot.getValueType().name(), "either object or boolean"));
@@ -289,7 +288,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case OBJECT: _if = parser.parse(scope, this, getJsonPointer() + "/" + IF, jif, null);
break;
case TRUE:
- case FALSE: _if = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jif, null);
+ case FALSE: _if = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jif);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
IF, jif.getValueType().name(), "either object or boolean"));
@@ -302,7 +301,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case OBJECT: _else = parser.parse(scope, this, getJsonPointer() + "/" + ELSE, jelse, null);
break;
case TRUE:
- case FALSE: _else = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jelse, null);
+ case FALSE: _else = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jelse);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
ELSE, jelse.getValueType().name(), "either object or boolean"));
@@ -315,7 +314,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
case OBJECT: _then = parser.parse(scope, this, getJsonPointer() + "/" + THEN, jthen, null);
break;
case TRUE:
- case FALSE: _then = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jthen, null);
+ case FALSE: _then = new BooleanJsonSchemaImpl(this, scope, getJsonPointer()).read(parser, jthen);
break;
default: throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
THEN, jthen.getValueType().name(), "either object or boolean"));
@@ -324,13 +323,13 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
final JsonValue jref = object.get(JsonReference.REF);
if (jref != null && JsonSchemaVersion.SCHEMA_DRAFT_2019_09.compareTo(
- parser.getJsonSchemaVersion(object)) <= 0) {
+ parser.getJsonSchemaVersion(locator)) <= 0) {
if (JsonValue.ValueType.STRING != jref.getValueType()) {
throw new JsonSchemaException(new ParsingError(ParsingMessage.INVALID_ATTRIBUTE_TYPE,
JsonReference.REF, jref.getValueType().name(), JsonValue.ValueType.STRING.name()));
}
- ref = new JsonReferenceImpl(this, scope, getJsonPointer()).read(parser, object, null);
+ ref = new JsonReferenceImpl(this, scope, getJsonPointer()).read(parser, object);
}
final JsonValue jdynamic_ref = object.get(JsonDynamicReference.DYNAMIC_REF);
@@ -345,7 +344,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
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);
+ ref = new JsonDynamicReferenceImpl(this, scope, getJsonPointer()).read(parser, object);
}
final JsonValue jrecursive_ref = object.get(JsonRecursiveReference.RECURSIVE_REF);
@@ -361,7 +360,7 @@ public PrimitiveSchemaImpl read(final JsonSubschemaParser parser,
String.join(",", List.of(JsonRecursiveReference.REF, JsonRecursiveReference.RECURSIVE_REF))));
}
- ref = new JsonRecursiveReferenceImpl(this, scope, getJsonPointer()).read(parser, object, null);
+ ref = new JsonRecursiveReferenceImpl(this, scope, getJsonPointer()).read(parser, object);
}
return this;
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 39d9467..7b4f4cb 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
@@ -27,7 +27,6 @@
import es.elixir.bsc.json.schema.JsonSchemaException;
import es.elixir.bsc.json.schema.JsonSchemaLocator;
-import es.elixir.bsc.json.schema.model.JsonType;
import es.elixir.bsc.json.schema.model.SchemaArray;
import java.util.HashSet;
import es.elixir.bsc.json.schema.impl.JsonSubschemaParser;
@@ -85,14 +84,13 @@ public boolean contains(AbstractJsonSchema schema) {
return schemas.contains(schema);
}
- public SchemaArrayImpl read(final JsonSubschemaParser parser,
- final JsonArray array,
- final JsonType type) throws JsonSchemaException {
+ public SchemaArrayImpl read(JsonSubschemaParser parser, JsonArray array)
+ throws JsonSchemaException {
for (int i = 0, n = array.size(); i < n; i++) {
final JsonValue value = array.get(i);
final AbstractJsonSchema schema = parser.parse(getScope(), this,
- getJsonPointer() + "/" + Integer.toString(i), value, type);
+ getJsonPointer() + "/" + Integer.toString(i), value, null);
add(schema);
}