Is there any way to move the Swagger 2 content to another base URL?
I have seen "how to do friendly base url for swagger 2.8.0" as well as this kind of workaround:
@RequestMapping("/swagger")
public String greeting() {
return "redirect:/swagger-ui.html";
}
The problem:
This is not possible in my case!
My server hosts two web applications and a REST api which is why I have this monster here:
@Controller
public class ForwardController {
@RequestMapping(value = "/sitemap.xml", method = RequestMethod.GET)
public String redirectSitemapXml(HttpServletRequest request) {
return "forward:/a/web/assets/sitemap.xml";
}
@RequestMapping(value = "/robots.txt", method = RequestMethod.GET)
public String redirectRobotTxt(HttpServletRequest request) {
return "forward:/a/web/assets/robots.txt";
}
@RequestMapping(value = "/*", method = RequestMethod.GET)
public String redirectRoot(HttpServletRequest request) {
return "forward:/a/web/index.html";
}
@RequestMapping(value = "/a/**/{path:[^.]*}", method = RequestMethod.GET)
public String redirectClients(HttpServletRequest request) {
String requestURI = request.getRequestURI();
if (requestURI.startsWith("/a/admin/")) {
return "forward:/a/admin/index.html";
}
return "forward:/a/web/index.html";
}
}
This goes along with Spring Security settings for this setup.
I need swagger to be available under /a/swagger-ui.html
, but is this possible?
The following cannot work either under my ForwardController
: