use of com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator in project fabric8 by jboss-fuse.
the class JsonSchemaLookup method getSchemaForClass.
public String getSchemaForClass(Class<?> clazz) {
LOG.info("Looking up schema for " + clazz.getCanonicalName());
String name = clazz.getName();
try {
ObjectWriter writer = mapper.writer().with(new FourSpacePrettyPrinter());
JsonSchemaGenerator jsg = new JsonSchemaGenerator(mapper);
JsonSchema jsonSchema = jsg.generateSchema(clazz);
return writer.writeValueAsString(jsonSchema);
} catch (Exception e) {
LOG.log(Level.FINEST, "Failed to generate JSON schema for class " + name, e);
return "";
}
}
Aggregations