Skip to content

Commit

Permalink
Restore behaviour of marshmallow 2 with unknown keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cript0nauta committed Feb 22, 2019
1 parent c88ab77 commit a307e8a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from sqlalchemy.orm.exc import NoResultFound, ObjectDeletedError
from sqlalchemy.inspection import inspect
from sqlalchemy import func
from marshmallow import Schema
from marshmallow import Schema, EXCLUDE
from marshmallow.compat import with_metaclass
from marshmallow.validate import Length
from marshmallow_sqlalchemy import ModelConverter
Expand Down Expand Up @@ -164,6 +164,11 @@ def _get_schema_instance(self, route_kwargs, **kwargs):
"""
kwargs['context'] = self._set_schema_context(
kwargs.get('context', {}), **route_kwargs)

# If the client send us fields that are not in the schema, ignore them
# This is the default in marshmallow 2, but not in marshmallow 3
kwargs['unknown'] = EXCLUDE

return self._get_schema_class()(**kwargs)

def _set_schema_context(self, context, **kwargs):
Expand Down

0 comments on commit a307e8a

Please sign in to comment.