1
1
package org .springdoc .ui ;
2
2
3
3
import io .swagger .v3 .oas .annotations .Operation ;
4
+ import org .apache .commons .lang3 .StringUtils ;
4
5
import org .springdoc .core .SwaggerUiConfigProperties ;
5
6
import org .springframework .beans .factory .annotation .Autowired ;
6
7
import org .springframework .beans .factory .annotation .Value ;
@@ -26,19 +27,26 @@ class SwaggerWelcome {
26
27
@ Value (SWAGGER_UI_PATH )
27
28
private String swaggerPath ;
28
29
30
+ @ Value (MVC_SERVLET_PATH )
31
+ private String mvcServletPath ;
32
+
29
33
@ Autowired
30
34
private SwaggerUiConfigProperties swaggerUiConfig ;
31
35
32
36
@ Operation (hidden = true )
33
37
@ GetMapping (SWAGGER_UI_PATH )
34
38
public String redirectToUi (HttpServletRequest request ) {
35
39
String contextPath = request .getContextPath ();
40
+ if (StringUtils .isNotBlank (mvcServletPath ))
41
+ contextPath += mvcServletPath ;
36
42
String uiRootPath = "" ;
37
43
if (swaggerPath .contains ("/" )) {
38
44
uiRootPath = swaggerPath .substring (0 , swaggerPath .lastIndexOf ('/' ));
39
45
}
40
46
StringBuilder sbUrl = new StringBuilder ();
41
47
sbUrl .append (REDIRECT_URL_PREFIX );
48
+ if (StringUtils .isNotBlank (mvcServletPath ))
49
+ sbUrl .append (mvcServletPath );
42
50
sbUrl .append (uiRootPath );
43
51
sbUrl .append (SWAGGER_UI_URL );
44
52
if (contextPath .endsWith (DEFAULT_PATH_SEPARATOR )) {
0 commit comments