如何记录 POST 端点的返回数据?
How does one document the returned data for a POST endpoint?
如果我有一个像这样使用 flask 的简单端点
import random
class MyResource(Resource):
def post(self):
return [i for i in range (random.randrange(100))]
如何使用 flask-restplus 获得像这样的 swagger 文档?
我正在寻找像这样的数据结构
[
type=integer, description='coin flip',
....
]
我可以让它为有效载荷工作,但不能为 return/response
来自https://flask-restplus.readthedocs.io/en/stable/swagger.html
You can optionally specify a response model as the third argument
model = api.model('Model', {
'name': fields.String,
})
@api.route('/my-resource/')
class MyResource(Resource):
@api.response(200, 'Success', model)
def get(self):
pass
如果我有一个像这样使用 flask 的简单端点
import random
class MyResource(Resource):
def post(self):
return [i for i in range (random.randrange(100))]
如何使用 flask-restplus 获得像这样的 swagger 文档?
我正在寻找像这样的数据结构
[
type=integer, description='coin flip',
....
]
我可以让它为有效载荷工作,但不能为 return/response
来自https://flask-restplus.readthedocs.io/en/stable/swagger.html
You can optionally specify a response model as the third argument
model = api.model('Model', {
'name': fields.String,
})
@api.route('/my-resource/')
class MyResource(Resource):
@api.response(200, 'Success', model)
def get(self):
pass