- From: Matthias Lehmann <mat@matlehmann.de>
- Date: Thu, 11 Jul 2013 12:07:27 +0200
- To: public-hydra@w3.org
I thought about it some more. Maybe it is supposed to work like this: API response: { [..] "items": [ {"name": "foo", "link": "_:mytemplate"}, {"name": "bar", "link": "_:mytemplate"} ] "templates": [ { "@id": "_:mytemplate", "template": "http://example.com/flups/{name}" } ] } Or maybe even API response: { "@context" { "my": "http:example.com/api/vocab#", }, "items": [ {"name": "foo", "link": "my:mytemplate"}, {"name": "bar", "link": "my:mytemplate"} ] } API description: { "@context" { "my": "http:example.com/api/vocab#", }, "@graph": [ [..] { "@id": "my:mytemplate", "template": "http://example.com/flups/{name}" } ] } Am I getting closer? 2013/7/11 Matthias Lehmann <mat@matlehmann.de>: > 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 10:10:12 UTC