-
-
Save hamnis/7351869 to your computer and use it in GitHub Desktop.
{ | |
"collection": { | |
"href": "http://example.com", | |
"accept-bulk": "application/vnd.collection-templates+json", | |
"template": { | |
"data": [ | |
{"name": "foo"} | |
] | |
} | |
} | |
} |
{ | |
"templates": [ | |
{ | |
"data": [ | |
{"name": "foo", "value": "bar"} | |
] | |
}, | |
{ | |
"data": [ | |
{"name": "foo", "value": "baz"} | |
] | |
} | |
] | |
} |
"templates":[]
is an existing extension[1] but not sure it's in use. the array is a safe extension (although i have my reservations about it).
[1] https://github.com/collection-json/extensions/blob/master/templates.md
seems you could get the same results using this:
{
"templates": [
{
"data": [
{"name": "foo", "value": "bar"},
{"name": "foo", "value": "baz"}
]
}
]
}
I knew that the templates extension exists.
I would use a new media type for this, as this is a write-only interaction.
I am also aware that it would be possible to multiple data entries, however this breaks quickly once your template becomes more advanced.
Consider this:
{
"collection": {
"href": "http://example.com/events",
"template": {
"data": [
{"name": "timestamp"},
{"name": "classifier"},
{"name": "event", "object": {}}
]
}
}
}
(this is using the "value-types" extension)
If you for instance need to add 100k new events to this, this quickly becomes 100k POSTs.
While I personally don't really have a problem with this, my solution allows multiple POSTs to be merged to one.
Weather this is a good idea or not, remains to be seen.
New media type: application/vnd.collection-templates+json or something.