RE: TemplatedLink

On Thursday, July 11, 2013 12:07 PM, Matthias Lehmann wrote:
> 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}"
>   }
>   ]
> }

Yeah, that's a pretty clever design if your URI template is always exactly
the same. You would probably nevertheless need to define the mappings in
that template definition.


> 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}"
>   }
>  ]
> }

Hmm... I'm a bit on the fence about this. By giving it a URL you set some
expectations of stability. In this case that's probably OK because you can
update the template nevertheless but be aware that you might run into
consistency issues if a client, e.g., caches the API description longer than
it should. It would be quite difficult to debug such a case because
everything seems to work, the client just creates wrong URLs because the URL
template it uses is outdated.

You also need to make sure that you type the link property as TemplatedLink
otherwise clients might mistake it with a concrete link.


> Am I getting closer?

I would say so. The beauty of all this is that everything is identifiable
and thus reusable. I have to admit that I forgot that myself in my last mail
:-P


--
Markus Lanthaler
@markuslanthaler

Received on Thursday, 11 July 2013 10:37:56 UTC