public final class JsonSchemaFactory extends Object
You can create a factory with all default settings using defaultFactory(). This is what you will do in the vast
majority of cases.
If you want to customize it, you need to go through JsonSchemaFactory.Builder.
This class is thread safe and immutable.
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonSchemaFactory.Builder
Builder class for a
JsonSchemaFactory |
| Modifier and Type | Method and Description |
|---|---|
static JsonSchemaFactory |
defaultFactory()
Build a factory with all default settings
|
JsonSchema |
fromSchema(JsonNode schema)
Create a schema instance from a JSON Schema
|
JsonSchema |
fromSchema(JsonNode schema,
String path)
Create a schema instance from a JSON Schema, at a certain path
|
JsonSchema |
fromURI(String str)
Create a schema instance from a JSON Schema located at a given URI
|
JsonSchema |
fromURI(String str,
String path)
Create a schema instance from a JSON Schema located at a given URI and
at a given path
|
JsonSchema |
fromURI(URI uri)
Create a schema instance from a JSON Schema located at a given URI
|
JsonSchema |
fromURI(URI uri,
String path)
Create a schema instance from a JSON Schema located at a given URI, and
at a given path
|
public static JsonSchemaFactory defaultFactory()
public JsonSchema fromSchema(JsonNode schema, String path)
For instance, if you submit this schema:
{
"schema1": { ... },
"schema2": { ... }
}
then you can create a validator for schema1 using:
final JsonSchema schema = factory.create(schema, "#/schema1");
The path can be a JsonPointer as above, but also an id
reference.
schema - the schemapath - the pointer/id reference into the schemaJsonSchema instanceJsonFragmentpublic JsonSchema fromSchema(JsonNode schema)
This calls fromSchema(JsonNode, String) with "" as
a path.
schema - the schemaJsonSchema instancepublic JsonSchema fromURI(URI uri, String path) throws JsonSchemaException
This allows you, for instance, to load a schema using HTTP. Or, in fact, any other URI scheme that is supported.
uri - the URIpath - the JSON Pointer/id reference into the downloaded schemaJsonSchema instanceJsonSchemaException - unable to get content from that URIURIManager,
SchemaRegistrypublic JsonSchema fromURI(URI uri) throws JsonSchemaException
uri - the URIJsonSchema instanceJsonSchemaException - unable to get content from that URIfromSchema(JsonNode, String)public JsonSchema fromURI(String str) throws JsonSchemaException
str - the URI as a stringJsonSchema instanceJsonSchemaException - unable to get content from that URIIllegalArgumentException - URI is invalidURI.create(String),
fromURI(URI, String)public JsonSchema fromURI(String str, String path) throws JsonSchemaException
str - the URI as a stringpath - the JSON Pointer/id reference into the downloaded schemaJsonSchema instanceJsonSchemaException - unable to get content from that URIIllegalArgumentException - URI is invalidURI.create(String),
fromURI(URI, String)Copyright © 2013. All Rights Reserved.