public final class Example5 extends ExampleBase
This example demonstrates another capability of JsonSchemaFactory
:
the ability to set a URI namespace. This requires to customize the factory,
and therefore go through JsonSchemaFactoryBuilder
again.
In order to set a URI namespace, we must grab a LoadingConfigurationBuilder
, set the namespace, freeze it, and pass it to
the factory builder and then freeze the factory.
The net effect is that all schema loading done by SchemaLoader
will now resolve against this namespace, and this includes arguments to
JsonSchemaFactory.getJsonSchema(String)
.
The schemas are split in two:
The first refers to the second one via the relative URI mntent.json
. This works precisely because a URI namespace has been set: all
URIs are resolved against this namespace.
Files validated, and the validation outputs, are the same as for Example2
.
Constructor and Description |
---|
Example5() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String... args) |
loadResource, printReport
public static void main(String... args) throws IOException, com.github.fge.jsonschema.exceptions.ProcessingException
IOException
com.github.fge.jsonschema.exceptions.ProcessingException
Copyright © 2014. All Rights Reserved.