Example usage for com.fasterxml.jackson.databind ObjectMapper generateJsonSchema

List of usage examples for com.fasterxml.jackson.databind ObjectMapper generateJsonSchema

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind ObjectMapper generateJsonSchema.

Prototype

@SuppressWarnings("deprecation")
public com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema(Class<?> t)
        throws JsonMappingException 

Source Link

Document

Generate <a href="http://json-schema.org/">Json-schema</a> instance for specified class.

Usage

From source file:de.oth.keycloak.CreateConfigSchema.java

public static void main(String[] args) {
    ObjectMapper mapper = new ObjectMapper();
    try {//w w w  .j a va2s.c  om
        JsonSchema schema = mapper.generateJsonSchema(RealmsConfig.class);
        String s = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
        System.out.println(s);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:io.neocdtv.jarxrs.server.ResourceExample.java

@GET
@Path("schema-jackson")
public Response generateSchemaJackson() throws JsonMappingException, IOException {
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true);

    final com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema = mapper
            .generateJsonSchema(Object1.class);

    return Response.ok(mapper.writeValueAsString(generateJsonSchema)).build();
}