我正在构建一个动态适应弹簧数据休息端点的客户端/代码生成器。
我要求提供两个请求的架构信息:
curl -v -H "Accept: application/schema+json" http://localhost:8080/legalEntity
curl -v -H "Accept: application/hal+json" http://localhost:8080/legalEntity
这给了我ApiLegalEntity
的模式。特别是,我对这个实体的一个子属性感兴趣,我知道它是List<ApiAccount>
。对于架构,我得到:
{
"title": "Api legal entity",
"properties": {
"accounts": {
"title": "Accounts",
"readOnly": true,
"type": "string",
"format": "uri"
},
...
},
"definitions": {},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
}
到目前为止,除了属性名称之外,我无法解读任何其他内容,但幸运的是hal(几乎)告诉我其他所有内容:
{
"alps": {
"version": "1.0",
"descriptors": [
{
"id": "legalentities-representation",
"href": "http://.../profile/legalentities",
...
"descriptors": [
{
"name": "accounts",
"type": "SAFE",
"rt": "http://.../#accounts-representation"
},
...
]
},
{
"id": "get-legalentities",
...
},
]
}
}
大!现在来自"rt": "http://.../#accounts-representation"
我知道accounts
属性是ApiAccount
实体。现在,我如何判断它是ApiAccounts的集合?