I have the following dependencies in my pom.xml
<!-- https://github.com/everit-org/json-schema -->
<dependency>
<groupId>com.github.everit-org.json-schema</groupId>
<artifactId>org.everit.json.schema</artifactId>
<version>1.11.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
this is my json schema
{
"$schema": "http://json-schema.org/draft-06/schema#",
"id": "test",
"title": "test-json validation",
"description": "This schema should define the structure of the test json",
"allOf": [
{
"$ref": "classpath:/jsonSchema/header/test.json#/definitions/test"
},
{
"$ref": "classpath:/jsonSchema/rows/test.json#/definitions/test"
}
],
"properties": {
"version": {
"type": "array",
"items": {
"type": "string",
"enum": [
"2.0",
"2.1"
]
}
}
},
"required": [
"version"
]
}
and this is what I am trying to achieve
public Schema createSchema(String schemaPath) throws IOException {
Schema schema = null;
try (InputStream inputStream = new ClassPathResource(schemaPath).getInputStream()) {
JSONObject rawSchema = new JSONObject(new JSONTokener(inputStream));
schema = SchemaLoader.load(rawSchema);
}
return schema;
}
And I get the following exception:
SchemaException: classpath:/jsonSchema/header/order_header.json#/definitions/order_header/properties/order_header/properties/origin/properties/locale: expected type is one of Boolean or JsonObject, found: String at org.everit.json.schema.loader.LoadingState.createSchemaException(LoadingState.java:142) at org.everit.json.schema.loader.JsonValue$Multiplexer.multiplexFailure(JsonValue.java:50) at org.everit.json.schema.loader.JsonValue$Multiplexer.lambda$requireAny$1(JsonValue.java:45) at java.util.Optional.orElseThrow(Optional.java:290) at org.everit.json.schema.loader.JsonValue$Multiplexer.requireAny(JsonValue.java:45) at org.everit.json.schema.loader.SchemaLoader.load(SchemaLoader.java:434) [6x]