尽管这里对该主题进行了很长的讨论:https://github.com/swagger-api/swagger-ui/issues/156 https://github.com/swagger-api/swagger-ui/issues/156
我还没有找到更干净的方法来“有选择地”禁用“尝试”按钮。
我想对我的 API 的所有 POST 方法禁用它。
先感谢您
Swagger UI 3.10.0+ 和 2.x 提供supportedSubmitMethods https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#network控制哪些 HTTP 方法启用“尝试”的选项(默认 = 全部)。
要禁用 POST(但不是 PATCH/PUT)的“尝试一下”:
// index.html (Swagger UI 3.10+)
const ui = SwaggerUIBundle({
url: "http://my.api.com/openapi.yaml",
supportedSubmitMethods: ["get", "delete", "options", "head", "patch", "trace"], // No "post"
...
})
要对除 GET 和 HEAD 之外的所有方法禁用“尝试一下”:
supportedSubmitMethods: ["get", "head"],
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)