我有一个标签系统:
标签
因此它们可以嵌套(最大深度3)
例如:
- Family
我有一些有标签的资源。
地点
我有几个终点:
/api/tags
{
"items": [
{
"_links": {
"self": {
"href": "/api/tags/1"
}
},
"id": 1,
"name": "Food",
"_embedded": {
"children": [
{
"_links": {
"self": {
"href": "/api/tags/4"
}
},
"id": 4,
"name": "Restaurant",
"_embedded": {
"children": []
}
},
{
"_links": {
"self": {
"href": "/api/tags/5"
}
},
"id": 5,
"name": "Fast food",
"_embedded": {
"children": []
}
}
]
}
},
{
"_links": {
"self": {
"href": "/api/tags/2"
}
},
"id": 2,
"name": "Medicine",
"_embedded": {
"children": []
}
},
{
"_links": {
"self": {
"href": "/api/tags/3"
}
},
"id": 3,
"name": "Entertainment",
"_embedded": {
"children": []
}
}
]
}和/api/place/1
{
"id": 1,
"name": "FooBar Arena",
"_embedded": {
"tags": [
{
"_links": {
"self": {
"href": "/api/tags/1"
}
},
"id": 1,
"name": "Food"
},
{
"_links": {
"self": {
"href": "/api/tags/2"
}
},
"id": 2,
"name": "Medicine"
}
]
}
}因此,我不希望标签在被列为嵌入式资源时拥有嵌入式资源,但不包括嵌入式子资源,我最终得到了两个不同的表示相同数据的自链接的表示,客户机应该如何比较它们呢?比较自链接是可行的,但有一种表示缺乏children
发布于 2017-11-27 22:04:13
我相信一个好的HAL客户不认为_embedded是表示的一部分。一个好的HAL客户端只是使用来自_embedded的值来温暖缓存。出现在_embedded中的项仍应出现在_links中。
因此,只要每个资源的标记出现在_links中,就不需要多次嵌入相同的资源。
https://stackoverflow.com/questions/47517898
复制相似问题