public class EventSchemaLoader extends Object
EventSchemaLoader schemaLoader = EventSchemaLoader.builder()
.setJsonSchemaLoader(ResourceLoader.asURLs(Arrays.asList(
"file:///path/to/schemas1",
"http://schema.repo.org/path/to/schemas"
)))
.build();
// Load the JSONSchema at file:///path/to/schemas/test/event/0.0.2
schemaLoader.getEventSchema("/test/event/0.0.2");
// Load the JsonNode or JSON String event's JSONSchema at /$schema
schemaLoader.getEventSchema(event);
Modifier and Type | Class and Description |
---|---|
static class |
EventSchemaLoader.Builder |
Modifier and Type | Field and Description |
---|---|
protected static String |
LATEST_FILE_NAME
When looking up latest schema versions, this will be used instead of a semver string.
|
protected com.fasterxml.jackson.core.JsonPointer |
schemaFieldPointer
Field in an event from which to extract the schema URI.
|
protected JsonSchemaLoader |
schemaLoader
JsonSchemaLoader used to load schemas from URIs.
|
Modifier | Constructor and Description |
---|---|
protected |
EventSchemaLoader(JsonSchemaLoader loader,
com.fasterxml.jackson.core.JsonPointer schemaFieldPointer)
Constructs a EventSchemaLoader that prefixes URIs with baseURI and
extracts schema URIs from the schemaField in events.
|
Modifier and Type | Method and Description |
---|---|
static EventSchemaLoader.Builder |
builder() |
URI |
extractSchemaUri(com.fasterxml.jackson.databind.JsonNode event)
Extracts the value at schemaFieldPointer from the event as a URI.
|
com.github.fge.jsonschema.main.JsonSchema |
getEventJsonSchema(com.fasterxml.jackson.databind.JsonNode event)
Given a JSON event, get its schema URI,
and load and return schema for the event as a JsonSchema (suited for validation).
|
com.github.fge.jsonschema.main.JsonSchema |
getEventJsonSchema(String eventString)
Given a JSON event, get its schema URI,
and load and return schema for the event as a JsonSchema (suited for validation).
|
com.fasterxml.jackson.databind.JsonNode |
getEventSchema(com.fasterxml.jackson.databind.JsonNode event)
Given an event object, this extracts its schema URI at schemaField
(prefixed with baseURI) and returns the schema there.
|
com.fasterxml.jackson.databind.JsonNode |
getEventSchema(String eventString)
Given a JSON event string, get its schema URI,
and load and return schema for the event.
|
JsonLoader |
getJsonLoader() |
com.github.fge.jsonschema.main.JsonSchema |
getJsonSchema(com.fasterxml.jackson.databind.JsonNode schema)
Given a json schema parsed as a JsonNode materialize JsonSchema suited for validation.
|
com.fasterxml.jackson.databind.JsonNode |
getLatestEventSchema(com.fasterxml.jackson.databind.JsonNode event)
Given an event object, this extracts its schema URI at schemaField
(prefixed with baseURI) and resolves it to the latest schema URI and returns
the schema there.
|
com.fasterxml.jackson.databind.JsonNode |
getLatestEventSchema(String eventString)
Given a JSON event string, get its schema URI,
and load and return latest schema for the event.
|
com.fasterxml.jackson.databind.JsonNode |
getLatestSchema(URI schemaUri)
Get a 'latest' JsonSchema given a schema URI looking in all baseUris.
|
URI |
getLatestSchemaUri(com.fasterxml.jackson.databind.JsonNode event)
Extracts the event's schema URI and converts it to a latest schema URI.
|
URI |
getLatestSchemaUri(URI schemaUri)
Converts the given schemaUri to a 'latest' schema URI.
|
String |
getLatestVersionFileName() |
ResourceLoader |
getResourceLoader() |
com.fasterxml.jackson.databind.JsonNode |
getSchema(URI schemaUri)
Get a JsonSchema at schemaUri looking in all baseUris.
|
URI |
latestSchemaURI(String title)
Builds the URI to the latest schema using this title.
|
com.fasterxml.jackson.databind.JsonNode |
load(URI schemaUri)
Returns the content at schemaURI as a JsonNode JSONSchema.
|
URI |
schemaUri(String title,
String version)
Builds the URI to the schema using this title and this version.
|
String |
toString() |
protected static final String LATEST_FILE_NAME
protected final com.fasterxml.jackson.core.JsonPointer schemaFieldPointer
protected final JsonSchemaLoader schemaLoader
protected EventSchemaLoader(JsonSchemaLoader loader, com.fasterxml.jackson.core.JsonPointer schemaFieldPointer)
EventSchemaLoader.Builder
.public static EventSchemaLoader.Builder builder()
public com.fasterxml.jackson.databind.JsonNode load(URI schemaUri) throws JsonLoadingException
JsonLoadingException
public URI extractSchemaUri(com.fasterxml.jackson.databind.JsonNode event)
public URI getLatestSchemaUri(URI schemaUri)
public URI latestSchemaURI(String title)
public URI schemaUri(String title, String version)
public URI getLatestSchemaUri(com.fasterxml.jackson.databind.JsonNode event)
public com.fasterxml.jackson.databind.JsonNode getSchema(URI schemaUri) throws JsonLoadingException
JsonLoadingException
public com.fasterxml.jackson.databind.JsonNode getLatestSchema(URI schemaUri) throws JsonLoadingException
JsonLoadingException
public com.fasterxml.jackson.databind.JsonNode getEventSchema(com.fasterxml.jackson.databind.JsonNode event) throws JsonLoadingException
JsonLoadingException
public com.fasterxml.jackson.databind.JsonNode getEventSchema(String eventString) throws JsonLoadingException
JsonLoadingException
public com.github.fge.jsonschema.main.JsonSchema getEventJsonSchema(String eventString) throws com.github.fge.jsonschema.core.exceptions.ProcessingException, JsonLoadingException
com.github.fge.jsonschema.core.exceptions.ProcessingException
JsonLoadingException
public com.github.fge.jsonschema.main.JsonSchema getEventJsonSchema(com.fasterxml.jackson.databind.JsonNode event) throws com.github.fge.jsonschema.core.exceptions.ProcessingException, JsonLoadingException
com.github.fge.jsonschema.core.exceptions.ProcessingException
JsonLoadingException
public com.github.fge.jsonschema.main.JsonSchema getJsonSchema(com.fasterxml.jackson.databind.JsonNode schema) throws com.github.fge.jsonschema.core.exceptions.ProcessingException
com.github.fge.jsonschema.core.exceptions.ProcessingException
public com.fasterxml.jackson.databind.JsonNode getLatestEventSchema(com.fasterxml.jackson.databind.JsonNode event) throws JsonLoadingException
JsonLoadingException
public com.fasterxml.jackson.databind.JsonNode getLatestEventSchema(String eventString) throws JsonLoadingException
JsonLoadingException
public JsonLoader getJsonLoader()
public ResourceLoader getResourceLoader()
public String getLatestVersionFileName()
Copyright © 2025. All rights reserved.