-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] Fetch json key from item serializer if empty collection is pass… #1537
Conversation
Fixes #1536 |
2f3f987
to
ba876c9
Compare
…ed to collection serializer and each_searializer is specified.
ba876c9
to
50cf6f4
Compare
def json_key | ||
'messages' | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you mind moving this to the test file? poro's is a little cluttered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -39,8 +45,15 @@ def paginated? | |||
private | |||
|
|||
def derived_root | |||
key = serializers.first.try(:json_key) || object.try(:name).try(:underscore) | |||
key.try(:pluralize) | |||
serializers.first.try(:json_key).try(:pluralize) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aside: we really need to replace Serializer#json_key
with Serializer._type
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here what about:
def derived_root
return unless serializers.empty?
serializers.first.json_key.to_s.pluralize
end
Makes it more readable IMO.
@RomanKapitonov are you planning on coming back to this? |
@RomanKapitonov are you planning on helping resolve the PR Review comments? :-\ |
Followed up with #1618 |
…ed to collection serializer and each_searializer is specified.