【问题标题】:flask_restx fields.Raw does not allow Noneflask_restx fields.Raw 不允许 None
【发布时间】:2021-06-03 21:58:35
【问题描述】:

我刚刚从 flaks_restplus 切换到了 flask_restx。我开始收到 marshal 错误。

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

我在模态中定义了这个字段,以及我传入的字典。

"my_field": fields.Raw

{... 'my_field': None}

我怎样才能允许 None 用于该字段?

【问题讨论】:

    标签: python json-schema-validator flask-restplus flask-restx


    【解决方案1】:

    我想我找到了答案。 我定义的字段包裹在field.Nested()

    我必须传入可选参数field.Nested(myModel, skip_none=True)

    这不直观...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 2022-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多