-
-
Save therabidbanana/2036705 to your computer and use it in GitHub Desktop.
A potential new version of hal
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
I've been playing with the idea of combining the data array defined in application/collection+json | |
(http://amundsen.com/media-types/collection/format/) with hal links for templated data. | |
Seems like a good way to keep the media type lightweight while allowing the api to specify the fields | |
it would like passed to a given resource. | |
I haven't really given much thought to an xml variation, but I took a stab at it as well. |
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
{ | |
"_links": { | |
"ex:basic": { "href": "/bleh" } | |
"ex:search": { "href": "/search_for;{searchTerm}"} | |
"ex:widget": { "href": "/widgets", | |
"data": [ | |
{"name": "name", "type": "string"}, | |
{"name": "description", "type": "string"} | |
] } | |
} | |
} |
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
<resource href="/" xmlns:ex="http://example.org/rels/"> | |
<link rel="ex:basic" href="/bleh" /> | |
<link rel="ex:search" href="/search_for;{searchTerm}" /> | |
<link rel="ex:widget" href="/widgets"> | |
<data name="name" type="string" /> | |
<data name="description" type="string" /> | |
</link> | |
</resource> |
That sounds reasonable. I can definitely see the advantage of separating those concerns. I started with a _template on the root json object that contained the data array, but wasn't sure whether it'd be preferable to add a new root element or to build on the existing ones.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Personally, I don't like the idea of using link as a templated write control - I'd much rather see this under a separate
_controls
and<control> ... </control>
in JSON and XML respectively