Re: Using hydra:Link

Hi Dietrich

Answers inline

October 7 2014 8:24 AM, "Dietrich Schulten" <ds@escalon.de> wrote: 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> I have difficulty to express that an attribute is supposed to be a
> hydra:Link.
> 
> The spec says I can define a Link in a separate json object like this:
> {
> "@context": "http://www.w3.org/ns/hydra/context.jsonld",
> "@id": "http://api.example.com/vocab#comments",
> "@type": "Link".
> }
> 
> I am not quite sure how that separate json object should be used.
> I read the definition above like this:
> - - use hydra as context
> - - the canonical link of this json object is
> "http://api.example.com/vocab#comments"
> - - the type of this json object is Link
> To me, that makes no sense. No comments term is defined and it does
> not seem to say that the value of the comments term should be of type
> Link.
>
This is precisely where the comments term is defined in that very example document from the specs.
>
> Do I miss some idiom here or is there something wrong? 
>

The 'cannonical link' as you put it is traditionally called an identifier. Let's stick to that. This helps accept the fact that the #commments link is itself also a resource of type hydra:Link.

>
> I would have expected it to be an external context which defines the
> term comments, but wouldn't it then be something like:
> {
> "@context": [
> "http://www.w3.org/ns/hydra/context.jsonld",
> {
> "comments": {
> "@id": "http://api.example.com/vocab#comments",
> "@type": "Link"
> }
> }
> ],
> "@id": "http://api.example.com/vocab.jsonld"
> }
>

You are close. Though the definition of #comments would be outside of the context. It's a represention of the #comments resource after all.
 
>
> The spec continues that I can use the above definition for a comments
> Link like this:
> 
> {
> "@context": {
> "comments": "http://api.example.com/vocab#comments"
> },
> "@id": "http://api.example.com/an-issue",
> "title": "An exemplary issue linking to its comments",
> "comments": { "@id": "http://api.example.com/an-issue/comments" }
> }
> 
> I do not understand how the client would know that the former
> definition of #comments as a Link applies to the latter usage. I do
> not see that the client is advised to read the former json file or any
> external context. How can it understand that the comments property
> value is a Link?
> 

The client has two options. The preferred is to look up the ApiDocumentation (from Link header) as described later in hydra specs. The ApiDocumentation would include descritpions of terms used in the API, including the #comments. This way the client only needs to make one request for the API meta data.

Another option, in the absence of ApiDocumentation, would be to dereference each property (and @type) to discover links and operations. In JSON-LD (RDF actually) everything is identified by URIs. That's why I emphasised the term identifier above. This means that when you get a resource you can 'GET http://api.example.com/vocab#comments' resource, which will return its description you mention above.

I hope this makes things a little bit clearer.

Regards,
Tom

>
> Best regards,
> Dietrich
> 
> - --
> Dietrich Schulten
> Escalon System-Entwicklung
> Bubenhalde 10
> 74199 Untergruppenbach
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.22 (MingW32)
> 
> iEYEARECAAYFAlQzhtoACgkQuKLNitGfiZMiewCePoEh/Dr3g1CHL8C53OjQbiny
> /V0An2ZvVBOSWkqkLT6upTjlJZghdEDU
> =8+50
> -----END PGP SIGNATURE-----

Received on Tuesday, 7 October 2014 07:15:07 UTC