TemplatedLink

I wonder, how hydra:TemplatedLink should be used.

The way, I understand it is this:

Some API respone:

{"@context": "/Flubber.jsonld",
 "@type": "Flubber",
 "flup": "schwubb",
 "link": {"template": "http://example.com/flups/{flup}",
              "mappings": {"variable": "flup", "property": "flup"}}
}

API-description:
{
[..]
"supportedClasses": [
 {
    "@id": "Flubber",
    "supportedProperties": [
       {
          "property": {"@id": "link", "@type": "hydra:TemplatedLink"}
       }
   }
[..]
}

This looks very verbose. Is it necessary to have a
hydra:IriTemplateMapping with a hydra:IriTemplate? Are there arguments
against having variabale names mapping to properties with equal name
by default? So in the example above, the mappings could be omitted.

A TemplatedLink as I understand it is only useful, if it can be
applied to several items. I think it is very common to have a API
response contain a collection of JSON objects at some place of the
JSON structure. I wonder, how I can say, that a TemplatedLink should
be used for a distinct set of objects. Did I miss something, or is
this still missing?

I could image something like this:

{ [..]
"items": [
   {"name": "foo"},
   {"name": "bar"}
  ]
 "link": {"template": "http://example.com/flups/{name}", "appliesTo": "items"}
}

I am still trying to grok, how a Hypertext-API could work. We have a
API which quite often returns collections of items, each of which has
a set of links or actions. One approach is to make it all explicit and
have every link as a property of each item. This is easy to use, but
it bloats the response. So templated links look like a good
alternative. But I don't see, how these work without "out-of-bounds"
information of how to apply them.


Regards

Matthias

Received on Thursday, 11 July 2013 09:28:33 UTC