description: "... in depth text ..."
}
}
- Right now I am debating whether to continue using a special "hrefTemplateParameters" list that documents the available URL template parameters - or simply share the parameters with the (optional) payload and let it all be described by JSON schema.
So, for instance, here is a templated link with schema describing the template parameters:
@controls
{
query:
{
A basic JSON action (default method is POST):
@controls
{
create:
{
type: "json",
schemaUrl: "http://...",
title: "Create new issue"
}
}
A JSON action with a templated request body:
@controls:
{
create:
{
href: "http://...",
type: "json",
schemaUrl: "http://...",
template:
{
title: "Enter title",
severity: 3,
trackingId: "87bd83hja",
securityToken: "7nbdi-2367eg",
last-updated: "2015-01-01T10:32:10"
}
}
}
- In the above example the client is supposed to take the "template" object and merge its request values into it, such that for instance "title" and "severity" is replaced with user input, but "trackingId", "securityToken" and "last-updated" are kept unmodified (for business tracking, security and avoiding lost updates).
The most complex example combines a templated URL and a request body. The description below is equivalent to the previous one:
@controls:
{
create:
{
href: "http://...?trackingId=87bd83hja&title={title}",
isHrefTemplate: true,
type: "json",
schemaUrl: "http://...",
template:
{
title: "Enter title",
severity: 3,
securityToken: "7nbdi-2367eg",
last-updated: "2015-01-01T10:32:10"
}
}
}
The client is supposed to react as follows:
- If no template object exists then use an empty JSON object as default value.
- Take the template object and merge it into the UI (not required, but recommended).
- Let the user change values.
- Merge the user input into the template object.
- Evaluate the URL template and replace parameters with values from the template object.
- Initiate the HTTP request with the assigned method, at the calculated URL, with the template object serialized as JSON in the body.
Then we have some special cases like having a link(?) with a DELETE method:
@controls
{
remove:
{
href: "http://...",
method: "DELETE"
}
}
Another funny ability (that Darell Miller pointed out in another discussion group) is to be able to POST a raw image to a URL where the image title and similar is encoded in the URL:
@controls:
{
addImage:
{
method: "POST",
type: "raw",
accept: ["image/jpeg", "image/png"],
schemaUrl: "http://..."
}
}
/Jørn
- Merge the