-
Notifications
You must be signed in to change notification settings - Fork 14
Add a kwarg to override relationships rendered in jsonapi errors #6
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
base: master
Are you sure you want to change the base?
Conversation
…jsonapi errors This especially allows to render jsonapi errors without a jsonapi payload (such as GET requests) by passing `relationships: {}`
Thanks for this PR! I think my preference would be |
I actually meant to commit My suggestion in this case def render_errors_for(record, relationships: nil)
relationships = if relationships == false
{}
else
relationships || deserialized_params.relationships
end
validation = Serializers::Validation.new(record, relationships)
end So we need to explicitely pass |
Having thought about this a bit more, I think your original commit was probably the way to go. I'm looking for def render_errors_for(record, relationships: {})
# ... code ...
relationships || deserialized_params.relationships # at some point If we get that + a spec I'll merge 👍 |
# Defaults to the deserialized data.relationships of Json:api Payload | ||
# @param record [ ActiveModel ] Object that implements ActiveModel | ||
def render_errors_for(record, relationships: {}) | ||
relationships || deserialized_params.relationships |
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.
this would never hit the right side of ||
since this defaults to {}
. Maybe line 6 should be nil
, but you can still pass a custom hash?
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.
Hey thanks and sorry about that, I'm still working on it and the test, didn't mean to push that commit ^^"
Regarding the test, since it's quite a big integration test I need some more time to work on it
This especially allows to render jsonapi errors without a jsonapi payload (such as GET requests) by passing
relationships: {}
Features
relationships: false
to send empty second argumentrelationships:
Argument is optional