I have a tag system:
Tag
- id
- name
- children tags
so they could be nested (max depth 3)
for example:
- Food
- Restaurant
- Fast food
- Chinese food
- Medicine
- Hospitals
- Pharmacy
- Entertainment
- Extreme
- Skiing
- Skating
- Family
- Extreme
And I have some resources that have tags.
Place
- id
- name
- tags
And I have few endpoints:
/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": []
}
}
]
}
And /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"
}
]
}
}
So I don't want tags to have embedded resources when they are listed as embedded resources themselves, but by NOT including embedded children I ended up with two different representations of the same data with the same SELF link, how clients should compare those? Comparing SELF links would work but one representation lacks children