chris
November 11, 2014, 7:53pm
1
My response looks like this
{ "members": [
{ "id": "1"
"name": "My Name"
"followerCount": 2
"followingCount": 4
},
{ "id": "2"
"name": "My Name Too"
"followerCount": 12
"followingCount": 6
}
],
"links": {
"members.followers": "http://example.com/members/{members.id}/followers",
"members.following": "http://example.com/members/{members.id}/following",
}
}
}
This is a standard JSON API way to do links instead of including it in the member objects themselves, but I am getting the warning message:
Encountered “links” in payload, but no model was found for model name
“link”
Is there support for this format that I’m missing somehow or do I need to hack away at this?
Preexo
November 12, 2014, 4:23am
2
I make the links part of the members properties, don’t know if that is the official way, but works for me
e.g.
{ "members": [
{ "id": "1"
"name": "My Name"
"followerCount": 2
"followingCount": 4
"links": {
"members.followers": "http://example.com/members/1/followers",
"members.following": "http://example.com/members/1/following",
}
},
...
],
}
but you can always adjust your (un)serializer and put the answer of the API in shape by hand…
chris
November 12, 2014, 3:16pm
3
Thanks for the response. They are both valid ways of doing links. Some of our APIs come back that way as well. The top level way is more convenient in the case that there are many members coming back, with 10+ links each. I wrote some serializer code to move the links inside the member property, but it would be nicer to have this as built in support if it should be.