Skip to content

Commit 671a440

Browse files
committed
Add Spring Boot 4.0.0-M1 support #3062
1 parent e1b9f71 commit 671a440

File tree

297 files changed

+3140
-3938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+3140
-3938
lines changed

pom.xml

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>org.springdoc</groupId>
44
<artifactId>springdoc-openapi</artifactId>
5-
<version>2.8.11-SNAPSHOT</version>
5+
<version>3.0.0-SNAPSHOT</version>
66
<packaging>pom</packaging>
77
<name>Spring openapi documentation</name>
88
<description>Spring openapi documentation</description>
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>3.5.4</version>
14+
<version>4.0.0-M1</version>
1515
</parent>
1616

1717
<licenses>
@@ -58,8 +58,8 @@
5858
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
5959
<jjwt.version>0.9.1</jjwt.version>
6060
<therapi-runtime-javadoc.version>0.15.0</therapi-runtime-javadoc.version>
61-
<spring-cloud-function.version>4.2.2</spring-cloud-function.version>
62-
<spring-security-oauth2-authorization-server.version>1.4.3
61+
<spring-cloud-function.version>5.0.0-M1</spring-cloud-function.version>
62+
<spring-security-oauth2-authorization-server.version>2.0.0-M1
6363
</spring-security-oauth2-authorization-server.version>
6464
</properties>
6565

@@ -223,30 +223,4 @@
223223
</build>
224224
</profile>
225225
</profiles>
226-
<repositories>
227-
<repository>
228-
<id>spring-milestones</id>
229-
<name>Spring Milestones</name>
230-
<url>https://repo.spring.io/milestone</url>
231-
<releases>
232-
<enabled>true</enabled>
233-
</releases>
234-
<snapshots>
235-
<enabled>false</enabled>
236-
</snapshots>
237-
</repository>
238-
</repositories>
239-
<pluginRepositories>
240-
<pluginRepository>
241-
<id>spring-milestones</id>
242-
<name>Spring Milestones</name>
243-
<url>https://repo.spring.io/milestone</url>
244-
<releases>
245-
<enabled>true</enabled>
246-
</releases>
247-
<snapshots>
248-
<enabled>false</enabled>
249-
</snapshots>
250-
</pluginRepository>
251-
</pluginRepositories>
252226
</project>

springdoc-openapi-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.springdoc</groupId>
55
<artifactId>springdoc-openapi</artifactId>
6-
<version>2.8.11-SNAPSHOT</version>
6+
<version>3.0.0-SNAPSHOT</version>
77
</parent>
88
<artifactId>springdoc-openapi-bom</artifactId>
99
<name>${project.artifactId}</name>

