-
Notifications
You must be signed in to change notification settings - Fork 68
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
[RFC] Infer serializer from api namespace. #58
Conversation
9ab8824
to
5654c4f
Compare
Nice work, let us know when this is ready to merge. |
rescue LoadError | ||
# attempt to fetch serializer through namespace inference | ||
serializer = namespace_inferred_serializer(options) | ||
end if serializer.nil? |
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.
I would extract this into a method, especially that inside a method you can rescue
without a begin
since you can do that on the entire method.
Cool, I'm traveling until Thursday but I'll update this after then. I'm planning on refactor the logic here pretty significantly if that's cool |
Now that #59 is merged, this needs a rebase, thanks. |
This is superseded by #60 and can be closed, right? |
Yup! Closing |
@nhinze - I tested this against your project and it will solve your issue. You can try it out with the following:
@dblock, @jrhe, @siong1987 - This change makes it so that the serializer lookup logic attempts to use the api namespace as the namespace of the serializer for both collection and resource inputs. This is a quick pass at the logic and not ready to be merged in. There are a number of items that I think still need to happen:
namespace
option back into serializer lookup so we don't have to duplicate serializer lookup logic in grape-ASMoptions[:version]
? Downsides are nested namespaces don't work well.Without this pull, grape-ASM tries to resolve the serializer namespace using
options[:version]
and it only works for non-collection inputs. Otherwise, it just uses ASM's serializer lookup logic. I think using the namespace of the requesting api as the namespace of the serializer is probably the best bet and have ASM add support back for thenamespace
option and ensure it passes it through from collection serializers to the member serializers. Thoughts?I'll be traveling until Thursday, but will get back to this after I return