虽然这里对这个主题有很长的讨论:https://github.com/swagger-api/swagger-ui/issues/156
我还没有找到更干净的方法来“有选择地”禁用“试用”按钮。 我想对我的 API 的所有 POST 方法禁用它。
提前谢谢
最佳答案
Swagger UI 3.10.0+ 和 2.x 提供 supportedSubmitMethods
控制哪些 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"],
关于reactjs - 在 swaggerUI 中选择性禁用 "Try it out",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47860927/