I go this wierd error:
TypeError: validate_schema() got an unexpected keyword argument 'partial'
using this code with flask_marhsmallow, flask_restx and flask_accepts:
schemas:
class EmailSchema(ma.Schema):
email = ma.Email()
class UsernameSchema(ma.Schema):
username = ma.String()
class ConfirmPasswordSchema(ma.Schema):
password = ma.String()
confirmation = ma.String()
@validates_schema
def validate_schema(self, data):
if data.password != data.confirmation:
raise ValidationError("Incorrect password confirmation")
class AccountSchema(ma.SQLAlchemySchema, EmailSchema, UsernameSchema, ConfirmPasswordSchema):
class Meta:
model = User
id = ma.Integer(required=True)
name = ma.String(required=True)
usage of schema
@api.route('/')
class Account(Resource):
@accepts(schema=AccountSchema, api=api)
@responds(schema=AccountSchema, api=api)
def post(self):
...
Is it possible that there is a problem with extending schemas?
See https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.decorators
Methods decorated with pre_load, post_load, pre_dump, post_dump, and validates_schema receive many as a keyword argument. In addition, pre_load, post_load, and validates_schema receive partial. If you don’t need these arguments, add **kwargs to your method signature.
@validates_schema
def validate_schema(self, data, **kwargs):
Most helpful comment
See https://marshmallow.readthedocs.io/en/stable/api_reference.html#module-marshmallow.decorators