Hydra collections, pagination, search

Hello everyone!

My name is Ardie and i'm interested in using Hydra for some new APIs i'm
building but was looking for examples on how to properly implement
collections. Specifically i'd like to see an example of how to implement
operations, searches and templated links.

Based on the examples within the spec, i believe a collection object should
look something like this:
{
    "@context": "http://www.w3.org/ns/hydra/context.jsonld",
    "@id": "http://api.example.com/an-issue/comments",
    "@type": "Collection",
    "totalItems": "4980",
    "member": [
        {
            "@id": "/comments/1",
            "value": "Some comment about this or that",
            "operation": [
                {
                    "@type": "Operation",
                    "method": "DELETE"
                }
            ]
        }
    ],
    "view": {
        "@id": "http://api.example.com/an-issue/comments?page=3&
createdBy=123",
        "@type": "PartialCollectionView",
        "first": "/an-issue/comments?page=1",
        "previous": "/an-issue/comments?page=2",
        "next": "/an-issue/comments?page=4",
        "last": "/an-issue/comments?page=498"
    },
    "search": {
        "@id": "hydra:search",
        "@type": "hydra:TemplatedLink"
        ...
    }
}


   - Where do operations go to create a new comment?
   - How about search filters that were used on the collection endpoint,
   are they included in the ID?


Also is the current iteration of the spec considered stable enough to use
in production? If not i was considering "wrapping" hydra around my custom
context until the official release. Any help would be greatly appreciated.


Thanks,

-Ardie

Received on Wednesday, 16 August 2017 18:40:36 UTC