繁体   English   中英

在Flask Restful Swagger的UI中隐藏端点

[英]Hide endpoints in UI of Flask restful Swagger

我正在使用flask restful swagger编写api文档,但是我不想在swagger提供的UI上显示一些api端点。 代码中有办法吗?

对于任何使用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 {}

由于您没有提供太多信息,因此根据文档很难知道您的意思。

# 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

尝试这个

api = Api(app, doc=False)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM