I using Flask-Restplus to develop my API. I wanna to ask,why the @api.doc
decorator not update my changes in the Swagger UI?
Here is the endpoint I define
@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)
So here is the result in my browser:
As you can see here,the doc is not updating according the string I define in @api.doc
decorator.
So anyone can let me know why is this happen? And how to solve this?
in fact the documentation that it generates first of the comment which follows directly the declaration of your function
change that:
@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)
To that:
@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)