Swagger 2 & spring MVC - ignore the war context path
<p>I am using swagger 2 with spring mvc. </p>

<p>The war file is web-app.war and Swagger base URL is shown as <code>/web-app/rest/api</code></p>

<p>I would like to remove the war context path so the api call can be made as </p>

<p><code>example.com/rest/api</code> and <strong>not</strong> <code>example.com/web-app/rest/api</code></p>

<p>SwaggerConfig.java</p>

<pre><code>@Configuration
@EnableWebMvc
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {

    @Bean
    public Docket api() {
        // @formatter:off
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.any())
                .build().apiInfo(apiInfo());
    }


    private ApiInfo apiInfo() {
         return new ApiInfoBuilder().title("Rest API")
                 .description("Describes the restful interface")
                 .build();
    }

    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
</code></pre>