我正在为 api 文档使用烧瓶 restful swagger,但是有一些 api 端点我不想在 swagger 提供的 UI 上显示。有没有办法在代码中这样做?
问问题
4627 次
3 回答
4
对于使用 flask-restplus 的任何人,您可能正在寻找一种从文档中隐藏端点的方法。
# 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 {}
于 2018-05-08T20:53:08.983 回答
0
由于您没有提供太多信息,因此很难知道您的意思,但根据文档:
# 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
也就是说,如果您不装饰您的资源,它们将不会出现在文档中。更多信息在这里https://github.com/rantav/flask-restful-swagger
于 2014-11-27T21:36:24.763 回答
-2
尝试这个
api = Api(app, doc=False)
于 2018-11-13T20:34:54.807 回答