Skip to content

Commit 4d8072c

Browse files
committed
Improve compatibility with new PathMatcher. Fixes #965.
1 parent 86277b0 commit 4d8072c

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,6 @@ public final class Constants {
305305
*/
306306
public static final String HEALTH_PATTERN = "/health/*";
307307

308-
/**
309-
* The constant SWAGGER_UI_PATTERN.
310-
*/
311-
public static final String SWAGGER_UI_PATTERN = SWAGGER_UI_PREFIX + ALL_PATTERN;
312-
313308
/**
314309
* The constant SPRINGDOC_USE_MANAGEMENT_PORT.
315310
*/

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
2929
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
3030

31-
import static org.springdoc.core.Constants.ALL_PATTERN;
3231
import static org.springdoc.core.Constants.CLASSPATH_RESOURCE_LOCATION;
3332
import static org.springdoc.core.Constants.DEFAULT_WEB_JARS_PREFIX_URL;
34-
import static org.springdoc.core.Constants.SWAGGER_UI_PATTERN;
33+
import static org.springdoc.core.Constants.SWAGGER_UI_PREFIX;
3534
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
3635

3736
/**
@@ -79,8 +78,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
7978
if (actuatorProvider.isPresent() && actuatorProvider.get().isUseManagementPort())
8079
uiRootPath.append(actuatorProvider.get().getBasePath());
8180

82-
uiRootPath.append(ALL_PATTERN);
83-
registry.addResourceHandler(uiRootPath + SWAGGER_UI_PATTERN)
81+
registry.addResourceHandler(uiRootPath +SWAGGER_UI_PREFIX +"*/**")
8482
.addResourceLocations(CLASSPATH_RESOURCE_LOCATION + DEFAULT_WEB_JARS_PREFIX_URL + DEFAULT_PATH_SEPARATOR)
8583
.resourceChain(false)
8684
.addTransformer(swaggerIndexTransformer);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
*
3+
* *
4+
* * * Copyright 2019-2020 the original author or authors.
5+
* * *
6+
* * * Licensed under the Apache License, Version 2.0 (the "License");
7+
* * * you may not use this file except in compliance with the License.
8+
* * * You may obtain a copy of the License at
9+
* * *
10+
* * * https://www.apache.org/licenses/LICENSE-2.0
11+
* * *
12+
* * * Unless required by applicable law or agreed to in writing, software
13+
* * * distributed under the License is distributed on an "AS IS" BASIS,
14+
* * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* * * See the License for the specific language governing permissions and
16+
* * * limitations under the License.
17+
* *
18+
*
19+
*/
20+
21+
package test.org.springdoc.ui.app3;
22+
23+
/**
24+
* @author bnasslashen
25+
*/
26+
27+
import org.springframework.context.annotation.Configuration;
28+
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
29+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
30+
import org.springframework.web.util.pattern.PathPatternParser;
31+
32+
@Configuration
33+
public class WebConfig implements WebMvcConfigurer {
34+
35+
@Override
36+
public void configurePathMatch(PathMatchConfigurer configurer) {
37+
configurer
38+
.setPatternParser(new PathPatternParser());
39+
}
40+
}

0 commit comments

Comments
 (0)