1

I'm wondering if there's a way to change the default generated CURL command in Swagger UI. It generates

 CURL -X

and I would like to change it to

CURL -k

Is there a way to do this?

2
  • Is this about Swagger UI? The curl command generated after you click "Try it out"? Commented Mar 4, 2021 at 17:50
  • Yes! That's the one Commented Mar 5, 2021 at 7:42

1 Answer 1

1

This is supported in Swagger UI 3.35.0 and later.

You need to modify your Swagger UI configuration code (located e.g. in index.html) and add the following requestInterceptor. In the interceptor, use req.curlOptions to specify additional arguments for the generated curl commands.

const ui = SwaggerUIBundle({
  dom_id: "#swagger-ui",
  url: "https://petstore.swagger.io/v2/swagger.json",
  ...
  requestInterceptor: (req) => {
    req.curlOptions = ["-k"];   // <-----------
    return req;
  }
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.