Skip to content

Commit b508d77

Browse files
committed
Merge branch '2.4.x' into 2.5.x
Closes gh-27803
2 parents ca655b6 + a8652a8 commit b508d77

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/testing.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,14 @@ If you require more control over Spring REST Docs configuration than offered by
748748
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java[]
749749
----
750750

751+
If you want to make use of Spring REST Docs support for a parameterized output directory, you can use a `WebTestClientBuilderCustomizer` to configure a consumer for every entity exchange result.
752+
The following example shows such a `WebTestClientBuilderCustomizer` being defined:
753+
754+
[source,java,indent=0]
755+
----
756+
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyWebTestClientBuilderCustomizerConfiguration.java[]
757+
----
758+
751759

752760

753761
[[features.testing.spring-boot-applications.autoconfigured-spring-restdocs.with-rest-assured]]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient;
18+
19+
import org.springframework.boot.test.context.TestConfiguration;
20+
import org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer;
21+
import org.springframework.context.annotation.Bean;
22+
23+
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
24+
25+
@TestConfiguration(proxyBeanMethods = false)
26+
public class MyWebTestClientBuilderCustomizerConfiguration {
27+
28+
@Bean
29+
public WebTestClientBuilderCustomizer restDocumentation() {
30+
return (builder) -> builder.entityExchangeResultConsumer(document("{method-name}"));
31+
}
32+
33+
}

0 commit comments

Comments
 (0)