简体   繁体   English

flask_restx fields.Raw 不允许 None

[英]flask_restx fields.Raw does not allow None

I just switched from flaks_restplus to flask_restx.我刚从 flaks_restplus 切换到 flask_restx。 I start getting the marshal error.我开始收到元帅错误。

jsonschema.exceptions.ValidationError: None is not of type 'object'

I defined this field in my modal, and the dict I passed in.我在我的模态中定义了这个字段,以及我传入的字典。

"my_field": fields.Raw

{... 'my_field': None}

How can I allow None for the field?我怎样才能允许 None 用于该领域?

I guess I found the answer.我想我找到了答案。 The field I defined is wrapped in field.Nested()我定义的字段被包裹在field.Nested()

I have to pass in the optional parameter field.Nested(myModel, skip_none=True)我必须传入可选参数field.Nested(myModel, skip_none=True)

It is not intuitive...这不直观...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM