Skip to content

Commit b403d0f

Browse files
committed
Add Spring Boot 4.0.0-M2 support #3062
1 parent 31c99b3 commit b403d0f

File tree

23 files changed

+203
-177
lines changed

23 files changed

+203
-177
lines changed

pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>4.0.0-M1</version>
14+
<version>4.0.0-M2</version>
1515
</parent>
1616

1717
<licenses>
@@ -104,6 +104,11 @@
104104
<artifactId>spring-boot-starter-test</artifactId>
105105
<scope>test</scope>
106106
</dependency>
107+
<dependency>
108+
<groupId>org.springframework.boot</groupId>
109+
<artifactId>spring-boot-jackson</artifactId>
110+
<scope>test</scope>
111+
</dependency>
107112
</dependencies>
108113
<build>
109114
<plugins>

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/providers/SpringDocJavadocProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828

2929
import java.lang.reflect.Field;
3030
import java.lang.reflect.Method;
31-
import java.util.*;
31+
import java.util.Arrays;
32+
import java.util.HashMap;
33+
import java.util.List;
34+
import java.util.Map;
35+
import java.util.Objects;
3236
import java.util.stream.Collectors;
3337

3438
import com.github.therapi.runtimejavadoc.ClassJavadoc;

springdoc-openapi-starter-webflux-api/pom.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@
2929
<optional>true</optional>
3030
</dependency>
3131
<!-- Test dependencies -->
32-
<dependency>
33-
<groupId>org.springframework.boot</groupId>
34-
<artifactId>spring-boot-jackson</artifactId>
35-
<scope>test</scope>
36-
</dependency>
32+
3733
</dependencies>
3834
<build>
3935
<plugins>

springdoc-openapi-starter-webflux-ui/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
<artifactId>spring-boot-reactor-netty</artifactId>
3535
<scope>test</scope>
3636
</dependency>
37-
<dependency>
38-
<groupId>org.springframework.boot</groupId>
39-
<artifactId>spring-boot-jackson</artifactId>
40-
<scope>test</scope>
41-
</dependency>
4237
</dependencies>
4338
<build>
4439
<plugins>

springdoc-openapi-starter-webmvc-api/pom.xml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,23 @@
2222
<groupId>org.springframework.boot</groupId>
2323
<artifactId>spring-boot-web-server</artifactId>
2424
</dependency>
25+
<dependency>
26+
<groupId>jakarta.servlet</groupId>
27+
<artifactId>jakarta.servlet-api</artifactId>
28+
<scope>provided</scope>
29+
</dependency>
2530
<!-- Actuator dependencies -->
2631
<dependency>
2732
<groupId>org.springframework.boot</groupId>
2833
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
2934
<optional>true</optional>
3035
</dependency>
31-
<dependency>
32-
<groupId>jakarta.servlet</groupId>
33-
<artifactId>jakarta.servlet-api</artifactId>
34-
<scope>provided</scope>
35-
</dependency>
3636
<!-- Test dependencies -->
3737
<dependency>
3838
<groupId>javax.money</groupId>
3939
<artifactId>money-api</artifactId>
4040
<scope>test</scope>
4141
</dependency>
42-
<dependency>
43-
<groupId>org.springframework.boot</groupId>
44-
<artifactId>spring-boot-jackson</artifactId>
45-
<scope>test</scope>
46-
</dependency>
4742
</dependencies>
4843
<build>
4944
<plugins>

springdoc-openapi-starter-webmvc-ui/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
3535
<optional>true</optional>
3636
</dependency>
37-
<dependency>
38-
<groupId>org.springframework.boot</groupId>
39-
<artifactId>spring-boot-restclient</artifactId>
40-
<scope>test</scope>
41-
</dependency>
4237
<dependency>
4338
<groupId>org.springframework.boot</groupId>
4439
<artifactId>spring-boot-tomcat</artifactId>

springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/AbstractSpringDocActuatorTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,30 @@
2525
package test.org.springdoc.ui;
2626

2727

28+
import java.net.http.HttpClient;
29+
2830
import jakarta.annotation.PostConstruct;
2931

30-
import org.springframework.beans.factory.annotation.Autowired;
31-
import org.springframework.boot.restclient.RestTemplateBuilder;
3232
import org.springframework.boot.web.server.test.LocalManagementPort;
33-
import org.springframework.web.client.RestTemplate;
33+
import org.springframework.http.client.JdkClientHttpRequestFactory;
34+
import org.springframework.web.client.RestClient;
3435

