Skip to content
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

Response fields filtering/masking #79

Open
DanielCardonaRojas opened this issue Nov 6, 2017 · 3 comments
Open

Response fields filtering/masking #79

DanielCardonaRojas opened this issue Nov 6, 2017 · 3 comments

Comments

@DanielCardonaRojas
Copy link

Hi,

I'd like to know if there is an easy way to modify the patch to mask the response fields by a query parameter (like /api/users?fields=email,name), I've tried the restplus approach with the X-Fields but that no longer works with the patch.

I thought the way to go would be to use a schema factory as shown in then marshmallow docs:
http://webargs.readthedocs.io/en/latest/advanced.html. But I don't understand the code base enough to intervene.

@frol
Copy link
Owner

frol commented Nov 6, 2017

There is no built-in functionality at the moment, though I see the value in such a feature. Currently, given you may not want to spend too much time on this, I would recommend you add a parameter to the users endpoint accepting fields (marshmallow List field type will match your needs) and then in the endpoint itself you return a serialized output:

return schemas.BaseUserSchema(only=fields, many=True).dump(users).data

@DanielCardonaRojas
Copy link
Author

Perfect, sounds fine. It did seem a little tricky to route the request object down to the response decorator, you're probably right, this would be time consuming.

Thanks for your quick reply.

@douglasfabretti
Copy link

I'm interested on this feature as well, I see a big value on having this OOO on flask-restplus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants