Skip to content

Commit

Permalink
Merge branch 'bug/3351/fix-swagger-ui-calls'
Browse files Browse the repository at this point in the history
relates to #3351
  • Loading branch information
dilipkrish committed Jun 30, 2020
2 parents c289294 + 98789a4 commit 03a10e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public ResponseEntity<Json> getDocumentation(
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
Swagger swagger = mapper.mapDocumentation(documentation);
swagger.basePath(isEmpty(request.getPath().contextPath().value()) ? "/" : request.getPath().contextPath().value());
if (isEmpty(swagger.getHost())) {
swagger.host(request.getURI().getAuthority());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public ResponseEntity<Json> getDocumentation(
}
Swagger swagger = mapper.mapDocumentation(documentation);
UriComponents uriComponents = componentsFrom(servletRequest, swagger.getBasePath());
String basePath = isEmpty(uriComponents.getPath()) ? "/" : uriComponents.getPath();
swagger.basePath(basePath.replace(servletRequest.getContextPath(), ""));
if (isEmpty(swagger.getHost())) {
swagger.host(hostName(uriComponents));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class Swagger2ControllerSpec extends DocumentationContextSpec
where:
prefix | expectedPath
"/fooservice" | "/fooservice/servletPath"
"/" | "/contextPath/servletPath"
"" | "/contextPath/servletPath"
"/" | "/servletPath"
"" | "/servletPath"
}
def "Should omit port number if it is -1"() {
Expand Down

0 comments on commit 03a10e6

Please sign in to comment.