public class JsonSchemaGenerator {
private static final ObjectMapper objectMapper = new ObjectMapper();
public static ObjectNode generate(Type type) {
ObjectNode objectNode = objectMapper.createObjectNode();
if (type instanceof Class) {
//原生类型
if (((Class<?>) type).isPrimitive()) {
if (type == byte.class || type == char.class || type == int.class || type == short.class || type == long.class) {
objectNode.put("type", "integer");
} else if (type == float.class || type == double.class) {
objectNode.put("type", "number");
} else if (type == boolean.class) {
objectNode.put("type", "boolean");
}
}
//Map
else if (isMap(type))
02-28
876
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交