Skip to content

Commit 3242617

Browse files
author
bnasslahsen
committed
Added support, for serving the swagger-ui from outside of the spring-boot App. Fixes #346.
1 parent a0c9724 commit 3242617

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/Constants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public final class Constants {
2929
public static final String SPRINGDOC_ACTUATOR_DOC_URL = "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/";
3030
public static final String SPRINGDOC_ACTUATOR_DOC_DESCRIPTION = "Spring Boot Actuator Web API Documentation";
3131
public static final String DEFAULT_WEB_JARS_PREFIX_URL = "/webjars";
32-
public static final String WEB_JARS_PREFIX_URL = "${springdoc.webjars.prefix:#{T(org.springdoc.core.Constants).DEFAULT_WEB_JARS_PREFIX_URL}}";
32+
public static final String WEB_JARS_PREFIX_URL = "${springdoc.webjars.prefix:"+DEFAULT_WEB_JARS_PREFIX_URL+"}";
33+
public static final String CLASSPATH_RESOURCE_LOCATION = "classpath:/META-INF/resources";
3334
public static final String SWAGGER_UI_URL = "/swagger-ui/index.html";
3435
public static final String SWAGGER_UI_OAUTH_REDIRECT_URL = "/swagger-ui/oauth2-redirect.html";
3536
public static final String APPLICATION_OPENAPI_YAML = "application/vnd.oai.openapi";

springdoc-openapi-ui/src/main/java/org/springdoc/ui/SwaggerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
3939
}
4040
uiRootPath.append("/**");
4141
String webJarsLocation = webJarsPrefixUrl + DEFAULT_PATH_SEPARATOR;
42-
registry.addResourceHandler(uiRootPath + "/swagger-ui/**").addResourceLocations(webJarsLocation)
42+
registry.addResourceHandler(uiRootPath + "/swagger-ui/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATION+webJarsLocation)
4343
.resourceChain(false)
4444
.addTransformer(swaggerIndexTransformer);
4545
}

0 commit comments

Comments
 (0)