3536
public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest {
3637

37-
protected RestTemplate actuatorRestTemplate;
38+
protected RestClient actuatorClient;
3839

3940
@LocalManagementPort
4041
private int managementPort;
4142

42-
@Autowired
43-
private RestTemplateBuilder restTemplateBuilder;
44-
4543
@PostConstruct
4644
void init() {
47-
actuatorRestTemplate = restTemplateBuilder
48-
.rootUri("http://localhost:" + this.managementPort).build();
45+
HttpClient jdkClient = HttpClient.newBuilder()
46+
.followRedirects(HttpClient.Redirect.NORMAL)
47+
.build();
48+
this.actuatorClient = RestClient.builder()
49+
.requestFactory(new JdkClientHttpRequestFactory(jdkClient))
50+
.baseUrl("http://localhost:" + managementPort)
51+
.build();
4952
}
53+
5054
}

springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@ void testIndex() throws Exception {
4545

4646
@Test
4747
void testIndexActuator() {
48-
String contentAsString = actuatorRestTemplate.getForObject("/application/swagger-ui", String.class);
48+
String contentAsString = actuatorClient.get()
49+
.uri("/application/swagger-ui")
50+
.retrieve()
51+
.body(String.class);
4952
assertTrue(contentAsString.contains("Swagger UI"));
5053
}
5154

5255
@Test
5356
void testIndexSwaggerConfig() throws Exception {
54-
String contentAsString = actuatorRestTemplate.getForObject("/application/swagger-ui/swagger-config", String.class);
57+
String contentAsString = actuatorClient.get()
58+
.uri("/application/swagger-ui/swagger-config")
59+
.retrieve()
60+
.body(String.class);
5561
String expected = getContent("results/app13-1.json");
5662
assertEquals(expected, contentAsString, true);
5763
}

springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,26 @@ void testIndex() throws Exception {
4242
String contentAsString = mvcResult.getResponse().getContentAsString();
4343
assertTrue(contentAsString.contains("Swagger UI"));
4444
}
45-
4645
@Test
4746
void testIndexActuator() {
48-
String contentAsString = actuatorRestTemplate.getForObject("/application/swagger-ui", String.class);
47+
String contentAsString = actuatorClient.get()
48+
.uri("/application/swagger-ui")
49+
.retrieve()
50+
.body(String.class);
51+
4952
assertTrue(contentAsString.contains("Swagger UI"));
5053
}
5154

5255
@Test
5356
void testIndexSwaggerConfig() throws Exception {
54-
String contentAsString = actuatorRestTemplate.getForObject("/application/swagger-ui/swagger-config", String.class);
57+
String contentAsString = actuatorClient.get()
58+
.uri("/application/swagger-ui/swagger-config")
59+
.retrieve()
60+
.body(String.class);
61+
5562
String expected = getContent("results/app14-1.json");
56-
assertEquals(expected, contentAsString, true);
63+
64+
assertEquals(expected, contentAsString, true); // true = strict comparison
5765
}
5866

5967
@SpringBootApplication

springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,26 @@ void testIndex() throws Exception {
4646
assertTrue(contentAsString.contains("Swagger UI"));
4747
}
4848

49+
4950
@Test
5051
void testIndexActuator() {
51-
String contentAsString = actuatorRestTemplate.getForObject("/test/application/swagger-ui", String.class);
52+
String contentAsString = actuatorClient.get()
53+
.uri("/test/application/swagger-ui")
54+
.retrieve()
55+
.body(String.class);
56+
5257
assertTrue(contentAsString.contains("Swagger UI"));
5358
}
5459

5560
@Test
5661
void testIndexSwaggerConfig() throws Exception {
57-
String contentAsString = actuatorRestTemplate.getForObject("/test/application/swagger-ui/swagger-config", String.class);
62+
String contentAsString = actuatorClient.get()
63+
.uri("/test/application/swagger-ui/swagger-config")
64+
.retrieve()
65+
.body(String.class);
66+
5867
String expected = getContent("results/app15-1.json");
68+
5969
assertEquals(expected, contentAsString, true);
6070
}
6171

0 commit comments

Comments
 (0)