T - SchemaConversions implementation@ParametersAreNonnullByDefault public class JsonSchemaConverter<T> extends Object
SchemaConversions implementation to
convert from JSONSchema types.
This was implemented expecting to support JSONSchema Draft 7,
but will likely work with many JSONSchema versions.
Support for JSONSchema Draft 3 has been added; notably
support for Draft 3's method of marking a field as required.| Constructor and Description |
|---|
JsonSchemaConverter(SchemaConversions<T> schemaConversions) |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkJsonSchemaIsObject(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema)
DRY helper function that asserts that the jsonSchema has "type": "object".
|
T |
convert(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema)
Converts this JSONSchema using the provided SchemaConversions.
|
protected T |
convert(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema,
String nodePath)
Iterates through jsonSchema and calls appropriate TypeConverter methods
on each jsonSchema property type in order to convert it into type T.
|
protected T |
convertArrayType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema,
String nodePath) |
protected T |
convertMapType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema,
String nodePath) |
protected T |
convertRowType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema,
String nodePath) |
static com.fasterxml.jackson.databind.JsonNode |
getJsonNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode,
String key,
String errorMessage)
DRY helper function to get a JsonNode out of an ObjectNode by key,
throwing IllegalArgumentException if the key does not exist, or is set to "null".
|
static String |
getJsonSchemaType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema)
DRY helper function to extract the JSONSchema "type".
|
public JsonSchemaConverter(SchemaConversions<T> schemaConversions)
@Nonnull public T convert(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema)
jsonSchema - The JSONSchema Object. This should have at minimum type.@Nonnull protected T convert(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema, String nodePath)
jsonSchema - The JSONSchema Object. This should have at minimum type.nodePath - Fully qualified dotted json path to the current node in the JSONSchema.
Used only for informational error and log messages.@Nonnull protected T convertArrayType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema, String nodePath)
@Nonnull protected T convertMapType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema, String nodePath)
@Nonnull protected T convertRowType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema, String nodePath)
@Nonnull public static com.fasterxml.jackson.databind.JsonNode getJsonNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String key, String errorMessage)
objectNode - ObjectNode from which to get JsonNode by keykey - Field name key to get out of the ObjectNode.errorMessage - Error message for IllegalArgumentException if key is not set or is "null".@Nonnull public static String getJsonSchemaType(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema)
@Nonnull public static void checkJsonSchemaIsObject(com.fasterxml.jackson.databind.node.ObjectNode jsonSchema)
IllegalArgumentException - if jsonSchema "type" != "object"Copyright © 2025. All rights reserved.