【发布时间】:2019-01-19 01:01:06
【问题描述】:
我在烧瓶中使用 flask_restplus swagger 来获取 api 文档。我想为将数据发布到数据库的 api 创建一个模型定义。我的问题是,数据是数组形式。我正在通过发布请求发送以下格式的数据。
{
"user_id" : 3,
"product" : [
{
"product_id" : 33,
"total_price" : 50,
"quantity": 2
},
{
"product_id" : 18,
"total_price" : 40,
"quantity": 2
}
]
}
我们如何为这种类型的结构定义模型?我在正文中发送数据。
【问题讨论】:
-
到目前为止您尝试过什么,您在哪里卡住了?
-
order = api.model('Order', { "user_id" : fields.Integer, "product" : { "product_id" : fields.String, "total_price" : fields.Integer, "quantity ": fields.Integer } })
标签: rest api flask swagger flask-restplus