- 
                Notifications
    You must be signed in to change notification settings 
- Fork 739
Spring REST Docs 2.0 Release Notes
        Andy Wilkinson edited this page Oct 30, 2017 
        ·
        3 revisions
      
    Spring WebFlux’s WebTestClient can now be used to document an API, for example:
@Before
public void setUp() {
this.webTestClient = WebTestClient.bindToApplicationContext(context)
    .configureClient().baseUrl("https://api.example.com")
    .filter(documentationConfiguration(restDocumentation))
    .build();
}
@Test
public void sample() throws Exception {
    this.webTestClient.get().uri("/").exchange()
        .expectStatus().isOk().expectBody()
        .consumeWith(document("sample"));
}Please refer to the sample and reference documentation for more details.
A JUnit 5 extension, RestDocumentationExtension, is provided and should be used when documenting an API using Junit 5-based tests. Please refer to the sample and reference documentation for more details.
Default request and response preprocessors can now be configured when setting up REST Docs, for example:
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
    .apply(documentationConfiguration(this.restDocumentation).operationPreprocessors()
        .withRequestDefaults(removeHeaders("Foo")) // (1)
        .withResponseDefaults(prettyPrint())) // (2)
    .build();Please refer to the reference documentation for more details.
Thank you to Filip Hrisafov who contributed this feature.