为什么@api.doc decorator python flask restplus 不更新我所做的更改?
Why @api.doc decorator python flask restplus not update the changes I make?
我使用 Flask-Restplus 来开发我的 API。我想问一下,为什么 @api.doc
装饰器不更新我在 Swagger 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
装饰器中定义的字符串进行更新。
所以谁能告诉我为什么会这样?以及如何解决这个问题?
事实上,它首先生成的文档是紧跟在函数声明之后的注释
更改为:
@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)
我使用 Flask-Restplus 来开发我的 API。我想问一下,为什么 @api.doc
装饰器不更新我在 Swagger 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
装饰器中定义的字符串进行更新。
所以谁能告诉我为什么会这样?以及如何解决这个问题?
事实上,它首先生成的文档是紧跟在函数声明之后的注释
更改为:
@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)