public final class WireMockRestDocs extends Object
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureRestDocs(outputDir = "target/snippets")
@AutoConfigureMockMvc
public class WiremockServerRestDocsApplicationTests {
@Autowired
private MockMvc mockMvc;
@Test
public void contextLoads() throws Exception {
mockMvc.perform(get("/resource"))
.andExpect(content().string("Hello World"))
.andDo(verify())
.andDo(document("resource"));
}
which creates a file "target/snippets/stubs/resource.json" matching any GET
request to "/resource". To match POST and PUT, you can also specify the content type
using verify().contentType(...) and JSON content of the body using
verify().jsonPath(...).public static ContractResultHandler verify()
Copyright © 2016–2022 Spring. All rights reserved.