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

Incorrect interpretation of the HAL RFC wrt curies #97

Closed
joshco opened this issue Mar 12, 2016 · 8 comments
Closed

Incorrect interpretation of the HAL RFC wrt curies #97

joshco opened this issue Mar 12, 2016 · 8 comments
Labels

Comments

@joshco
Copy link

joshco commented Mar 12, 2016

Im having trouble with curies and what appears to be a difference in behavior in hyperclient vs hal-browser. Hyperclient is templating urls when not expected.
My server returns:

"curies": [
      {
        "name": "osdi",
        "href": "http://opensupporter.github.io/osdi-docs/{rel}",
        "templated": true
      }
    ],
    "osdi:tags": {
      "href": "http://demo.osdi.io/api/v1/tags",
      "title": "The collection of tags in the system"
    },

In the hal browser, the curie is just used for documentation links and it does not reformat the link URL, which is already absolute.
But in hyperclient, it is reformatting the url for the link itself as:

http://opensupporter.github.io/osdi-docs/http://demo.osdi.io/api/v1/tags

How do I reconcile this? Can I disable curie reformatting in hyperclient?

Reference: #64

@joshco
Copy link
Author

joshco commented Mar 12, 2016

pull request fix created

@dblock dblock added the bug label Mar 12, 2016
@dblock
Copy link
Collaborator

dblock commented Mar 12, 2016

This is clearly a bug, thanks for suggesting a fix.

@dblock
Copy link
Collaborator

dblock commented Mar 13, 2016

About this issue here, why are you using a curie in the osdi:tags example? Should this just be tags, in which case the issue is moot?

@joshco
Copy link
Author

joshco commented Mar 14, 2016

perhaps we should separate the two issues and I'll move the query params out of this issue.
I think the issue of avoiding expansion when the href is already absolute should stay open.

@joshco
Copy link
Author

joshco commented Mar 14, 2016

I think there is a misinterpretation of how curies are supposed to be used in HAL. Curies are meant to shorten the key names in a _links hash, not the actual href associated with a link in the _links hash, as well as provide a link to the human readable documentation for said link.

https://tools.ietf.org/html/draft-kelly-json-hal-07#section-8.2

8.2. Link relations

Custom link relation types (Extension Relation Types in [RFC5988])
SHOULD be URIs that when dereferenced in a web browser provide
relevant documentation, in the form of an HTML page, about the
meaning and/or behaviour of the target Resource. This will improve
the discoverability of the API.

So actually, hyperclient shouldn't be doing any template expansion when dealing with curie syntax at all when navigating to a curied link.

The CURIE Syntax [W3C.NOTE-curie-20101216] MAY be used for brevity
for these URIs. CURIEs are established within a HAL document via a
set of Link Objects with the relation type "curies" on the root
Resource Object. These links contain a URI Template with the token
'rel', and are named via the "name" property.

{
"_links": {
"self": { "href": "/orders" },
"curies": [{
"name": "acme",
"href": "http://docs.acme.com/relations/{rel}",
"templated": true
}],
"acme:widgets": { "href": "/widgets" }
}
}

The above demonstrates the relation "http://docs.acme.com/relations/
widgets" being abbreviated to "acme:widgets" via CURIE syntax.

When a curie is present, the href template inside the curie is how to find the documentation, not the resources. In the example above (from the spec), the resource is widgets, but the curie href refers to the documentation for wigets.

@joshco
Copy link
Author

joshco commented Mar 14, 2016

Created pull request for that
#100

@dblock
Copy link
Collaborator

dblock commented Mar 14, 2016

Fixed in #101.

@dblock dblock changed the title Curie behavior conflict Incorrect interpretation of the HAL RFC wrt curies Mar 14, 2016
@dblock
Copy link
Collaborator

dblock commented Mar 15, 2016

Closed via #101.

@dblock dblock closed this as completed Mar 15, 2016
dblock added a commit to ruby-grape/grape-with-roar that referenced this issue Mar 15, 2016
dblock added a commit to dblock/doppler that referenced this issue Mar 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants