11package org .springdoc .ui ;
22
33import io .swagger .v3 .oas .annotations .Operation ;
4+ import org .apache .commons .lang3 .StringUtils ;
45import org .springdoc .core .SwaggerUiConfigProperties ;
56import org .springframework .beans .factory .annotation .Autowired ;
67import org .springframework .beans .factory .annotation .Value ;
@@ -26,19 +27,26 @@ class SwaggerWelcome {
2627 @ Value (SWAGGER_UI_PATH )
2728 private String swaggerPath ;
2829
30+ @ Value (MVC_SERVLET_PATH )
31+ private String mvcServletPath ;
32+
2933 @ Autowired
3034 private SwaggerUiConfigProperties swaggerUiConfig ;
3135
3236 @ Operation (hidden = true )
3337 @ GetMapping (SWAGGER_UI_PATH )
3438 public String redirectToUi (HttpServletRequest request ) {
3539 String contextPath = request .getContextPath ();
40+ if (StringUtils .isNotBlank (mvcServletPath ))
41+ contextPath += mvcServletPath ;
3642 String uiRootPath = "" ;
3743 if (swaggerPath .contains ("/" )) {
3844 uiRootPath = swaggerPath .substring (0 , swaggerPath .lastIndexOf ('/' ));
3945 }
4046 StringBuilder sbUrl = new StringBuilder ();
4147 sbUrl .append (REDIRECT_URL_PREFIX );
48+ if (StringUtils .isNotBlank (mvcServletPath ))
49+ sbUrl .append (mvcServletPath );
4250 sbUrl .append (uiRootPath );
4351 sbUrl .append (SWAGGER_UI_URL );
4452 if (contextPath .endsWith (DEFAULT_PATH_SEPARATOR )) {
0 commit comments