ruby-grape / grape-active_model_serializers

User active_model_serializers with Grape
MIT License
139 stars 68 forks source link

[RFC] Infer serializer from api namespace. #58

Closed drn closed 8 years ago

drn commented 8 years ago

@nhinze - I tested this against your project and it will solve your issue. You can try it out with the following:

gem 'grape-active_model_serializers', github: 'ruby-grape/grape-active_model_serializers', branch: 'namespace-inferred-serializer'

@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:

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 the namespace 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

dblock commented 8 years ago

Nice work, let us know when this is ready to merge.

drn commented 8 years ago

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

dblock commented 8 years ago

Now that #59 is merged, this needs a rebase, thanks.

dblock commented 8 years ago

This is superseded by #60 and can be closed, right?

drn commented 8 years ago

Yup! Closing