我有以下的Json字符串
{
"name": "Mr Xyz"
}
上述JSON格式的Java模型类如下所示:
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"name"
})
public class Test {
@JsonProperty("name")
@JsonPropertyDescription("Non Zero Length String")
@Size(min = 1)
@NotNull
private String name;
Jackson API根据下面的Test.class Java对象生成下面的JSON模式
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Test",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 1,
"description": "Non Zero Length String"
}
},
"required": [
"name"
]
}
我的问题是如何更改我的Java pojo对象,以便它可以生成以下模式
{
"$id": "test id",
"$schema": "http://json-schema.org/draft-07/schema",
"title": "Test title",
"description": "test description",
"type": "object",
"properties": {
"name": {
"$ref": "#/definitions/d_NonZeroLengthString"
}
},
"definitions": {
"d_NonZeroLengthString": {
"description": "Non Zero Length String",
"type": "string",
"minLength": 1
}
}
}