Skip to content

Don't use curies to expand resource links. Curies hrefs are for doc links - #100

Closed
joshco wants to merge 1 commit into
codegram:masterfrom
joshco:dont_use_curies_to_expand_links
Closed

joshco wants to merge 1 commit into
codegram:masterfrom
joshco:dont_use_curies_to_expand_links

Conversation

@joshco

@joshco joshco commented Mar 14, 2016

Copy link
Copy Markdown

Re issue: #97
https://tools.ietf.org/html/draft-kelly-json-hal-07#section-8.2
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.

@dblock

dblock commented Mar 14, 2016

Copy link
Copy Markdown
Collaborator

That would mean I totally misunderstood curies, which would be, to say the least, unfortunate. I asked https://groups.google.com/forum/#!topic/hal-discuss/Vr7EYhUzWAE to be sure. If it's the case this PR needs a lot of work, including updating tests, documentation, etc.

Note that http://stackoverflow.com/questions/28154998/can-anyone-provide-a-good-explanation-of-curies-and-how-to-use-them agrees with you.

@dblock

dblock commented Mar 14, 2016

Copy link
Copy Markdown
Collaborator

I read everything again and I am pretty sure you're right @joshco, thanks for pointing this out. Can you please take a look at #101 and comment on it, which is the full version of this PR. I'll close this one in favor of #101.

@dblock dblock closed this Mar 14, 2016
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

Successfully merging this pull request may close these issues.

2 participants