Skip to content

Commit 17de960

Browse files
author
bnasslahsen
committed
Setting oauth2RedirectUrl does not respect relaxed binding. Fixes #591.
1 parent 9c94882 commit 17de960

File tree

13 files changed

+109
-116
lines changed

13 files changed

+109
-116
lines changed

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,8 @@ public final class Constants {
4646

4747
public static final String SPRINGDOC_SWAGGER_UI_ENABLED = "springdoc.swagger-ui.enabled";
4848

49-
public static final String SPRINGDOC_SWAGGER_UI_CONFIG_URL = "springdoc.swagger-ui.configUrl";
50-
51-
public static final String SPRINGDOC_SWAGGER_UI_URL = "springdoc.swagger-ui.url";
52-
5349
public static final String NULL = ":#{null}";
5450

55-
public static final String MVC_SERVLET_PATH = "${spring.mvc.servlet.path" + NULL + "}";
56-
57-
public static final String SPRINGDOC_SWAGGER_UI_URL_VALUE = "${" + SPRINGDOC_SWAGGER_UI_URL + NULL + "}";
58-
59-
public static final String SPRINGDOC_OAUTH2_REDIRECT_URL = "springdoc.swagger-ui.oauth2RedirectUrl";
60-
61-
public static final String SPRINGDOC_OAUTH2_REDIRECT_URL_VALUE = "${" + SPRINGDOC_OAUTH2_REDIRECT_URL + NULL + "}";
62-
63-
public static final String SPRINGDOC_SWAGGER_UI_CONFIG_URL_VALUE = "${" + SPRINGDOC_SWAGGER_UI_CONFIG_URL + NULL + "}";
64-
6551
public static final String SPRINGDOC_SHOW_ACTUATOR = "springdoc.show-actuator";
6652

6753
public static final String SPRINGDOC_ACTUATOR_TAG = "Actuator";
@@ -74,8 +60,6 @@ public final class Constants {
7460

7561
public static final String DEFAULT_WEB_JARS_PREFIX_URL = "/webjars";
7662

77-
public static final String WEB_JARS_PREFIX_URL = "${springdoc.webjars.prefix:" + DEFAULT_WEB_JARS_PREFIX_URL + "}";
78-
7963
public static final String CLASSPATH_RESOURCE_LOCATION = ResourceUtils.CLASSPATH_URL_PREFIX + "/META-INF/resources";
8064

8165
public static final String SWAGGER_UI_URL = "/swagger-ui/index.html";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.http.MediaType;
2828

29+
import static org.springdoc.core.Constants.DEFAULT_WEB_JARS_PREFIX_URL;
2930
import static org.springdoc.core.Constants.SPRINGDOC_ENABLED;
3031

3132
@Configuration
@@ -190,7 +191,7 @@ public void setRemoveBrokenReferenceDefinitions(boolean removeBrokenReferenceDef
190191
}
191192

192193
public static class Webjars {
193-
private String prefix = "/webjars";
194+
private String prefix = DEFAULT_WEB_JARS_PREFIX_URL;
194195

195196
public String getPrefix() {
196197
return prefix;

springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerWelcome.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323
import org.springdoc.core.SwaggerUiConfigProperties;
2424

2525
import org.springframework.beans.factory.InitializingBean;
26-
import org.springframework.beans.factory.annotation.Value;
2726
import org.springframework.web.util.UriComponentsBuilder;
2827

29-
import static org.springdoc.core.Constants.SPRINGDOC_OAUTH2_REDIRECT_URL_VALUE;
30-
import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_CONFIG_URL_VALUE;
31-
import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_URL_VALUE;
3228
import static org.springdoc.core.Constants.SWAGGGER_CONFIG_FILE;
3329
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
3430

@@ -41,18 +37,18 @@ public abstract class AbstractSwaggerWelcome implements InitializingBean {
4137

4238
protected String uiRootPath;
4339

44-
@Value(SPRINGDOC_OAUTH2_REDIRECT_URL_VALUE)
4540
protected String oauth2RedirectUrl;
4641

47-
@Value(SPRINGDOC_SWAGGER_UI_CONFIG_URL_VALUE)
4842
private String originConfigUrl;
4943

50-
@Value(SPRINGDOC_SWAGGER_UI_URL_VALUE)
5144
private String swaggerUiUrl;
5245

5346
public AbstractSwaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties) {
5447
this.swaggerUiConfig = swaggerUiConfig;
5548
this.springDocConfigProperties = springDocConfigProperties;
49+
this.oauth2RedirectUrl = swaggerUiConfig.getOauth2RedirectUrl();
50+
this.originConfigUrl = swaggerUiConfig.getConfigUrl();
51+
this.swaggerUiUrl = swaggerUiConfig.getUrl();
5652
}
5753

5854
@Override
@@ -89,9 +85,9 @@ protected void buildConfigUrl(String contextPath, UriComponentsBuilder uriCompon
8985
protected UriComponentsBuilder getUriComponentsBuilder(String sbUrl) {
9086
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(sbUrl);
9187
uriBuilder.queryParam(SwaggerUiConfigProperties.CONFIG_URL_PROPERTY, swaggerUiConfig.getConfigUrl());
92-
if(StringUtils.isNotEmpty(swaggerUiConfig.getLayout()))
88+
if (StringUtils.isNotEmpty(swaggerUiConfig.getLayout()))
9389
uriBuilder.queryParam(SwaggerUiConfigProperties.LAYOUT_PROPERTY, swaggerUiConfig.getLayout());
94-
if(StringUtils.isNotEmpty(swaggerUiConfig.getFilter()))
90+
if (StringUtils.isNotEmpty(swaggerUiConfig.getFilter()))
9591
uriBuilder.queryParam(SwaggerUiConfigProperties.FILTER_PROPERTY, swaggerUiConfig.getFilter());
9692

9793
return uriBuilder;

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/converters/CollectionModelContentConverter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.swagger.v3.oas.models.media.ArraySchema;
3131
import io.swagger.v3.oas.models.media.ObjectSchema;
3232
import io.swagger.v3.oas.models.media.Schema;
33+
3334
import org.springframework.hateoas.EntityModel;
3435
import org.springframework.hateoas.server.LinkRelationProvider;
3536

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

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,55 +24,32 @@
2424
import org.springdoc.core.SwaggerUiConfigProperties;
2525
import org.springdoc.core.SwaggerUiOAuthProperties;
2626

27-
import org.springframework.beans.factory.annotation.Autowired;
28-
import org.springframework.beans.factory.annotation.Value;
2927
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3028
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
29+
import org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties;
3130
import org.springframework.context.annotation.Bean;
3231
import org.springframework.context.annotation.Configuration;
33-
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
34-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
3532

36-
import static org.springdoc.core.Constants.CLASSPATH_RESOURCE_LOCATION;
37-
import static org.springdoc.core.Constants.DEFAULT_WEB_JARS_PREFIX_URL;
3833
import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_ENABLED;
39-
import static org.springdoc.core.Constants.SWAGGER_UI_PATH;
40-
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
4134

4235

4336
@Configuration
4437
@ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true)
4538
@ConditionalOnBean(SpringDocConfiguration.class)
46-
@SuppressWarnings("deprecation")
47-
public class SwaggerConfig extends WebMvcConfigurerAdapter { // NOSONAR
48-
49-
@Value(SWAGGER_UI_PATH)
50-
private String swaggerPath;
51-
52-
@Autowired
53-
private SwaggerIndexTransformer swaggerIndexTransformer;
54-
55-
@Override
56-
public void addResourceHandlers(ResourceHandlerRegistry registry) {
57-
StringBuilder uiRootPath = new StringBuilder();
58-
if (swaggerPath.contains("/"))
59-
uiRootPath.append(swaggerPath, 0, swaggerPath.lastIndexOf('/'));
60-
uiRootPath.append("/**");
61-
registry.addResourceHandler(uiRootPath + "/swagger-ui/**")
62-
.addResourceLocations(CLASSPATH_RESOURCE_LOCATION + DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR)
63-
.resourceChain(false)
64-
.addTransformer(swaggerIndexTransformer);
65-
}
39+
public class SwaggerConfig {
6640

6741
@Bean
68-
@ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true)
69-
SwaggerWelcome swaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties) {
70-
return new SwaggerWelcome(swaggerUiConfig, springDocConfigProperties);
42+
SwaggerWelcome swaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties, WebMvcProperties webMvcProperties) {
43+
return new SwaggerWelcome(swaggerUiConfig, springDocConfigProperties, webMvcProperties);
7144
}
7245

7346
@Bean
74-
@ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true)
7547
SwaggerIndexTransformer indexPageTransformer(SwaggerUiOAuthProperties swaggerUiOAuthProperties, ObjectMapper objectMapper) {
7648
return new SwaggerIndexTransformer(swaggerUiOAuthProperties, objectMapper);
7749
}
50+
51+
@Bean
52+
SwaggerWebMvcConfigurer swaggerWebMvcConfigurer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerIndexTransformer swaggerIndexTransformer){
53+
return new SwaggerWebMvcConfigurer(swaggerUiConfig,swaggerIndexTransformer);
54+
}
7855
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package org.springdoc.webmvc.ui;
2+
3+
import org.springdoc.core.SwaggerUiConfigProperties;
4+
5+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7+
8+
import static org.springdoc.core.Constants.CLASSPATH_RESOURCE_LOCATION;
9+
import static org.springdoc.core.Constants.DEFAULT_WEB_JARS_PREFIX_URL;
10+
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
11+
12+
@SuppressWarnings("deprecation")
13+
public class SwaggerWebMvcConfigurer extends WebMvcConfigurerAdapter { // NOSONAR
14+
15+
private String swaggerPath;
16+
17+
private SwaggerIndexTransformer swaggerIndexTransformer;
18+
19+
public SwaggerWebMvcConfigurer(SwaggerUiConfigProperties swaggerUiConfig, SwaggerIndexTransformer swaggerIndexTransformer) {
20+
this.swaggerPath = swaggerUiConfig.getPath();
21+
this.swaggerIndexTransformer = swaggerIndexTransformer;
22+
}
23+
24+
@Override
25+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
26+
StringBuilder uiRootPath = new StringBuilder();
27+
if (swaggerPath.contains("/"))
28+
uiRootPath.append(swaggerPath, 0, swaggerPath.lastIndexOf('/'));
29+
uiRootPath.append("/**");
30+
registry.addResourceHandler(uiRootPath + "/swagger-ui/**")
31+
.addResourceLocations(CLASSPATH_RESOURCE_LOCATION + DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR)
32+
.resourceChain(false)
33+
.addTransformer(swaggerIndexTransformer);
34+
}
35+
36+
}

springdoc-openapi-ui/src/main/java/org/springdoc/webmvc/ui/SwaggerWelcome.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,24 @@
2424

2525
import io.swagger.v3.oas.annotations.Operation;
2626
import org.apache.commons.lang3.ArrayUtils;
27-
import org.apache.commons.lang3.StringUtils;
2827
import org.springdoc.core.SpringDocConfigProperties;
2928
import org.springdoc.core.SpringDocConfiguration;
3029
import org.springdoc.core.SwaggerUiConfigProperties;
3130
import org.springdoc.ui.AbstractSwaggerWelcome;
3231

33-
import org.springframework.beans.factory.annotation.Value;
3432
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3533
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
34+
import org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties;
3635
import org.springframework.http.MediaType;
3736
import org.springframework.stereotype.Controller;
37+
import org.springframework.util.AntPathMatcher;
3838
import org.springframework.web.bind.annotation.GetMapping;
3939
import org.springframework.web.bind.annotation.ResponseBody;
4040
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
4141
import org.springframework.web.util.UriComponentsBuilder;
4242

43-
import static org.springdoc.core.Constants.MVC_SERVLET_PATH;
4443
import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_ENABLED;
4544
import static org.springdoc.core.Constants.SWAGGER_CONFIG_URL;
46-
import static org.springdoc.core.Constants.SWAGGER_UI_OAUTH_REDIRECT_URL;
4745
import static org.springdoc.core.Constants.SWAGGER_UI_PATH;
4846
import static org.springdoc.core.Constants.SWAGGER_UI_URL;
4947
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
@@ -54,11 +52,11 @@
5452
@ConditionalOnBean(SpringDocConfiguration.class)
5553
public class SwaggerWelcome extends AbstractSwaggerWelcome {
5654

57-
@Value(MVC_SERVLET_PATH)
5855
private String mvcServletPath;
5956

60-
public SwaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties) {
57+
public SwaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties, WebMvcProperties webMvcProperties) {
6158
super(swaggerUiConfig, springDocConfigProperties);
59+
this.mvcServletPath = webMvcProperties.getServlet().getPath();
6260
}
6361

6462
@Operation(hidden = true)
@@ -81,7 +79,7 @@ public Map<String, Object> openapiYaml(HttpServletRequest request) {
8179
@Override
8280
protected void calculateUiRootPath(StringBuilder... sbUrls) {
8381
StringBuilder sbUrl = new StringBuilder();
84-
if (StringUtils.isNotBlank(mvcServletPath))
82+
if(!AntPathMatcher.DEFAULT_PATH_SEPARATOR.equals(mvcServletPath))
8583
sbUrl.append(mvcServletPath);
8684
if (ArrayUtils.isNotEmpty(sbUrls))
8785
sbUrl = sbUrls[0];
@@ -93,16 +91,14 @@ protected void calculateUiRootPath(StringBuilder... sbUrls) {
9391

9492
@Override
9593
protected String buildUrl(String contextPath, final String docsUrl) {
96-
if (StringUtils.isNotBlank(mvcServletPath))
94+
if(!AntPathMatcher.DEFAULT_PATH_SEPARATOR.equals(mvcServletPath))
9795
contextPath += mvcServletPath;
9896
return super.buildUrl(contextPath, docsUrl);
9997
}
10098

10199
@Override
102100
protected void calculateOauth2RedirectUrl(UriComponentsBuilder uriComponentsBuilder) {
103-
if (StringUtils.isEmpty(oauth2RedirectUrl))
104-
swaggerUiConfig.setOauth2RedirectUrl(uriComponentsBuilder.path(this.uiRootPath).path(SWAGGER_UI_OAUTH_REDIRECT_URL).build().toString());
105-
else if (!swaggerUiConfig.isValidUrl(swaggerUiConfig.getOauth2RedirectUrl()))
101+
if (!swaggerUiConfig.isValidUrl(swaggerUiConfig.getOauth2RedirectUrl()))
106102
swaggerUiConfig.setOauth2RedirectUrl(uriComponentsBuilder.path(this.uiRootPath).path(swaggerUiConfig.getOauth2RedirectUrl()).build().toString());
107103
}
108104
}

springdoc-openapi-ui/src/test/java/test/org/springdoc/ui/app5/SpringDocOauthPathsWithPropertyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
3030
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
3131

32-
@TestPropertySource(properties = "springdoc.swagger-ui.oauth2RedirectUrl=http://localhost:8080/toto/test/swagger-ui/oauth2-redirect.html")
32+
@TestPropertySource(properties = "springdoc.swagger-ui.oauth2-redirect-url=http://localhost:8080/toto/test/swagger-ui/oauth2-redirect.html")
3333
public class SpringDocOauthPathsWithPropertyTest extends AbstractSpringDocTest {
3434

3535
@Test

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

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,31 @@
1919
package org.springdoc.webflux.ui;
2020

2121
import com.fasterxml.jackson.databind.ObjectMapper;
22+
import org.springdoc.core.SpringDocConfigProperties;
2223
import org.springdoc.core.SpringDocConfiguration;
24+
import org.springdoc.core.SwaggerUiConfigProperties;
2325
import org.springdoc.core.SwaggerUiOAuthProperties;
2426

25-
import org.springframework.beans.factory.annotation.Autowired;
26-
import org.springframework.beans.factory.annotation.Value;
2727
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2828
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2929
import org.springframework.context.annotation.Bean;
3030
import org.springframework.context.annotation.Configuration;
31-
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
3231
import org.springframework.web.reactive.config.WebFluxConfigurer;
3332

34-
import static org.springdoc.core.Constants.CLASSPATH_RESOURCE_LOCATION;
35-
import static org.springdoc.core.Constants.DEFAULT_WEB_JARS_PREFIX_URL;
3633
import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_ENABLED;
37-
import static org.springdoc.core.Constants.SWAGGER_UI_PATH;
38-
import static org.springdoc.core.Constants.WEB_JARS_PREFIX_URL;
39-
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
4034

4135

4236
@Configuration
4337
@ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true)
4438
@ConditionalOnBean(SpringDocConfiguration.class)
4539
public class SwaggerConfig implements WebFluxConfigurer {
4640

47-
@Value(SWAGGER_UI_PATH)
48-
private String swaggerPath;
49-
50-
@Value(WEB_JARS_PREFIX_URL)
51-
private String webJarsPrefixUrl;
52-
53-
@Autowired
54-
private SwaggerIndexTransformer swaggerIndexTransformer;
55-
56-
@Override
57-
public void addResourceHandlers(ResourceHandlerRegistry registry) {
58-
StringBuilder uiRootPath = new StringBuilder();
59-
if (swaggerPath.contains("/")) {
60-
uiRootPath.append(swaggerPath, 0, swaggerPath.lastIndexOf('/'));
61-
}
62-
registry.addResourceHandler(uiRootPath + webJarsPrefixUrl + "/**")
63-
.addResourceLocations(CLASSPATH_RESOURCE_LOCATION + DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR)
64-
.resourceChain(false)
65-
.addTransformer(swaggerIndexTransformer);
41+
@Bean
42+
SwaggerWebFluxConfigurer swaggerWebFluxConfigurer(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties, SwaggerIndexTransformer swaggerIndexTransformer) {
43+
return new SwaggerWebFluxConfigurer(swaggerUiConfig, springDocConfigProperties, swaggerIndexTransformer);
6644
}
6745

6846
@Bean
69-
@ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true)
7047
SwaggerIndexTransformer indexPageTransformer(SwaggerUiOAuthProperties swaggerUiOAuthProperties, ObjectMapper objectMapper) {
7148
return new SwaggerIndexTransformer(swaggerUiOAuthProperties, objectMapper);
7249
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.springdoc.webflux.ui;
2+
3+
import org.springdoc.core.SpringDocConfigProperties;
4+
import org.springdoc.core.SwaggerUiConfigProperties;
5+
6+
import org.springframework.web.reactive.config.ResourceHandlerRegistry;
7+
import org.springframework.web.reactive.config.WebFluxConfigurer;
8+
9+
import static org.springdoc.core.Constants.CLASSPATH_RESOURCE_LOCATION;
10+
import static org.springdoc.core.Constants.DEFAULT_WEB_JARS_PREFIX_URL;
11+
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
12+
13+
public class SwaggerWebFluxConfigurer implements WebFluxConfigurer {
14+
15+
private String swaggerPath;
16+
17+
private String webJarsPrefixUrl;
18+
19+
private SwaggerIndexTransformer swaggerIndexTransformer;
20+
21+
public SwaggerWebFluxConfigurer(SwaggerUiConfigProperties swaggerUiConfig, SpringDocConfigProperties springDocConfigProperties, SwaggerIndexTransformer swaggerIndexTransformer) {
22+
this.swaggerPath = swaggerUiConfig.getPath();
23+
this.webJarsPrefixUrl = springDocConfigProperties.getWebjars().getPrefix();
24+
this.swaggerIndexTransformer = swaggerIndexTransformer;
25+
}
26+
27+
@Override
28+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
29+
StringBuilder uiRootPath = new StringBuilder();
30+
if (swaggerPath.contains("/")) {
31+
uiRootPath.append(swaggerPath, 0, swaggerPath.lastIndexOf('/'));
32+
}
33+
registry.addResourceHandler(uiRootPath + webJarsPrefixUrl + "/**")
34+
.addResourceLocations(CLASSPATH_RESOURCE_LOCATION + DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR)
35+
.resourceChain(false)
36+
.addTransformer(swaggerIndexTransformer);
37+
}
38+
39+
}

0 commit comments

Comments
 (0)