public static void main(String[] args) throws JsonMappingException {
ObjectMapper jsonMapper = new ObjectMapper();
AnnotationIntrospector introspector = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(),
new JacksonAnnotationIntrospector());
jsonMapper.setAnnotationIntrospector(introspector);
JsonSchema schema = jsonMapper.generateJsonSchema(Testi.class);
if(Testi.class.getAnnotation(XmlRootElement.class)!=null
&& !Testi.class.getAnnotation(XmlRootElement.class).name().equals("##default"))
schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlRootElement.class).name());
else if(Testi.class.getAnnotation(XmlType.class)!=null
&& !Testi.class.getAnnotation(XmlType.class).name().equals("##default"))
schema.getSchemaNode().put("name", Testi.class.getAnnotation(XmlType.class).name());
else
schema.getSchemaNode().put("name", Testi.class.getSimpleName());
String schemaJson = schema.toString();
System.out.println(schemaJson);
}
Testi.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:test-html-generator-plugin
作者:
评论列表
文章目录