在Spring中向客户端发送字段元数据



我希望我的客户端能够请求关于@RequestMapping的元数据,比如每个字段的@Size@Length值。Spring有办法做到这一点吗?

最接近的可能是Spring HATEOAS为HAL形式提供支持。

春季HATEOAS绿化

响应生成的输出包括关于请求模型的所有元数据以及验证规则和方法。

{
"_embedded": {
"employees": [...]
},
"_links": {
"self": {
"href": "http://localhost:8080/employees"
}
},
"_templates": {
"default": {
"title": null,
"method": "post",
"contentType": "",
"properties":[
{
"name": "firstName",
"required": true
},
{
"name": "id",
"required": true
},
{
"name": "lastName",
"required": true
},
{
"name": "role",
"required": true
}
]
}
}
}

最新更新