Skip to content

Commit 90f6f84

Browse files
antoinelochetAntoine Lochet
authored andcommitted
Spring Boot 4 GA
1 parent 58e90c4 commit 90f6f84

File tree

19 files changed

+166
-733
lines changed

19 files changed

+166
-733
lines changed

README.md

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ This is why we came up with this project.
4949
- [Documenting Bean Validation constraints](#documenting-bean-validation-constraints)
5050
- [Migrate existing Spring REST Docs tests](#migrate-existing-spring-rest-docs-tests)
5151
- [MockMvc based tests](#mockmvc-based-tests)
52-
- [REST Assured based tests](#rest-assured-based-tests)
5352
- [WebTestClient based tests](#webtestclient-based-tests)
5453
- [Security Definitions in OpenAPI](#security-definitions-in-openapi)
5554
- [Running the gradle plugin](#running-the-gradle-plugin)
@@ -70,10 +69,11 @@ This is why we came up with this project.
7069

7170
Spring Boot and Spring REST Docs 3.0.0 introduced [breaking chances to how request parameters are documented: `RequestParameterSnippet` was split into `QueryParameterSnippet` and `FormParameterSnippet`.](https://github.com/spring-projects/spring-restdocs/issues/832)
7271

73-
|Spring Boot version | restdocs-api-spec version|
74-
|---|---|
75-
|3.x|0.17.1 or later|
76-
|2.x|0.16.4|
72+
| Spring Boot version | restdocs-api-spec version |
73+
|---------------------|---------------------------|
74+
| 4.x | 0.XX.X or later |
75+
| 3.x | 0.17.1 to 0.19.4 |
76+
| 2.x | 0.16.4 |
7777

7878
### Project structure
7979

@@ -83,7 +83,6 @@ The project consists of the following main components:
8383
This is most importantly the [ResourceDocumentation](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apispec/ResourceDocumentation.kt) which is the entry point to use the extension in your tests.
8484
The [ResourceSnippet](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apispec/ResourceSnippet.kt) is the snippet used to produce a json file `resource.json` containing all the details about the documented resource.
8585
- [restdocs-api-spec-mockmvc](restdocs-api-spec-mockmvc) - contains a wrapper for `MockMvcRestDocumentation` for easier migration to `restdocs-api-spec` from MockMvc tests that use plain `spring-rest-docs-mockmvc`.
86-
- [restdocs-api-spec-restassured](restdocs-api-spec-restassured) - contains a wrapper for `RestAssuredRestDocumentation` for easier migration to `restdocs-api-spec` from [Rest Assured](http://rest-assured.io) tests that use plain `spring-rest-docs-restassured`.
8786
- [restdocs-api-spec-gradle-plugin](restdocs-api-spec-gradle-plugin) - adds a gradle plugin that aggregates the `resource.json` files produced by `ResourceSnippet` into an API specification file for the whole project.
8887

8988
### Build configuration
@@ -94,7 +93,7 @@ The [ResourceSnippet](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apis
9493
* Using the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block):
9594
```groovy
9695
plugins {
97-
id 'com.epages.restdocs-api-spec' version '0.18.2'
96+
id 'com.epages.restdocs-api-spec' version '0.XX.X'
9897
}
9998
```
10099
Examples with Kotlin are also available [here](https://plugins.gradle.org/plugin/com.epages.restdocs-api-spec)
@@ -110,7 +109,7 @@ The [ResourceSnippet](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apis
110109
}
111110
}
112111
dependencies {
113-
classpath "com.epages:restdocs-api-spec-gradle-plugin:0.18.2" //1.2
112+
classpath "com.epages:restdocs-api-spec-gradle-plugin:0.XX.X" //1.2
114113
}
115114
}
116115
@@ -119,7 +118,7 @@ The [ResourceSnippet](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apis
119118
```
120119
2. Add required dependencies to your tests
121120
* *2.1* add the `mavenCentral` repository used to resolve the `com.epages:restdocs-api-spec` module of the project.
122-
* *2.2* add the actual `restdocs-api-spec-mockmvc` dependency to the test scope. Use `restdocs-api-spec-restassured` if you use `RestAssured` instead of `MockMvc`.
121+
* *2.2* add the actual `restdocs-api-spec-mockmvc` dependency to the test scope.
123122
* *2.3* add configuration options for `restdocs-api-spec-gradle-plugin`. See [Gradle plugin configuration](#gradle-plugin-configuration)
124123
```groovy
125124
@@ -129,7 +128,7 @@ The [ResourceSnippet](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apis
129128
130129
dependencies {
131130
//..
132-
testImplementation('com.epages:restdocs-api-spec-mockmvc:0.18.2') //2.2
131+
testImplementation('com.epages:restdocs-api-spec-mockmvc:0.XX.X') //2.2
133132
}
134133
135134
openapi { //2.3
@@ -298,30 +297,6 @@ resultActions
298297
This will do exactly what `MockMvcRestDocumentation.document` does.
299298
Additionally it will add a `ResourceSnippet` with the descriptors you provided in the `RequestFieldsSnippet`, `ResponseFieldsSnippet`, and `LinksSnippet`.
300299

301-
#### REST Assured based tests
302-
303-
Also for REST Assured we offer a convenience wrapper similar to `MockMvcRestDocumentationWrapper`.
304-
The usage for REST Assured is also similar to MockMVC, except that [com.epages.restdocs.apispec.RestAssuredRestDocumentationWrapper](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apispec/RestAssuredRestDocumentationWrapper.kt) is used instead of [com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper](restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apispec/MockMvcRestDocumentationWrapper.kt).
305-
306-
To use the `RestAssuredRestDocumentationWrapper`, you have to add a dependency to [restdocs-api-spec-restassured](restdocs-api-spec-restassured) to your build.
307-
```java
308-
RestAssured.given(this.spec)
309-
.filter(RestAssuredRestDocumentationWrapper.document("{method-name}",
310-
"The API description",
311-
requestParameters(
312-
parameterWithName("param").description("the param")
313-
),
314-
responseFields(
315-
fieldWithPath("doc.timestamp").description("Creation timestamp")
316-
)
317-
))
318-
.when()
319-
.queryParam("param", "foo")
320-
.get("/restAssuredExample")
321-
.then()
322-
.statusCode(200);
323-
```
324-
325300
#### WebTestClient based tests
326301

327302
We also offer a convenience wrapper for `WebTestClient` which works similar to `MockMvcRestDocumentationWrapper`.
@@ -586,7 +561,7 @@ Given that the `master` branch on the upstream repository is in the state from w
586561
587562
[Create release via the GitHub UI](https://github.com/ePages-de/restdocs-api-spec/releases/new).
588563
589-
Use the intended version number as "Tag version", e.g. "0.18.2".
564+
Use the intended version number as "Tag version", e.g. "0.XX.X".
590565
This will automatically trigger a GitHub Action build which publishes the JAR files for this release to Sonatype.
591566
592567
**(2) Login to Sonatype**

build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

2+
import org.gradle.kotlin.dsl.withType
23
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
34
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
45
import org.jmailen.gradle.kotlinter.tasks.LintTask
6+
import org.springframework.boot.gradle.tasks.bundling.BootJar
57
import pl.allegro.tech.build.axion.release.domain.TagNameSerializationConfig
68
import pl.allegro.tech.build.axion.release.domain.hooks.HooksConfig
79

@@ -15,6 +17,7 @@ plugins {
1517
jacoco
1618
java
1719
kotlin("jvm") version "2.2.21" apply false
20+
id("org.springframework.boot") version "4.0.0"
1821
}
1922

2023
repositories {
@@ -66,13 +69,6 @@ allprojects {
6669

6770
subprojects {
6871

69-
val jacksonVersion by extra { "3.0.2" }
70-
val jackson2Version by extra { "2.20.1" }
71-
val jacksonAnnotationsVersion by extra { "2.20" }
72-
val springBootVersion by extra { "4.0.0-RC2" }
73-
val springRestDocsVersion by extra { "4.0.0-RC1" }
74-
val springRestDocsRestAssuredVersion by extra { "4.0.0-M3" }
75-
val junitVersion by extra { "6.0.1" }
7672
val jmustacheVersion by extra { "1.16" }
7773

7874
tasks.withType<KotlinCompile> {
@@ -154,3 +150,7 @@ sonar {
154150
property("sonar.exclusions", "**/samples/**")
155151
}
156152
}
153+
154+
tasks.withType<BootJar> {
155+
enabled = false
156+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#This file is generated by updateDaemonJvm
2+
toolchainVersion=21

restdocs-api-spec-gradle-plugin/build.gradle.kts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
2+
import kotlin.apply
3+
14
repositories {
25
mavenCentral()
36
}
@@ -9,6 +12,13 @@ plugins {
912
id("com.gradle.plugin-publish") version "0.21.0"
1013
}
1114

15+
apply(plugin = "io.spring.dependency-management")
16+
the<DependencyManagementExtension>().apply {
17+
imports {
18+
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
19+
}
20+
}
21+
1222
gradlePlugin {
1323
plugins {
1424
register("com.epages.restdocs-api-spec") {
@@ -36,9 +46,6 @@ pluginBundle {
3646
}
3747
}
3848

39-
val jacksonVersion: String by extra
40-
val junitVersion: String by extra
41-
4249
val jacocoRuntime by configurations.creating
4350

4451
dependencies {
@@ -50,14 +57,14 @@ dependencies {
5057
implementation(project(":restdocs-api-spec-openapi-generator"))
5158
implementation(project(":restdocs-api-spec-openapi3-generator"))
5259
implementation(project(":restdocs-api-spec-postman-generator"))
53-
implementation("tools.jackson.core:jackson-databind:$jacksonVersion")
54-
implementation("tools.jackson.module:jackson-module-kotlin:$jacksonVersion")
55-
implementation("tools.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
60+
implementation("tools.jackson.core:jackson-databind")
61+
implementation("tools.jackson.module:jackson-module-kotlin")
62+
implementation("tools.jackson.dataformat:jackson-dataformat-yaml")
5663

57-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
64+
testImplementation("org.junit.jupiter:junit-jupiter-engine")
5865
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
5966
testImplementation("org.junit-pioneer:junit-pioneer:2.3.0")
60-
testImplementation("org.assertj:assertj-core:3.27.6")
67+
testImplementation("org.assertj:assertj-core")
6168

6269
testImplementation("com.jayway.jsonpath:json-path:2.10.0")
6370

restdocs-api-spec-jsonschema/build.gradle.kts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
2+
import kotlin.apply
3+
14
plugins {
25
kotlin("jvm")
36
signing
@@ -7,21 +10,25 @@ repositories {
710
mavenCentral()
811
}
912

10-
val jacksonVersion: String by extra
11-
val junitVersion: String by extra
13+
apply(plugin = "io.spring.dependency-management")
14+
the<DependencyManagementExtension>().apply {
15+
imports {
16+
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
17+
}
18+
}
1219

1320
dependencies {
1421
implementation(kotlin("stdlib-jdk8"))
1522
implementation(project(":restdocs-api-spec-model"))
1623
implementation("com.github.erosb:everit-json-schema:1.11.0")
17-
implementation("tools.jackson.core:jackson-databind:$jacksonVersion")
18-
implementation("tools.jackson.module:jackson-module-kotlin:$jacksonVersion")
24+
implementation("tools.jackson.core:jackson-databind")
25+
implementation("tools.jackson.module:jackson-module-kotlin")
1926

20-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
27+
testImplementation("org.junit.jupiter:junit-jupiter-engine")
2128
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2229
testImplementation("com.github.java-json-tools:json-schema-validator:2.2.14")
2330
testImplementation("com.jayway.jsonpath:json-path:2.10.0")
24-
testImplementation("org.assertj:assertj-core:3.27.6")
31+
testImplementation("org.assertj:assertj-core")
2532
testImplementation("javax.validation:validation-api:2.0.1.Final")
2633
}
2734

restdocs-api-spec-mockmvc/build.gradle.kts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
2+
import kotlin.apply
3+
14
plugins {
25
kotlin("jvm")
36
signing
@@ -7,25 +10,28 @@ repositories {
710
mavenCentral()
811
}
912

10-
val springBootVersion: String by extra
11-
val springRestDocsVersion: String by extra
12-
val junitVersion: String by extra
13+
apply(plugin = "io.spring.dependency-management")
14+
the<DependencyManagementExtension>().apply {
15+
imports {
16+
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
17+
}
18+
}
1319

1420
dependencies {
1521
implementation(kotlin("stdlib-jdk8"))
1622

1723
api(project(":restdocs-api-spec"))
18-
implementation("org.springframework.restdocs:spring-restdocs-mockmvc:$springRestDocsVersion")
24+
implementation("org.springframework.restdocs:spring-restdocs-mockmvc")
1925

20-
testImplementation("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
21-
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test:$springBootVersion")
22-
testImplementation("org.springframework.boot:spring-boot-restdocs:$springBootVersion")
23-
testImplementation("org.springframework.boot:spring-boot-starter-validation:$springBootVersion")
24-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
26+
testImplementation("org.springframework.boot:spring-boot-starter-test")
27+
testImplementation("org.springframework.boot:spring-boot-starter-webmvc-test")
28+
testImplementation("org.springframework.boot:spring-boot-restdocs")
29+
testImplementation("org.springframework.boot:spring-boot-starter-validation")
30+
testImplementation("org.junit.jupiter:junit-jupiter-engine")
2531
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
2632
testImplementation("org.junit-pioneer:junit-pioneer:2.3.0")
2733
testImplementation(testFixtures(project(":restdocs-api-spec")))
28-
testImplementation("org.springframework.boot:spring-boot-starter-hateoas:$springBootVersion")
34+
testImplementation("org.springframework.boot:spring-boot-starter-hateoas")
2935
}
3036

3137
publishing {

restdocs-api-spec-model/build.gradle.kts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
val jacksonVersion: String by extra
2-
val jacksonAnnotationsVersion: String by extra
1+
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
2+
import kotlin.apply
33

44
plugins {
55
kotlin("jvm")
@@ -10,9 +10,16 @@ repositories {
1010
mavenCentral()
1111
}
1212

13+
apply(plugin = "io.spring.dependency-management")
14+
the<DependencyManagementExtension>().apply {
15+
imports {
16+
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
17+
}
18+
}
19+
1320
dependencies {
1421
implementation(kotlin("stdlib-jdk8"))
15-
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonAnnotationsVersion")
22+
implementation("com.fasterxml.jackson.core:jackson-annotations")
1623
}
1724

1825
publishing {

restdocs-api-spec-openapi-generator/build.gradle.kts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
2+
import kotlin.apply
3+
14
plugins {
25
kotlin("jvm")
36
signing
@@ -7,25 +10,28 @@ repositories {
710
mavenCentral()
811
}
912

10-
val junitVersion: String by extra
11-
val jacksonVersion: String by extra
12-
val springBootVersion: String by extra
13+
apply(plugin = "io.spring.dependency-management")
14+
the<DependencyManagementExtension>().apply {
15+
imports {
16+
mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
17+
}
18+
}
1319

1420
dependencies {
1521
implementation(kotlin("stdlib-jdk8"))
1622

1723
api(project(":restdocs-api-spec-model"))
1824
api(project(":restdocs-api-spec-jsonschema"))
1925
api("io.swagger:swagger-core:1.6.16")
20-
implementation("org.springframework.boot:spring-boot-jackson2:$springBootVersion")
21-
implementation("tools.jackson.core:jackson-databind:$jacksonVersion")
22-
implementation("tools.jackson.module:jackson-module-kotlin:$jacksonVersion")
23-
implementation("tools.jackson.dataformat:jackson-dataformat-yaml:$jacksonVersion")
26+
implementation("org.springframework.boot:spring-boot-jackson2")
27+
implementation("tools.jackson.core:jackson-databind")
28+
implementation("tools.jackson.module:jackson-module-kotlin")
29+
implementation("tools.jackson.dataformat:jackson-dataformat-yaml")
2430

2531
testImplementation("io.swagger:swagger-parser:1.0.75")
26-
testImplementation("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
32+
testImplementation("org.junit.jupiter:junit-jupiter-engine")
2733
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
28-
testImplementation("org.assertj:assertj-core:3.27.6")
34+
testImplementation("org.assertj:assertj-core")
2935
}
3036

3137
publishing {

0 commit comments

Comments
 (0)