Skip to content

Instantly share code, notes, and snippets.

@Dynom
Last active December 14, 2015 22:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dynom/5159873 to your computer and use it in GitHub Desktop.
Save Dynom/5159873 to your computer and use it in GitHub Desktop.
Dealing with root-level curies in the HAL specification. This example is a modified version of the one mentioned on: http://stateless.co/hal_specification.html This example introduces a root-level _links definition with CURIE definitions. These definitions must be available in nested attributes, with the option to override a CURIE definition, wi…
{
"_links": {
"api-root:self": { "href": "orders" },
"api-root:next": { "href": "orders?page=2" },
"api-root:find": { "href": "orders{?id}", "templated": true },
"api-root:admin": [
{ "href": "admins/2", "title": "Fred" },
{ "href": "admins/5", "title": "Kate" }
],
"_curies" : [
{ "name": "api-root", "href": "https://api.example.org/{?href}", "templated": true},
{ "name": "file-api-root", "href": "https://pool-2.static.example.org/file/{?href}", "templated": true }
]
},
"currentlyProcessing": 14,
"shippedToday": 20,
"_embedded": {
"orders": [{
"_links": {
"_curies": [
{ "name": "file-api-root", "href": "https://pool-99.static.example.org/file/{?href}", "templated": true }
],
"api-root:self": { "href": "orders/123" },
"api-root:basket": { "href": "baskets/98712" },
"api-root:customer": { "href": "customers/7809" },
"file-api-root:sellHistoryChartImage": { "href": "chart/20130314-123.png" },
"trackAndTrace": { "href": "https://shippingcompany.com/track/2374981" }
},
"total": 30.00,
"currency": "USD",
"status": "shipped",
},{
"_links": {
"api-root:self": { "href": "orders/124" },
"api-root:basket": { "href": "baskets/97213" },
"api-root:customer": { "href": "customers/12369" },
"file-api-root:sellHistoryChartImage": { "href": "chart/20130314-124.png"}
},
"total": 20.00,
"currency": "USD",
"status": "processing"
}]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment