我是这个 API 的新手。试图生成一类 10-15 个不同数据类型的字段。但是生成的类具有我声明的类型的第一个变量,但如果是 Object 类型,则保留如下。
// 架构
{
"type":"object",
"properties": {
"foo": {
"type": "string"
},
"bar": {
"type": "String"
},
"baz": {
"type": "String"
}
}
}
//生成的类
//...
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"foo",
"bar",
"baz"
})
public class Sample{
@JsonProperty("foo")
private String foo;
@JsonProperty("bar")
private Object bar;
@JsonProperty("baz")
private Object baz;
@JsonIgnore
....//
如果您注意到第二个和第三个变量被声明为 String 但从类生成的结果是对象类型。有人可以帮助了解问题所在吗?
{
"type":"object",
"properties": {
"length": {
"type": "string"
},
"width": {
"type": "string"
},
"height": {
"type": "string"
},
"dimensionalWeight": {
"type": "string"
}
}
}