This sounds like a rookie question, but I'm wondering what's the best way to present paged resources with HAL format? Right now I'm using Spring HATEOAS API to convert Page
object into resource PagedResourcesAssembler#toResource(Page<T>, ResourceAssembler<T,R>)
. This results in the following output:
{
"_links": {
"self": {
"href": "http://example.org/api/user?page=3"
},
…
}
"count": 3,
"total": 498,
"_embedded": {
"users": [
{
"_links": {
"self": {
"href": "http://example.org/api/user/mwop"
}
},
"id": "mwop",
"name": "Matthew Weier O'Phinney"
}
]
}
}
Everything works fine but the only problem is the collection being returned is under _embedded
field and has the class name, so the client has to know this class name as well right? Would it be better to just return the collection under content
like non-HAL format? If yes how should I achieve it using Spring HATEOAS?