@@ -42,14 +42,7 @@ class SwaggerWelcome {
42
42
@ Operation (hidden = true )
43
43
@ GetMapping (SWAGGER_UI_PATH )
44
44
public String redirectToUi (HttpServletRequest request ) {
45
- String uiRootPath = "" ;
46
- if (swaggerPath .contains ("/" ))
47
- uiRootPath = swaggerPath .substring (0 , swaggerPath .lastIndexOf ('/' ));
48
- StringBuilder sbUrl = new StringBuilder ();
49
- sbUrl .append (REDIRECT_URL_PREFIX );
50
- if (StringUtils .isNotBlank (mvcServletPath ))
51
- sbUrl .append (mvcServletPath );
52
- sbUrl .append (uiRootPath );
45
+ StringBuilder sbUrl = new StringBuilder (REDIRECT_URL_PREFIX ).append (this .calculateUiRootPath ());
53
46
sbUrl .append (SWAGGER_UI_URL );
54
47
buildConfigUrl (request );
55
48
UriComponentsBuilder uriBuilder = UriComponentsBuilder .fromUriString (sbUrl .toString ());
@@ -87,7 +80,18 @@ private void buildConfigUrl(HttpServletRequest request) {
87
80
88
81
}
89
82
if (!swaggerUiConfig .isValidUrl (swaggerUiConfig .getOauth2RedirectUrl ())) {
90
- swaggerUiConfig .setOauth2RedirectUrl (ServletUriComponentsBuilder .fromCurrentContextPath ().path (swaggerUiConfig .getOauth2RedirectUrl ()).build ().toString ());
83
+ swaggerUiConfig .setOauth2RedirectUrl (ServletUriComponentsBuilder .fromCurrentContextPath ().path (this . calculateUiRootPath (). append ( swaggerUiConfig .getOauth2RedirectUrl ()). toString ()).build ().toString ());
91
84
}
92
85
}
86
+
87
+ private StringBuilder calculateUiRootPath () {
88
+ String uiRootPath = "" ;
89
+ if (swaggerPath .contains ("/" ))
90
+ uiRootPath = swaggerPath .substring (0 , swaggerPath .lastIndexOf ('/' ));
91
+ StringBuilder sbUrl = new StringBuilder ();
92
+ if (StringUtils .isNotBlank (mvcServletPath ))
93
+ sbUrl .append (mvcServletPath );
94
+ sbUrl .append (uiRootPath );
95
+ return sbUrl ;
96
+ }
93
97
}
0 commit comments