Closed azakordonets closed 3 years ago
I managed to find a solution :
public static JSONObject generateJsonSchema(Class clazz) throws IOException {
ObjectMapper mapper = new ObjectMapper();
JsonSchemaConfig config = JsonSchemaConfig.vanillaJsonSchemaDraft4().withFailOnUnknownProperties(false);
config = config.withFailOnUnknownProperties(false);
JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator(mapper, config);
JsonNode jsonSchema = jsonSchemaGenerator.generateJsonSchema(clazz);
String json = mapper.writeValueAsString(jsonSchema);
return new JSONObject(json);
}
Again, thanks a lot for a great library 🙇♂️👍
I'm trying to use your library to generate JSON schema's and so far it works great - thanks for the lib. I have one problem that i can't figure out - i would like to allow additionalProperties in my schema, but disabling
FAIL_ON_UNKNOWN_PROPERTIES
option in ObjectMapper doesn't help :Results in
Example of pojo: