package org.openlmis.stockmanagement;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class CustomWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {

  @Value("${service.url}")
  private String serviceUrl;

  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/stockmanagement/docs")
            .setViewName("redirect:" + serviceUrl + "/stockmanagement/docs/");
    registry.addViewController("/stockmanagement/docs/")
            .setViewName("forward:/stockmanagement/docs/index.html");
    super.addViewControllers(registry);
  }

  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/stockmanagement/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
    super.addResourceHandlers(registry);
  }
}

@@ -152,16 +152,62 @@
 ration;%0A
+import org.springframework.http.CacheControl;%0A
 import o
@@ -444,16 +444,55 @@
 apter;%0A%0A
+import java.util.concurrent.TimeUnit;%0A%0A
 @Configu
@@ -1236,24 +1236,92 @@
 s/webjars/%22)
+%0A            .setCacheControl(CacheControl.maxAge(7, TimeUnit.DAYS))
 ;%0A    super.

Enable cache for swagger ui web jar so that it's faster to load in test/uat envs