title: How to show the swagger-ui at my app root?
body: <p>In my spring boot application, I want to see the swagger-ui, whenever I navigate to <code>http://localhost:8080/myapp/</code>.</p>
  
  <p>I enabled swagger and redirected <code>/</code> to <code>swagger-ui.html</code> with this config:</p>
  
  <pre><code>@Configuration
  @EnableSwagger2
  public class Swagger2Config implements WebMvcConfigurer {
  
      @Override
      public void addViewControllers(ViewControllerRegistry registry) {
          registry.addViewController("/").setViewName("forward:/swagger-ui.html");
      }
  }
  </code></pre>
  
  <p>However, this makes my browser log this JavaScript-Exception:</p>
  
  <pre><code>springfox.js?v=2.9.2:1 Uncaught (in promise) TypeError: Cannot read property '1' of null
      at e (springfox.js?v=2.9.2:1)
      at springfox.js?v=2.9.2:1
      at x (springfox.js?v=2.9.2:1)
      at Generator._invoke (springfox.js?v=2.9.2:1)
      at Generator.t.(:8080/myapp/anonymous function) [as next] (http://localhost:8080/myapp/webjars/springfox-swagger-ui/springfox.js?v=2.9.2:1:50487)
      at e (springfox.js?v=2.9.2:1)
      at springfox.js?v=2.9.2:1
      at new Promise (&lt;anonymous&gt;)
      at springfox.js?v=2.9.2:1
      at window.onload (springfox.js?v=2.9.2:1)
  e @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  x @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  t.(anonymous function) @ springfox.js?v=2.9.2:1
  e @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  window.onload @ springfox.js?v=2.9.2:1
  load (async)
  (anonymous) @ springfox.js?v=2.9.2:1
  r @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  r @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  (anonymous) @ springfox.js?v=2.9.2:1
  </code></pre>
  
  <p>The first item of the stacktrace points to this line in <code>http://localhost:8080/myapp/webjars/springfox-swagger-ui/springfox.js?v=2.9.2</code>:</p>
  
  <pre><code>return/(.*)\/swagger-ui.html.*/.exec(window.location.href)[1]
  </code></pre>
  
  <p>How can I make my swagger api doc appear, when I open the root of my application?</p>
  
  <p>The depenencies I used:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;io.springfox&lt;/groupId&gt;
      &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
      &lt;version&gt;2.9.2&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;io.springfox&lt;/groupId&gt;
      &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
      &lt;version&gt;2.9.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>