Skip to content

Spring REST Docs 2.0 Release Notes

Andy Wilkinson edited this page Nov 28, 2017 · 3 revisions

New and noteworthy

Support for Spring WebFlux’s WebTestClient

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.

Support for JUnit 5

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

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.

Upgrading

Spring Framework 5.0

Spring REST Docs 2.0 requires Spring Framework 5.0.2 or later.

REST Assured 3.0

Spring REST Docs' REST Assured integration now requires REST Assured 3.0 or later.

Java 8

Spring REST Docs now requires Java 8 or later.

Deprecations from Spring REST Docs 1.2

Classes and methods that were deprecated in Spring REST Docs 1.2 have been removed.