Closed jchannon closed 9 years ago
Sorry I deleted my previous comment, I wasn't thinking.
You would probably want to return an orders collection where the entities are all the orders:
Here's a simple example:
{
"class": [ "collection" ],
"entities": [
{ // order 1},
{ // order 2},
{ // order N}
]
"links": [
{ "rel": [ "self" ], "href": "http://api.x.io/orders" }
]
So this is what I have. How does it look? The one issue I have is on the action of creating an order. I've put array as the type where you would POST an array of items to create the order but I'm pretty sure this is wrong.
{
"class": [
"collection"
],
"properties": null,
"entities": [
{
"class": [
"order"
],
"rel": [
"http://localhost:8080/rels/order"
],
"href": "http://localhost:8080/orders/45323",
"properties": {
"orderNumber": 45323,
"itemCount": 2,
"status": "Pending"
},
"links": null
},
{
"class": [
"order"
],
"rel": [
"http://localhost:8080/rels/order"
],
"href": "http://localhost:8080/orders/6534",
"properties": {
"orderNumber": 6534,
"itemCount": 5,
"status": "Completed"
},
"links": null
}
],
"actions": [
{
"name": "add-order",
"title": "Add Order",
"method": "POST",
"href": "http://localhost:8080/orders/",
"type": "application/json",
"fields": [
{
"name": "orderitems",
"type": "array",
"value": null
}
]
}
],
"links": [
{
"rel": [
"self"
],
"href": "http://localhost:8080/orders/"
}
]
}
I've pushed my code although still WIP here if you want to see https://github.com/jchannon/Nancy.Siren
WRT to the general response it looks pretty good. Personally I'd avoid putting null for properties, just put an empty hash or skip having properties at all.
I don't personally use posting of json, but generally the action looks right to me.
BTW, I just realized this is not the appropriate place for general how to questions. The discussion group is more appropriate: https://groups.google.com/forum/#!forum/siren-hypermedia
You should close this issue and if you have more questions ask at the discussion group.
Have continued it here - https://groups.google.com/forum/#!topic/siren-hypermedia/hU1UTiqSW80
Hi,
I'm just looking into Siren and writing a C# library that can be used with NancyFX to return Siren responses.
As part of my demo I was going to use your
Order
example. On my/
route in the API I return an array of orders but I'm unsure what the payload should look like.Any chance you could help me out?
Thanks