com.github.fge.jsonschema.examples
Class Example10

java.lang.Object
  extended by com.github.fge.jsonschema.examples.ExampleBase
      extended by com.github.fge.jsonschema.examples.Example10

public final class Example10
extends ExampleBase

Tenth example: registering schemas

link to source code

In this example, we register a custom schema with a given URI, and initiate the JsonSchema instance using that URI. This is done by customizing a LoadingConfiguration and registering schemas using LoadingConfigurationBuilder.preloadSchema(String, JsonNode).

The only necessary condition for the URI is for it to be an absolute JSON reference (see JsonRef.isAbsolute()), and you can register as many schemas as you want. Here, we register both schemas from Example5. You will notice that the scheme for these URIs is xxx: it does not matter in the slightest that it is not a supported scheme by default, the schema is registered all the same.

This also shows that reference resolution still works in such a case, since the mntent schema is referred to via a relative URI from the fstab schema.


Constructor Summary
Example10()
           
 
Method Summary
static void main(String... args)
           
 
Methods inherited from class com.github.fge.jsonschema.examples.ExampleBase
loadResource, printReport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Example10

public Example10()
Method Detail

main

public static void main(String... args)
                 throws IOException,
                        ProcessingException
Throws:
IOException
ProcessingException


Copyright © 2014. All Rights Reserved.