diff --git a/springfox-swagger2/src/main/java/springfox/documentation/swagger2/web/Swagger2ControllerWebFlux.java b/springfox-swagger2/src/main/java/springfox/documentation/swagger2/web/Swagger2ControllerWebFlux.java
index <HASH>..<HASH> 100644
--- a/springfox-swagger2/src/main/java/springfox/documentation/swagger2/web/Swagger2ControllerWebFlux.java
+++ b/springfox-swagger2/src/main/java/springfox/documentation/swagger2/web/Swagger2ControllerWebFlux.java
@@ -88,7 +88,7 @@ public class Swagger2ControllerWebFlux {
       return new ResponseEntity<>(HttpStatus.NOT_FOUND);
     }
     Swagger swagger = mapper.mapDocumentation(documentation);
-    swagger.basePath("/");
+    swagger.basePath(isEmpty(request.getPath().contextPath().value()) ? "/" : request.getPath().contextPath().value());
     if (isEmpty(swagger.getHost())) {
       swagger.host(request.getURI().getAuthority());
     }
Set the basePath using the request context path if present

This allows the X-Forwarded-Prefix header to work correctly