gpt4 book ai didi

python - 在 Flask restful Swagger 的 UI 中隐藏端点

转载 作者:行者123 更新时间:2023-12-05 03:14:12 25 4
gpt4 key购买 nike

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

最佳答案

对于任何使用 flask-restplus 的人,您可能正在寻找一种方法来 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 {}

关于python - 在 Flask restful Swagger 的 UI 中隐藏端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26142997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com