Last active
December 27, 2015 15:59
-
-
Save hamnis/7351869 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"collection": { | |
"href": "http://example.com", | |
"accept-bulk": "application/vnd.collection-templates+json", | |
"template": { | |
"data": [ | |
{"name": "foo"} | |
] | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"templates": [ | |
{ | |
"data": [ | |
{"name": "foo", "value": "bar"} | |
] | |
}, | |
{ | |
"data": [ | |
{"name": "foo", "value": "baz"} | |
] | |
} | |
] | |
} |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hamnis
"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