How to set swagger as default start page

How to set Swagger as the default start page

To set Swagger as the default start page, you need to make some changes to your application’s configuration. Below are the steps to do it:

  1. Open the configuration file of your application. This could be a web.config file for ASP.NET applications or a application.properties file for Spring Boot applications.
  2. Locate the section where the default start page is defined. This can vary depending on the framework you are using.
  3. Change the default start page to the Swagger UI URL. The Swagger UI URL is usually /swagger-ui.html or /swagger-ui/index.html.
  4. Save the configuration file.

Here are examples for different frameworks:

ASP.NET Core

    <configuration>
      <system.webServer>
        <defaultDocument>
          <files>
            <clear />
            <add value="swagger/index.html" />
          </files>
        </defaultDocument>
      </system.webServer>
    </configuration>
  

Java + Spring Boot

    spring.mvc.view.prefix=/swagger-ui/
    spring.mvc.view.suffix=.html
  

Make sure to restart your application after making these changes for them to take effect. Once restarted, accessing the root URL of your application should directly load the Swagger UI.

Leave a comment