Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added hydra:memberTemplate #158

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions spec/latest/core/core.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"last": { "@id": "hydra:last", "@type": "@id" },
"next": { "@id": "hydra:next", "@type": "@id" },
"previous": { "@id": "hydra:previous", "@type": "@id" },
"memberTemplate": "hydra:memberTemplate",
"Link": "hydra:Link",
"TemplatedLink": "hydra:TemplatedLink",
"IriTemplate": "hydra:IriTemplate",
Expand Down Expand Up @@ -386,6 +387,15 @@
"range": "xsd:string",
"vs:term_status": "testing"
},
{
"@id": "hydra:memberTemplate",
"@type": "hydra:TemplatedLink",
"label": "collection member IRI template",
"comment": "A IRI template to directly access collection members.",
"range": "hydra:IriTemplate",
"domain": "hydra:Collection",
"vs:term_status": "testing"
},
{
"@id": "hydra:TemplatedLink",
"@type": "hydra:Class",
Expand Down
46 changes: 46 additions & 0 deletions spec/latest/core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,52 @@ <h3>Templated Links</h3>
-->
</pre>
</section>

<section>
<h3>Collection member link template</h3>

<p>In some circumstances it is useful to give a direct access to a collection's
members by providing an instruction on how to construct an URL to the client.
This URL then can be used either to obtain member's details or to update it.
In order to support this scenario Hydra provides the <i>memberTemplate</i> property
to describe the URL structure of collection members with an <i>IriTemplate</i>.</p>

<pre class="example nohighlight" data-transform="updateExample"
title="Collection with a direct access to its members via an IRI template">
<!--
{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://api.example.com/users",
"@type": "Collection",
"totalItems": "329",
"member": [
####... members of the Collection ...####
],
"memberTemplate": {
"@type": "IriTemplate",
"template": "http://api.example/com/users/{userName}",
"variableRepresentation": "hydra:BasicRepresentation",
"mapping": {
"@type": "IriTemplateMapping",
"variable": "userName",
"property": "http://api.example.com/vocab#userName",
"required": true
},
"operation": {
"@type": "Operation",
"method": "PUT",
"expects": "http://api.example.com/vocab#User"
}
}
}
-->
</pre>

<p>In the example above, the API describes how to directly access a member of the
<i>/users</i> collection through an IRI template requiring the user name.
There is also an operation that tels a client that it can use HTTP put on
those resources.</p>
</section>

<section>
<h3>Description of HTTP Status Codes and Errors</h3>
Expand Down