Ref to another json schema doesn`t work #1103
-
Hello :) I want to implement referensing to the child json schema from the parent one. I have main json schema "parent-validation-schema.json": and the child-validation-schema.json: Also I configured JsonSchemaFactory and JsonSchema (it works grait for the single json schema): public class JsonSchemaValidator implements EventValidator { private final JsonSchema jsonSchema; public JsonSchemaValidator() { They are located on the same directory. I`m basing on the test cases in your repo: But I get error: URI is not absolute. I case I use Could you please help me with this issue? :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
A relative IRI Instead of jsonSchema = factory.getSchema(JsonSchemaValidator.class.getResourceAsStream("/parent-validation-schema.json")); You can try jsonSchema = factory.getSchema(SchemaLocation.of("classpath:/parent-validation-schema.json")); Also this line doesn't do anything meaningful as you created an execution context and set the config but never stored the reference to it in order to pass it somewhere. jsonSchema.createExecutionContext().getExecutionConfig().setFormatAssertionsEnabled(true); Typically this is done by passing a lambda as a parameter to validate if you want to customize the execution context for that run. Set<ValidationMessage> messages = schema.validate(inputData, InputFormat.JSON, executionContext -> {
executionContext.getExecutionConfig().setFormatAssertionsEnabled(true);
}); |
Beta Was this translation helpful? Give feedback.
A relative IRI
$ref
needs a base IRI to resolve. As you are using anInputStream
to load your parent schema and there is no$id
defined there is no base IRI.Instead of
You can try
Also this line doesn't do anything meaningful as you created an execution context and set the config but never stored the reference to it in order to pass it somewhere.
Typically this is done by passing a lambda as a …