springdoc-openapi-starter-common/pom.xml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.springdoc</groupId>
55
<artifactId>springdoc-openapi</artifactId>
6-
<version>2.8.11-SNAPSHOT</version>
6+
<version>3.0.0-SNAPSHOT</version>
77
</parent>
88
<artifactId>springdoc-openapi-starter-common</artifactId>
99
<name>${project.artifactId}</name>
@@ -14,21 +14,21 @@
1414
</dependency>
1515
<dependency>
1616
<groupId>org.springframework.boot</groupId>
17-
<artifactId>spring-boot-starter-validation</artifactId>
17+
<artifactId>spring-boot-validation</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>io.swagger.core.v3</groupId>
21+
<artifactId>swagger-core-jakarta</artifactId>
1822
</dependency>
1923
<dependency>
2024
<groupId>org.springframework.boot</groupId>
2125
<artifactId>spring-boot-configuration-processor</artifactId>
2226
<optional>true</optional>
2327
</dependency>
24-
<dependency>
25-
<groupId>io.swagger.core.v3</groupId>
26-
<artifactId>swagger-core-jakarta</artifactId>
27-
</dependency>
2828
<!-- Actuator dependencies -->
2929
<dependency>
3030
<groupId>org.springframework.boot</groupId>
31-
<artifactId>spring-boot-starter-actuator</artifactId>
31+
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
3232
<optional>true</optional>
3333
</dependency>
3434
<!-- For Spring Cloud Function Support -->
@@ -61,6 +61,16 @@
6161
<artifactId>spring-security-oauth2-client</artifactId>
6262
<optional>true</optional>
6363
</dependency>
64+
<dependency>
65+
<groupId>jakarta.servlet</groupId>
66+
<artifactId>jakarta.servlet-api</artifactId>
67+
<scope>provided</scope>
68+
</dependency>
69+
<dependency>
70+
<groupId>org.springframework.boot</groupId>
71+
<artifactId>spring-boot-web-server</artifactId>
72+
<optional>true</optional>
73+
</dependency>
6474
<!-- Kotlin -->
6575
<dependency>
6676
<groupId>com.fasterxml.jackson.module</groupId>
@@ -85,14 +95,24 @@
8595
<!-- Spring Web /Data Rest/Hateoas && For Enhanced Pageable Support-->
8696
<dependency>
8797
<groupId>org.springframework.boot</groupId>
88-
<artifactId>spring-boot-starter-data-rest</artifactId>
98+
<artifactId>spring-boot-data-rest</artifactId>
99+
<optional>true</optional>
100+
</dependency>
101+
<dependency>
102+
<groupId>org.springframework.boot</groupId>
103+
<artifactId>spring-boot-hateoas</artifactId>
89104
<optional>true</optional>
90105
</dependency>
91106
<dependency>
92107
<groupId>com.querydsl</groupId>
93108
<artifactId>querydsl-core</artifactId>
94109
<optional>true</optional>
95110
</dependency>
111+
<dependency>
112+
<groupId>commons-logging</groupId>
113+
<artifactId>commons-logging</artifactId>
114+
<scope>test</scope>
115+
</dependency>
96116
</dependencies>
97117
<build>
98118
<resources>

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@
110110
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
111111
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
112112
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
113-
import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties;
114113
import org.springframework.boot.autoconfigure.web.format.WebConversionService;
114+
import org.springframework.boot.data.autoconfigure.web.SpringDataWebProperties;
115115
import org.springframework.context.MessageSource;
116116
import org.springframework.context.annotation.Bean;
117117
import org.springframework.context.annotation.Conditional;

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocDataRestConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
5555
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
5656
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
57-
import org.springframework.boot.autoconfigure.hateoas.HateoasProperties;
57+
import org.springframework.boot.hateoas.autoconfigure.HateoasProperties;
5858
import org.springframework.context.annotation.Bean;
5959
import org.springframework.context.annotation.Configuration;
6060
import org.springframework.context.annotation.ImportRuntimeHints;

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocHateoasConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
4545
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
4646
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
47-
import org.springframework.boot.autoconfigure.hateoas.HateoasProperties;
47+
import org.springframework.boot.hateoas.autoconfigure.HateoasProperties;
4848
import org.springframework.context.annotation.Bean;
4949
import org.springframework.context.annotation.Configuration;
5050
import org.springframework.context.annotation.Lazy;

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocSecurityConfiguration.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@
6767
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
6868
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
6969
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
70-
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
7170
import org.springframework.security.web.util.matcher.RequestMatcher;
72-
import org.springframework.web.util.pattern.PathPattern;
7371

7472
import static org.springdoc.core.utils.Constants.SPRINGDOC_SHOW_LOGIN_ENDPOINT;
7573
import static org.springdoc.core.utils.Constants.SPRINGDOC_SHOW_OAUTH2_ENDPOINTS;
7674
import static org.springdoc.core.utils.SpringDocUtils.getConfig;
75+
import static org.springdoc.core.utils.SpringSecurityUtils.getPath;
7776

