简体   繁体   中英

flask_restx fields.Raw does not allow None

I just switched from flaks_restplus to 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?

I guess I found the answer. The field I defined is wrapped in field.Nested()

I have to pass in the optional parameter field.Nested(myModel, skip_none=True)

It is not intuitive...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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