'How to get JSON metadata of a class in Spring Boot
I'm trying to get metadata in JSON format of a class in Spring Boot, but I don't really know how to start. I have created my class, that is a random one, just to make some attempt. Can someone show me some examples?
@RequestMapping(value = "/meta", method = RequestMethod.GET)
public String getMetadata(HttpServletResponse response) throws Exception {
ObjectMapper mapper = new ObjectMapper();
SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
mapper.acceptJsonFormatVisitor(Catasto.class, visitor);
JsonSchema schema = visitor.finalSchema();
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|