Last active
December 29, 2015 03:08
-
-
Save dadamssg/7605129 to your computer and use it in GitHub Desktop.
This file contains 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
//Why are collections namespaced and single entity responses not? For example: | |
[ | |
{ | |
"name": "Hulk Hogan", | |
"id": "100002" | |
}, | |
{ | |
"name": "Mick Foley", | |
"id": "100003" | |
} | |
] | |
//the above seems more consistent with the following | |
{ | |
"name": "Phil Sturgeon", | |
"id": "511501255" | |
} | |
//or provide the resource type with the single entity response as well | |
{ | |
"users": [ | |
{ | |
"name": "Hulk Hogan", | |
"id": "100002" | |
}, | |
{ | |
"name": "Mick Foley", | |
"id": "100003" | |
} | |
] | |
} | |
//single entity response | |
{ | |
"user": { | |
"name": "Hulk Hogan", | |
"id": "100002" | |
} | |
} |
@philsturgeon thanks. that makes sense. I was going to bring up the possibility of meta data being returned but i can't think of any meta data that would make sense to return with a single entity
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I do not namespace a single resource because there is only one thing it could possibly be: the resource you asked for.
I namespace collections because you can have pagination and other meta data in there.
But you can do whatever you like. :)