Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I would like to disable Try it Out button in the API documentation. I have tried "tryItOut": false in the parameter and the configuration. Furthermore, I'm using swagger 2.0 which has 'Try it out' button is enabled by default and in 3.0 it is disabled by default. So, there should be option to configure it. How to disable Try it out button from the Swagger UI?

@Alkanshel despite the name, the tryItOutEnabled config does NOT disable the "try it out" functionality. This config is used to display operations in the "try it out" mode by default so the users only have to click "Execute" (instead of "Try it out" followed by "Execute") to send requests. Helen Nov 1, 2022 at 14:30

Set supportedSubmitMethods to an empty array [] in your Swagger UI configuration. This config option is supported in v. 3.10.0+.

const ui = SwaggerUIBundle({
  "dom_id": "#swagger-ui",
  url: "https://path/to/your/api.yaml",
  supportedSubmitMethods: []    // <--------

This config can also disable "Try it out" selectively for specific HTTP methods. For example, supportedSubmitMethods: ["get", "head"] keeps "Try it out" only for GET and HEAD, but disables it for POST, PUT, PATCH, DELETE and other methods.

    app.UseSwaggerUI(options =>
        options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API");
        options.EnableTryItOutByDefault();
                The relevant Swashbuckle option is actually .SupportedSubmitMethods(..). .EnableTryItOutByDefault does not disable the "try it out" functionality (which is what the OP wanted), it has another purpose.
– Helen
                Mar 6 at 23:01

From the GitHub repository comments, the bellow code works to me

const DisableTryItOutPlugin = function() {
  return {
    statePlugins: {
      spec: {
        wrapSelectors: {
          allowTryItOutFor: () => () => false
// elsewhere, when you call Swagger-UI...
SwaggerUI({
  plugins: [
    DisableTryItOutPlugin

Reference: https://github.com/swagger-api/swagger-ui/issues/3725#issuecomment-334899276

While the plugin still works, now there's a built-in supportedSubmitMethods config for that. – Helen Jul 9, 2021 at 8:07

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.