SQLAlchemy @property causes 'Unknown Field' error in Marshmallow with dump_only

江枫思渺然 提交于 2019-12-02 07:24:36
Jérôme

In marshmallow 2, unknown or dump_only fields are ignored from input. Unless the user decides to add his own validation to error on them.

In marshmallow 3, we changed that to offer three possibilities (see docs):

  • RAISE (default)
  • EXCLUDE (like marshmallow 2)
  • INCLUDE (pass data without validation)

There's been discussions about how to deal with dump_only fields and we came to the conclusion that from client perspective, those should be treated just as unknown fields (see https://github.com/marshmallow-code/marshmallow/issues/875).

Bottom line, your PUT payload should not include dump_only fields. Or you could set the EXCLUDE policy to your schema, but I'd favor the former option.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!