I am using flask restful swagger for api documentation, but there are some api endpoints which i dont want to be showed on the UI offered by swagger. Is there a way to do so in the code?
For anyone who's using flask-restplus, you're probably looking for a way to hide endpoints from the documentation .
# Hide the full resource
@api.route('/resource1/', doc=False)
class Resource1(Resource):
def get(self):
return {}
@api.route('/resource2/')
@api.doc(False)
class Resource2(Resource):
def get(self):
return {}
@api.route('/resource3/')
@api.hide
class Resource3(Resource):
def get(self):
return {}
Since you've not provided much information it's quite difficult to know what you mean but according to the docs:
# Operations not decorated with @swagger.operation do not get added to the swagger docs
class Todo(Resource):
def options(self, todo_id):
"""
I'm not visible in the swagger docs
"""
pass
That is if you do not decorate your Resources they will not show up in the docs. More information here https://github.com/rantav/flask-restful-swagger
尝试这个
api = Api(app, doc=False)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.