问题
I am using Jackson to create json schema. I want to display property with their default value in json schema. I tried @JsonProperty annotation with default attribute but still default value is not being display on the json schema.
I am using following code to generate Json Schema:
ObjectMapper mapper = new ObjectMapper();
JsonSchemaGenerator schemaGen = new JsonSchemaGenerator(mapper);
JsonSchema schema = null;
try {
schema = schemaGen.generateSchema(RootTemplate.class);
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema));
}
catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
来源:https://stackoverflow.com/questions/61124672/how-to-display-default-value-in-json-schema-using-jackson