我正在尝试使用jsonschema2pojo来生成Java类。我在使用'$ ref'标签引用我父模式中的其他模式时遇到了麻烦。
{
"$schema": "http://json-schema.org/draft-03/hyper-schema",
"additionalProperties": false,
"id": "device:v1",
"name": "device",
"properties": {
"components": {
"$ref": "spec.json"
},
"usage": {
"$ref": "spec.json"
}
}
},
"required": true,
"title": "Device",
"type": "object"
}
{
"$schema": "http://json-schema.org/draft-03/hyper-schema",
"additionalProperties": false,
"id": "spec:v1",
"name": "spec",
"properties": {
"content": {
"description" : "Content",
"type": "string",
"required": false
}
},
"required": true,
"title": "spec",
"type": "object"
}
现在我希望创建以下java类:
public class Device {
private Spec components,
private Spec usage
.....
}
和
public class Spec {
private String content
}
但我得到
public class Device {
private Components components,
private Components usage
.....
}
和
public class Components {
private String content
}
我做错了什么?
答案 0 :(得分:0)
感谢here,joelittlejohn的回答。我使用spec.json
中的 javaType 来实现此功能function_name = ...
{
"$schema": "http://json-schema.org/draft-03/hyper-schema",
"additionalProperties": false,
"id": "device:v1",
"name": "device",
"properties": {
"components": {
"$ref": "spec.json",
"type": "object",
},
"usage": {
"$ref": "spec.json",
"type": "object",
}
}
},
"required": true,
"title": "Device",
"type": "object"
}