7877
/**
7978
* The type Spring doc security configuration.
@@ -164,24 +163,12 @@ OpenApiCustomizer springSecurityLoginEndpointCustomizer(ApplicationContext appli
164163
true
165164
);
166165

167-
String loginPath = null;
168-
169-
if (requestMatcher instanceof AntPathRequestMatcher) {
170-
loginPath = ((AntPathRequestMatcher) requestMatcher).getPattern();
171-
}
172-
else if (requestMatcher instanceof PathPatternRequestMatcher) {
173-
PathPattern pathPattern = (PathPattern) FieldUtils.readField(
174-
requestMatcher,
175-
"pattern",
176-
true
177-
);
178-
loginPath = pathPattern.getPatternString();
166+
if (requestMatcher instanceof PathPatternRequestMatcher pathPatternRequestMatcher) {
167+
String loginPath = getPath(pathPatternRequestMatcher);
168+
openAPI.getPaths().addPathItem(loginPath, pathItem);
179169
}
180-
181-
openAPI.getPaths().addPathItem(loginPath, pathItem);
182170
}
183-
catch (IllegalAccessException |
184-
ClassCastException ignored) {
171+
catch (IllegalAccessException | ClassCastException ignored) {
185172
// Exception escaped
186173
LOGGER.trace(ignored.getMessage());
187174
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocSecurityOAuth2Customizer.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@
7979
import org.springframework.security.web.FilterChainProxy;
8080
import org.springframework.security.web.SecurityFilterChain;
8181
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
82-
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
82+
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
8383
import org.springframework.security.web.util.matcher.OrRequestMatcher;
8484
import org.springframework.security.web.util.matcher.RequestMatcher;
8585
import org.springframework.util.ReflectionUtils;
8686

87+
import static org.springdoc.core.utils.SpringSecurityUtils.getPath;
8788
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
8889
import static org.springframework.http.MediaType.TEXT_HTML_VALUE;
8990

@@ -496,24 +497,26 @@ private void buildPath(Object oAuth2EndpointFilter, String authorizationEndpoint
496497
try {
497498
RequestMatcher endpointMatcher = (RequestMatcher) FieldUtils.readDeclaredField(oAuth2EndpointFilter, authorizationEndpointMatcher, true);
498499
String path = null;
499-
if (endpointMatcher instanceof AntPathRequestMatcher antPathRequestMatcher)
500-
path = antPathRequestMatcher.getPattern();
500+
if (endpointMatcher instanceof PathPatternRequestMatcher pathPatternRequestMatcher) {
501+
path = getPath(pathPatternRequestMatcher);
502+
}
501503
else if (endpointMatcher instanceof OrRequestMatcher endpointMatchers) {
502504
Iterable<RequestMatcher> requestMatchers = (Iterable<RequestMatcher>) FieldUtils.readDeclaredField(endpointMatchers, "requestMatchers", true);
503505
for (RequestMatcher requestMatcher : requestMatchers) {
504506
if (requestMatcher instanceof OrRequestMatcher orRequestMatcher) {
505507
requestMatchers = (Iterable<RequestMatcher>) FieldUtils.readDeclaredField(orRequestMatcher, "requestMatchers", true);
506508
for (RequestMatcher matcher : requestMatchers) {
507-
if (matcher instanceof AntPathRequestMatcher antPathRequestMatcher)
508-
path = antPathRequestMatcher.getPattern();
509+
if (matcher instanceof PathPatternRequestMatcher pathPatternRequestMatcher) {
510+
path = getPath(pathPatternRequestMatcher);
511+
}
509512
}
510513
}
511-
else if (requestMatcher instanceof AntPathRequestMatcher antPathRequestMatcher) {
512-
path = antPathRequestMatcher.getPattern();
514+
else if (requestMatcher instanceof PathPatternRequestMatcher pathPatternRequestMatcher) {
515+
path = getPath(pathPatternRequestMatcher);
513516
}
514517
}
515518
}
516-
519+
517520
PathItem pathItem = new PathItem();
518521
if (HttpMethod.POST.equals(requestMethod)) {
519522
pathItem.post(operation);
@@ -528,8 +531,10 @@ else if (HttpMethod.GET.equals(requestMethod)) {
528531
}
529532
}
530533

534+
531535
@Override
532-
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
536+
public void setApplicationContext(ApplicationContext applicationContext) throws
537+
BeansException {
533538
this.applicationContext = applicationContext;
534539
}
535540
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/QuerydslPredicateOperationCustomizer.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@
5353
import org.springdoc.core.properties.SpringDocConfigProperties;
5454

5555
import org.springframework.core.MethodParameter;
56+
import org.springframework.core.ResolvableType;
5657
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
5758
import org.springframework.data.querydsl.binding.QuerydslBindings;
5859
import org.springframework.data.querydsl.binding.QuerydslBindingsFactory;
5960
import org.springframework.data.querydsl.binding.QuerydslPredicate;
60-
import org.springframework.data.util.CastUtils;
61-
import org.springframework.data.util.ClassTypeInformation;
6261
import org.springframework.data.util.TypeInformation;
6362
import org.springframework.util.CollectionUtils;
6463
import org.springframework.web.method.HandlerMethod;
@@ -174,15 +173,23 @@ private boolean getFieldValueOfBoolean(QuerydslBindings instance, String fieldNa
174173
* @return the querydsl bindings
175174
*/
176175
private QuerydslBindings extractQdslBindings(QuerydslPredicate predicate) {
177-
ClassTypeInformation<?> classTypeInformation = ClassTypeInformation.from(predicate.root());
178-
TypeInformation<?> domainType = classTypeInformation.getRequiredActualType();
179-
180-
Optional<Class<? extends QuerydslBinderCustomizer<?>>> bindingsAnnotation = Optional.of(predicate)
181-
.map(QuerydslPredicate::bindings)
182-
.map(CastUtils::cast);
176+
// Replacement for ClassTypeInformation.from(...).getRequiredActualType()
177+
TypeInformation<?> domainType = TypeInformation
178+
.of(ResolvableType.forClass(predicate.root()))
179+
.getRequiredActualType();
180+
// Replacement for CastUtils::cast
181+
Optional<Class<? extends QuerydslBinderCustomizer<?>>> bindingsAnnotation =
182+
Optional.of(predicate)
183+
.map(QuerydslPredicate::bindings)
184+
.map(clazz -> {
185+
@SuppressWarnings("unchecked")
186+
Class<? extends QuerydslBinderCustomizer<?>> typed =
187+
(Class<? extends QuerydslBinderCustomizer<?>>) clazz;
188+
return typed;
189+
});
183190

184191
return bindingsAnnotation
185-
.map(it -> querydslBindingsFactory.createBindingsFor(domainType, it))
192+
.map(customizer -> querydslBindingsFactory.createBindingsFor(domainType, customizer))
186193
.orElseGet(() -> querydslBindingsFactory.createBindingsFor(domainType));
187194
}
188195

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/data/DataRestRequestService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.springframework.data.rest.webmvc.PersistentEntityResource;
6161
import org.springframework.data.rest.webmvc.support.BackendId;
6262
import org.springframework.data.rest.webmvc.support.DefaultedPageable;
63-
import org.springframework.http.HttpHeaders;
6463
import org.springframework.web.bind.annotation.RequestHeader;
6564
import org.springframework.web.bind.annotation.RequestMethod;
6665
import org.springframework.web.method.HandlerMethod;
@@ -253,6 +252,6 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
253252
*/
254253
private boolean isHeaderToIgnore(MethodParameter methodParameter) {
255254
RequestHeader requestHeader = methodParameter.getParameterAnnotation(RequestHeader.class);
256-
return requestHeader != null && HttpHeaders.ACCEPT.equals(requestHeader.value());
255+
return requestHeader != null;
257256
}
258257
}

0 commit comments

Comments
 (0)