Python 如何在Flask Restx中对其中一个进行建模?

Python 如何在Flask Restx中对其中一个进行建模?,python,flask-restx,Python,Flask Restx,我有下面的模式文档 { "$schema": "http://json-schema.org/draft-07/schema#", "title": "foo", "definitions": { "stuff": { "type": "object",

我有下面的模式文档

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "foo",
    "definitions": {
        "stuff": {
            "type": "object",
            "properties": {
                "id": {
                    "description": "the id",
                    "type": "string"
                },
                "type": {
                    "description": "the type",
                    "type": "string"
                }
            },
            "oneOf": [{
                "required": ["id"]
            }, {
                "required": ["type"]
            }],
        },
    },
    "type": "object",
    "properties": {
        "bar": {
            "description": "blah",
            "type": "object",
            "additionalProperties": {
                "$ref": "#/definitions/stuff"
            }
        }
    },
    "required": ["bar"]
}
我正在尝试创建flask restx模型,但我不确定如何对所需字段之一进行建模

我认为下面的方法行得通,但它忽略了需求

stuff_model = (
    "Stuff Model",
    "id": fields.String(description="the id", required=False),
    "type": fields.String(description="the type", required=False)
)

bar_model = (
    "Bar Model",
    "bar": fields.Nested(stuff_model, required=True)
)