Python 为什么@api.doc decorator.restplus不更新我所做的更改?
我使用Flask Restplus开发API。我想问,为什么Python 为什么@api.doc decorator.restplus不更新我所做的更改?,python,swagger,swagger-ui,flask-restplus,Python,Swagger,Swagger Ui,Flask Restplus,我使用Flask Restplus开发API。我想问,为什么@api.doc装饰程序不更新我在招摇过市UI中的更改 这是我定义的端点 @api.route('/create_user') class User(Resource): @api.response(201, 'User successfully created.') @api.doc('create a new user') @api.expect(_user, validate=True) @api.
@api.doc
装饰程序不更新我在招摇过市UI中的更改
这是我定义的端点
@api.route('/create_user')
class User(Resource):
@api.response(201, 'User successfully created.')
@api.doc('create a new user')
@api.expect(_user, validate=True)
@api.marshal_list_with(_user, envelope='data')
def post(self):
"""Creates a new User """
data = request.json
return create_user(data=data)
@api.route('/get_user_list')
class UserList(Resource):
@api.doc('list_of_registered') //even I change here,in Swagger is still not update
@api.marshal_list_with(_user, envelope='data')
def get(self):
"""List all registered users"""
return get_all_users()
@api.route('/create_product')
class Product(Resource):
@api.response(201, 'Product successfully created.')
@api.doc('12345678') //here I state to this
@api.expect(_product, validate=True)
def post(self):
"""Creates a new User """
data = request.json
return create_product(data=data)
下面是我的浏览器中的结果:
正如您在这里看到的,文档没有根据我在@api.doc
decorator中定义的字符串进行更新
所以任何人都可以告诉我为什么会这样?如何解决这个问题呢?事实上,它生成的第一条注释直接跟在函数声明后面 更改为:
@api.route('/create_product')
class Product(Resource):
@api.response(201, 'Product successfully created.')
@api.doc('12345678') //here I state to this
@api.expect(_product, validate=True)
def post(self):
"""Creates a new User """
data = request.json
return create_product(data=data)
为此:
@api.route('/create_product')
class Product(Resource):
@api.response(201, 'Product successfully created.')
@api.doc('12345678') //here I state to this
@api.expect(_product, validate=True)
def post(self):
"""Creates a new Product """
data = request.json
return create_product(data=data)
这意味着文档将从函数中的注释生成??如果函数中没有注释,那么它将仅从
@api.doc
生成。我是对的吗?不抱歉,我错了,他只将此文档作为注释,但当函数中没有注释时,浏览器中的文档直接为空,但是没有生成表单api.docyes这是真的,我只是测试了它,它没有使用trought@api.doc指定的表单。我真正想知道的是,为什么在最新的flask restplus文档中,我甚至不能(轻松地)找到提到方法描述取自方法声明后的块注释,更不用说如何超越它了。这里面什么都没有,我本以为搜索“评论”会发现一些东西。我错过了什么?