Open
Description
Expected behavior vs actual behavior
I created 2 models and added has_one
to the serializer, by default, it returns the relationship object:
{
"data": {
"id": "1",
"type": "posts",
"attributes": { "title": "my title" },
"relationships": {
"comment": { "data": { "id": "2", "name": "John", "text": "whatever" } }
}
}
}
However, I was expecting it to be
{
"data": {
"id": "1",
"type": "posts",
"attributes": {
"title": "my title"
},
"relationships": {
"comment": { "data": { "id": "2", "type": "comment" } }
}
}
}
JSONAPI specifies that
The value of the relationships key MUST be an object (a “relationships object”).
See what this means here: http://jsonapi.org/format/#document-resource-object-linkage
Basically, if I passed included
, then I'd expect to see the actual objects. Otherwise it only makes sense to return the Object Linkage (which is what JSONAPI specifies anyway).
Steps to reproduce
Just create 2 serializers and add a has_one
to one of them.
Environment
ActiveModelSerializers Version: 0.10.4
Integrated application and version (e.g., Rails, Grape, etc): Rails