Polish
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -33,7 +33,8 @@ public class ContractDslSnippet extends TemplatedSnippet {
|
||||
private static final String SNIPPET_NAME = "dsl-contract";
|
||||
|
||||
private Map<String, Object> model = new HashMap<>();
|
||||
private Set<String> bannedHeaders = new HashSet<>(Arrays.asList(HttpHeaders.HOST, HttpHeaders.CONTENT_LENGTH));
|
||||
private static final Set<String> 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<String, String> headers) {
|
||||
for (String header : this.bannedHeaders) {
|
||||
for (String header : IGNORED_HEADERS) {
|
||||
if (headers.containsKey(header)) {
|
||||
headers.remove(header);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user