diff --git a/docs/src/main/asciidoc/spring-cloud-wiremock.adoc b/docs/src/main/asciidoc/spring-cloud-wiremock.adoc index b0e5b51e0f..a1c597984a 100644 --- a/docs/src/main/asciidoc/spring-cloud-wiremock.adoc +++ b/docs/src/main/asciidoc/spring-cloud-wiremock.adoc @@ -300,6 +300,12 @@ Another thing that can be generated with Spring RestDocs is the Spring Cloud Contract DSL file and documentation. If you combine that with Spring Cloud WireMock then you're getting both the contracts and stubs. +Why would you want to use this feature? Some people in the community asked questions +about situation in which they would like to move to DSL based contract definition +but they already have a lot of Spring MVC tests. Using this feature allows you to generate +the contract files that you can later modify and move to proper folders so that the +plugin picks them up. + TIP: You might wonder why this functionality is in the WireMock module. Come to think of it, it does make sense since it makes little sense to generate only contracts and not generate the stubs. That's why we suggest to do both. diff --git a/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippet.java b/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippet.java index 59da24a28a..16289f8b31 100644 --- a/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippet.java +++ b/spring-cloud-contract-wiremock/src/main/java/org/springframework/cloud/contract/wiremock/restdocs/ContractDslSnippet.java @@ -33,7 +33,8 @@ public class ContractDslSnippet extends TemplatedSnippet { private static final String SNIPPET_NAME = "dsl-contract"; private Map model = new HashMap<>(); - private Set bannedHeaders = new HashSet<>(Arrays.asList(HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH)); + private static final Set IGNORED_HEADERS = + new HashSet<>(Arrays.asList(HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH)); /** * Creates a new {@code ContractDslSnippet} with no additional attributes. @@ -105,7 +106,7 @@ public class ContractDslSnippet extends TemplatedSnippet { } private void filterHeaders(Map headers) { - for (String header : this.bannedHeaders) { + for (String header : IGNORED_HEADERS) { if (headers.containsKey(header)) { headers.remove(header); }