如何在 Swagger UI 中使用“-k”参数生成 curl 命令?
How to generate curl commands with the '-k' argument in Swagger UI?
我想知道是否有办法更改 Swagger 中默认生成的 CURL 命令 UI。它生成
CURL -X
我想将其更改为
CURL -k
有办法吗?
Swagger UI 3.35.0 及更高版本支持此功能。
您需要修改您的 Swagger UI 配置代码(位于例如 index.html 中)并添加以下内容 requestInterceptor
。在拦截器中,使用 req.curlOptions
为生成的 curl 命令指定附加参数。
const ui = SwaggerUIBundle({
dom_id: "#swagger-ui",
url: "https://petstore.swagger.io/v2/swagger.json",
...
requestInterceptor: (req) => {
req.curlOptions = ["-k"]; // <-----------
return req;
}
})
我想知道是否有办法更改 Swagger 中默认生成的 CURL 命令 UI。它生成
CURL -X
我想将其更改为
CURL -k
有办法吗?
Swagger UI 3.35.0 及更高版本支持此功能。
您需要修改您的 Swagger UI 配置代码(位于例如 index.html 中)并添加以下内容 requestInterceptor
。在拦截器中,使用 req.curlOptions
为生成的 curl 命令指定附加参数。
const ui = SwaggerUIBundle({
dom_id: "#swagger-ui",
url: "https://petstore.swagger.io/v2/swagger.json",
...
requestInterceptor: (req) => {
req.curlOptions = ["-k"]; // <-----------
return req;
}
})