-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Milestone
Description
Expected Behavior
I expected relationships serialized with set_id defined, to use the return value of set_id in the serialized data.
Serializers
class Serializers::Base
include FastJsonapi::ObjectSerializer
set_id { |object| object.encoded_id } # <- encoded id!
end
class Serializers::Employee < Serializers::Base
set_type :employee
end
class Serializers::Pro < Serializers::Base
set_type :pro
end
class Serializers::Consult < Serializers::Base
set_type :consult
belongs_to :employee, serializer: Serializers::Employee
belongs_to :pro, serializer: Serializers::Pro
endExpected JSON
{
"data": {
"id": "x6vx5z",
"type": "consult",
"relationships": {
"employee": {
"data": {
"id": "g5v29z",
"type": "employee"
}
},
"pro": {
"data": {
"id": "rxvemv",
"type": "pro"
}
}
}
}
}Actual JSON
Note: the top level "consult" id is encoded correctly where the relationships are displaying the integer id
{
"data": {
"id": "x6vx5z",
"type": "consult",
"relationships": {
"employee": {
"data": {
"id": "2",
"type": "employee"
}
},
"pro": {
"data": {
"id": "3",
"type": "pro"
}
}
}
}
}Specifications
GIT
remote: https://github.com/fast-jsonapi/fast_jsonapi
revision: c305b699a970ba60e77ba5d7d1f962390bcdc363
specs:
fast_jsonapi (1.6.0)
activesupport (>= 4.2)
- Ruby version: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
Maybe possibly related to the open pr: #45
Felt like this was a simple enough example to illustrate just in case it's not related!
Thanks for any insights (or a workaround?)
😎
phlegx, umihico, lekemula, fragkakis and brooksco
Metadata
Metadata
Assignees
Labels
No labels