Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON example and hypertext cache pattern #16

Open
pnsantos opened this issue Mar 12, 2014 · 1 comment
Open

JSON example and hypertext cache pattern #16

pnsantos opened this issue Mar 12, 2014 · 1 comment

Comments

@pnsantos
Copy link

Hi Mike,

I think there was a thread in hal-discuss about this but shouldn't the example in the main page have an ea:order within the links section? like so:

{
    "_links": {
        "self": { "href": "/orders" },
        "curies": [{ "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true }],
        "next": { "href": "/orders?page=2" },
        "ea:find": {
            "href": "/orders{?id}",
            "templated": true
        },
        "ea:admin": [{
            "href": "/admins/2",
            "title": "Fred"
        }, {
            "href": "/admins/5",
            "title": "Kate"
        }],
        "ea:order": [
           { "href": "/orders/123" },
           { "href": "/orders/124" }
        ]
    },
    "currentlyProcessing": 14,
    "shippedToday": 20,
    "_embedded": {
        "ea:order": [{
            "_links": {
                "self": { "href": "/orders/123" },
                "ea:basket": { "href": "/baskets/98712" },
                "ea:customer": { "href": "/customers/7809" }
            },
            "total": 30.00,
            "currency": "USD",
            "status": "shipped"
        }, {
            "_links": {
                "self": { "href": "/orders/124" },
                "ea:basket": { "href": "/baskets/97213" },
                "ea:customer": { "href": "/customers/12369" }
            },
            "total": 20.00,
            "currency": "USD",
            "status": "processing"
        }]
    }
}

According to the section about Hypertext cache pattern:

To activate this client behaviour for a given link, servers SHOULD
add an embedded resource into the representation with the same
relation.

Servers SHOULD NOT entirely "swap out" a link for an embedded
resource (or vice versa) because client support for this technique is
OPTIONAL.

This would imply that to have an embedded resource ea:order there SHOULD be a link ea:order which in this case would be an array of links, where each link points to a resource (which is what is being embedded).

If you agree I can make a pull request.

@jkobus
Copy link

jkobus commented Aug 10, 2016

I'm also interested in answer to this question. Anyone?

Update: https://groups.google.com/d/msg/hal-discuss/O_U1x6Wdz-g/fBtP_oZzLkUJ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants