Skip to content

Ref to another json schema doesn`t work #1103

Answered by justin-tay
HalinaPichukha asked this question in Q&A
Discussion options

You must be logged in to vote

A relative IRI $ref needs a base IRI to resolve. As you are using an InputStream to load your parent schema and there is no $id defined there is no base 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 …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by HalinaPichukha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants