What I have:
I\'m generating a JSON schema from a pojo. My code to generate the schema looks like so:
ObjectMapper mapper = new ObjectMapper();
Titl
It seems to not be possible using the instructions I found using databind. However I found another jackson module that seems to do the trick nicely. Oddly several of the objects are named the same.
TLDR: use objects from the org.codehaus.jackson.map
package rather than the com.fasterxml.jackson.databind
package. If you're following the instructions on this page then you're doing it wrong. Just use the jackson-mapper module instead.
Here's the code for future googlers:
private static String getJsonSchema(Class clazz) throws IOException {
org.codehaus.jackson.map.ObjectMapper mapper = new ObjectMapper();
//There are other configuration options you can set. This is the one I needed.
mapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
JsonSchema schema = mapper.generateJsonSchema(clazz);
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
}