com.github.fge.jsonschema.examples
Class Example6
java.lang.Object
com.github.fge.jsonschema.examples.Example6
public final class Example6
- extends Object
Sixth example: URI redirection
link to source code
In this example, the same schema file is used as in Example1. This
time, though, it is assumed that the base URI used for addressing this schema
is http://my.site/schemas/fstab.json#. But instead of trying to
fetch it from the web directly, we want to use the local copy, which is
located under URI resource:/org/eel/kitchen/jsonschema/examples/fstab.json#.
The solution here is to build a custom URITranslatorConfiguration,
which allows to customize URI handling; in this case, a schema redirection
using the URITranslatorConfigurationBuilder.addSchemaRedirect(String,
String). We then inject this into a custom LoadingConfiguration.
The effect is that if you required a schema via URI http://my.site/schemas/fstab.json#, it will silently transform this URI into
resource:/org/eel/kitchen/jsonschema/examples/fstab.json#
internally.
Note that URIs must be absolute JSON references (see JsonRef).
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Example6
public Example6()
main
public static void main(String... args)
throws IOException,
ProcessingException
- Throws:
IOException
ProcessingException