Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit c039c99

Browse files
authored
Document generation of WireMock stubs (#308)
* Document generation of WireMock stubs * Reset generated documentation
1 parent 0b0b336 commit c039c99

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

spring-auto-restdocs-docs/index.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@ include::constraints.adoc[]
8484

8585
include::other.adoc[]
8686

87+
include::integrations.adoc[]
88+
8789
include::contributing.adoc[]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[[integrations]]
2+
== Integrations
3+
4+
[[integrations-wiremock]]
5+
=== WireMock
6+
7+
WireMock stubs can be generated with Spring REST Docs,
8+
see https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/2.1.0.RELEASE/multi/multi__spring_cloud_contract_wiremock.html#_generating_stubs_using_rest_docs[Generating Stubs using REST Docs].
9+
This also works with Spring Auto REST Docs.
10+
However, the corresponding snippet does not register automatically
11+
and thus has to be registered manually.
12+
13+
The following code shows how the `new WireMockSnippet()` can be registered.
14+
15+
[source,java]
16+
.WireMock snippet registration example
17+
----
18+
public void setUp() {
19+
this.mockMvc = MockMvcBuilders
20+
.webAppContextSetup(context)
21+
.alwaysDo(prepareJackson(objectMapper))
22+
.alwaysDo(document("{class-name}/{method-name}",
23+
preprocessRequest(), commonResponsePreprocessor()))
24+
.apply(documentationConfiguration(restDocumentation)
25+
.uris()
26+
.and().snippets()
27+
.withDefaults(curlRequest(), httpRequest(), httpResponse(),
28+
requestFields(), responseFields(), pathParameters(),
29+
requestParameters(), description(), methodAndPath(),
30+
section(), new WireMockSnippet()))
31+
.build();
32+
}
33+
----

0 commit comments

Comments
 (0)