我使用swagger2.0创建python flask后端的框架。
我在Swagger在线编辑器上声明了POST /image
端点如下:
/image:
post:
summary: "Description."
operationId: "image_post"
consumes:
- "multipart/form-data"
parameters:
- in: "formData"
name: "upfile"
description: "The file to upload."
required: true
type: "file"
responses:
201:
description: "Ok"
schema:
type: "string"
400:
description: "bad image"
x-swagger-router-controller: "swagger_server.controllers.default_controller"
下载python-flask
服务器后,我用python -m swagger_server
命令运行它。当通过postman发送post请求时,我得到状态码是200
,而不是{200
。在
如果这是个窃听器,有什么线索吗?还是我做错了什么?在
我确信您需要显式地声明您希望在view函数中返回的状态代码;swagger描述只是API服务器实际上并不关心的文档。类似这样的伪代码:
相关问题 更多 >
编程相关推荐