You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a simple CRUD class (based on flask.views.MethodView).
The Schema class is based on marshmallow_sqlalchemy.SQLAlchemyAutoSchema.
@_bp.arguments(AccountGroupModelSchema)@_bp.response(200, AccountGroupModelSchema)defpatch(self, updated, account_group_id):
"""Update an existing object."""item=AccountGroup.query.get_or_404(account_group_id)
item.name=updated.nameoritem.namedb.session.commit()
returnitem
When submitting a HTTP PATCH, the JSON payload contains only those fields being modified, e.g. { "name": "new_name" }. This means the Schema validation fails, because mandatory fields are not present.
Is there anyway to handle validating the fields that are present AND rejecting any fields that are unknown but NOT failing validation for missing (as not being modified) fields in a PATCH? Or do I just have to take the JSON directly, update the entity, then validate prior to updated in the ORM?