问题描述
我有以下架构文档
{
"$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","additionalProperties": {
"$ref": "#/definitions/stuff"
}
}
},"required": ["bar"]
}
我正在尝试创建flask restx模型,但是我不确定如何为所需的OneOf字段建模?
我认为以下方法会起作用,但是随后它忽略了其中一个要求。
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)
)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)