Polish "Document how to parameterize REST Docs' output dir with WebTestClient"

See gh-27755
pull/28061/head
Andy Wilkinson 3 years ago
parent c83f6ebaa2
commit 990b766847

@ -8063,14 +8063,12 @@ If you require more control over Spring REST Docs configuration than offered by
include::{code-examples}/test/autoconfigure/restdocs/webclient/AdvancedConfigurationExample.java[tag=configuration]
----
If you want to make use of Spring REST Docs support for a parameterized output directory, you can create a `WebTestClientBuilderCustomizer` bean.
The auto-configuration calls this `WebTestClientBuilderCustomizer` in order to create the `WebTestClient` bean for the current context
with the consumer provided in the parameter of the method `entityExchangeResultConsumer`.
The following example shows a `WebTestClientBuilderCustomizer` being defined:
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.
The following example shows such a `WebTestClientBuilderCustomizer` being defined:
[source,java,indent=0,subs="verbatim"]
[source,java,indent=0]
----
include::{code-examples}/test/autoconfigure/restdocs/webclient/MyWebTestClientBuilderCustomizerConfiguration.java[]
include::{code-examples}/test/autoconfigure/restdocs/webclient/ParameterizedOutputConfigurationExample.java[tag=configuration]
----

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredspringrestdocs.withwebtestclient;
package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.web.reactive.server.WebTestClientBuilderCustomizer;
@ -22,12 +22,18 @@ import org.springframework.context.annotation.Bean;
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
@TestConfiguration(proxyBeanMethods = false)
public class MyWebTestClientBuilderCustomizerConfiguration {
class ParameterizedOutputConfigurationExample {
// tag::configuration[]
@TestConfiguration(proxyBeanMethods = false)
static class ParameterizedOutputConfiguration {
@Bean
WebTestClientBuilderCustomizer restDocumentation() {
return (builder) -> builder.entityExchangeResultConsumer(document("{method-name}"));
}
@Bean
public WebTestClientBuilderCustomizer restDocumentation() {
return (builder) -> builder.entityExchangeResultConsumer(document("{method-name}"));
}
// end::configuration[]
}
Loading…
Cancel
Save