Example usage for com.fasterxml.jackson.databind.jsonschema SchemaAware getSchema

List of usage examples for com.fasterxml.jackson.databind.jsonschema SchemaAware getSchema

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.jsonschema SchemaAware getSchema.

Prototype

public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException;

Source Link

Document

Get the representation of the schema to which this serializer will conform.

Usage

From source file:com.googlecode.jsonschema2pojo.SchemaGenerator.java

private ObjectNode simpleTypeSchema(JsonNode exampleValue) {

    try {//  w ww. java  2s  .  co m

        Object valueAsJavaType = OBJECT_MAPPER.treeToValue(exampleValue, Object.class);

        SchemaAware valueSerializer = getValueSerializer(valueAsJavaType);

        return (ObjectNode) valueSerializer.getSchema(OBJECT_MAPPER.getSerializerProvider(), null);
    } catch (JsonMappingException e) {
        throw new GenerationException("Unable to generate a schema for this json example: " + exampleValue, e);
    } catch (JsonProcessingException e) {
        throw new GenerationException("Unable to generate a schema for this json example: " + exampleValue, e);
    }

}