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

"Partial" deserialization support #290

Closed
taion opened this Issue Oct 3, 2015 · 2 comments

Comments

Projects
None yet
3 participants
@taion
Contributor

taion commented Oct 3, 2015

For implementing PATCH handlers on REST endpoints, it would be useful to have a concept of partial deserialization.

This would mean ignoring missing required fields and default values for missing fields.

I know this sounds a bit weird, but it matches a standard CRUD endpoint fairly well - POST or PUT to that endpoint should use the full validation w/r/t required fields or defaults, but PATCH is intended to apply a partial update and only modify what was actually changed.

I can handle this in userspace by catching ValidationErrors for missing fields, but I don't think I can do the same for ignoring default field values.

Here's the equivalent API in DRF: http://www.django-rest-framework.org/api-guide/serializers/#partial-updates. From my POV I think any partial arg (if you think it makes sense) would best be positioned as a named argument on load, though.

@sloria

This comment has been minimized.

Member

sloria commented Oct 4, 2015

I am open to this; it seems to solve a common problem. For consistency with the many parameter, I think it would make sense as both an argument to the constructor and to load.

sloria referenced this issue in touilleMan/marshmallow-mongoengine Oct 6, 2015

@viniciuschiele

This comment has been minimized.

viniciuschiele commented Oct 6, 2015

I need this feature too, my solution so far was to create another schema for partial update without required and missing attributes and this schema always returns a dict rather than my model. It works well but I'm not happy with it.

A partial argument to the constructor and to load looks good for me.

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