Closed swaziloo closed 10 years ago
Just in case someone else needs the workaround. Include this in your ApiDocumentationController subclass:
@Override
@RequestMapping(value = "/resourceList", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody Documentation getResources(HttpServletRequest request) {
WrappedHttpServletRequest wrapReq = new WrappedHttpServletRequest(request);
return super.getResources(wrapReq);
}
public class WrappedHttpServletRequest extends HttpServletRequestWrapper {
public WrappedHttpServletRequest(HttpServletRequest request) {
super(request);
}
@Override
public String getServletPath() {
return "/documentation";
}
}
Thank you for posting a work around. I'll take a look into this issue to see if the work around can be avoided.
When following the instructions here: https://github.com/wkennedy/swagger4spring-web to override the request mapping ("Alternative Implementation") I found that though the resourceList request did, in fact, work with the "/documentation" root, the returned Documentation entries still referred to the default "/api" root.
The ApiDocumentationController tries to override this on line 155, but it uses the request.getServletPath() where it should (most likely) use request.getPathInfo().
In order to work around this flaw, I wrapped the HttpServletRequest and returned the expected root ("/documentation") via the wrapper's request.getServletPath() method.