From ff0b19e9daadada33142dc1c137d8574b41e1c56 Mon Sep 17 00:00:00 2001 From: buildmaster Date: Tue, 5 Nov 2019 13:28:05 +0000 Subject: [PATCH] Sync docs from 2.1.x to gh-pages --- .../multi__spring_cloud_contract_wiremock.html | 11 +++++------ 2.1.x/multi/multi_contract-dsl.html | 2 +- 2.1.x/single/spring-cloud-contract.html | 13 ++++++------- 2.1.x/spring-cloud-contract.xml | 13 ++++++------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/2.1.x/multi/multi__spring_cloud_contract_wiremock.html b/2.1.x/multi/multi__spring_cloud_contract_wiremock.html index 242c6baaf7..ff90283f6c 100644 --- a/2.1.x/multi/multi__spring_cloud_contract_wiremock.html +++ b/2.1.x/multi/multi__spring_cloud_contract_wiremock.html @@ -227,8 +227,8 @@ public class ApplicationTests { mockMvc.perform(post("/resource") .content("{\"id\":\"123456\",\"message\":\"Hello World\"}")) .andExpect(status().isOk()) - .andDo(verify().jsonPath("$.id") - .stub("resource")); + .andDo(verify().jsonPath("$.id")) + .andDo(document("resource")); } }

This contract specifies that any valid POST with an "id" field receives the response defined in this test. You can chain together calls to .jsonPath() to add additional @@ -244,8 +244,8 @@ following example:

"/resource"))
-						.withRequestBody(matchingJsonPath("$.id"))
-                       .stub("post-resource"));
+						.withRequestBody(matchingJsonPath("$.id")))
+                       .andDo(document("post-resource"));
 }

The WireMock API is rich. You can match headers, query parameters, and request body by regex as well as by JSON path. These features can be used to create stubs with a wider range of parameters. The above example generates a stub resembling the following example:

post-resource.json.  @@ -288,8 +288,7 @@ is there because it makes sense to generate both the contracts and the stubs.

// first WireMock .andDo(WireMockRestDocs.verify().jsonPath("$[?(@.foo >= 20)]") .jsonPath("$[?(@.bar in ['baz','bazz','bazzz'])]") - .contentType(MediaType.valueOf("application/json")) - .stub("shouldGrantABeerIfOldEnough")) + .contentType(MediaType.valueOf("application/json"))) // then Contract DSL documentation .andDo(document("index", SpringCloudContractRestDocs.dslContract()));

The preceding test creates the stub presented in the previous section, generating both the contract and a documentation file.

The contract is called index.groovy and might look like the following example:

import org.springframework.cloud.contract.spec.Contract
diff --git a/2.1.x/multi/multi_contract-dsl.html b/2.1.x/multi/multi_contract-dsl.html
index 9146cf9583..20e1212201 100644
--- a/2.1.x/multi/multi_contract-dsl.html
+++ b/2.1.x/multi/multi_contract-dsl.html
@@ -1605,7 +1605,7 @@ the method name and passed the proper JSON path as a parameter to it.

}, "response" : { "status" : 200, - "body" : "{\\"date\\":\\"2017-01-01\\",\\"dateTime\\":\\"2017-01-01T01:23:45\\",\\"aBoolean\\":true,\\"valueWithMax\\":[1,2,3],\\"valueWithOccurrence\\":[1,2,3,4],\\"number\\":123,\\"duck\\":123,\\"alpha\\":\\"abc\\",\\"valueWithMin\\":[1,2,3],\\"time\\":\\"01:02:34\\",\\"valueWithTypeMatch\\":\\"string\\",\\"valueWithMinMax\\":[1,2,3],\\"valueWithoutAMatcher\\":\\"foo\\"}", + "body" : "{\\"duck\\":123,\\"alpha\\":\\"abc\\",\\"number\\":123,\\"aBoolean\\":true,\\"date\\":\\"2017-01-01\\",\\"dateTime\\":\\"2017-01-01T01:23:45\\",\\"time\\":\\"01:02:34\\",\\"valueWithoutAMatcher\\":\\"foo\\",\\"valueWithTypeMatch\\":\\"string\\",\\"valueWithMin\\":[1,2,3],\\"valueWithMax\\":[1,2,3],\\"valueWithMinMax\\":[1,2,3],\\"valueWithOccurrence\\":[1,2,3,4]}", "headers" : { "Content-Type" : "application/json" }, diff --git a/2.1.x/single/spring-cloud-contract.html b/2.1.x/single/spring-cloud-contract.html index 6a0dd62a75..5ca109cbd1 100644 --- a/2.1.x/single/spring-cloud-contract.html +++ b/2.1.x/single/spring-cloud-contract.html @@ -5424,7 +5424,7 @@ the method name and passed the proper JSON path as a parameter to it.

}, "response" : { "status" : 200, - "body" : "{\\"date\\":\\"2017-01-01\\",\\"dateTime\\":\\"2017-01-01T01:23:45\\",\\"aBoolean\\":true,\\"valueWithMax\\":[1,2,3],\\"valueWithOccurrence\\":[1,2,3,4],\\"number\\":123,\\"duck\\":123,\\"alpha\\":\\"abc\\",\\"valueWithMin\\":[1,2,3],\\"time\\":\\"01:02:34\\",\\"valueWithTypeMatch\\":\\"string\\",\\"valueWithMinMax\\":[1,2,3],\\"valueWithoutAMatcher\\":\\"foo\\"}", + "body" : "{\\"duck\\":123,\\"alpha\\":\\"abc\\",\\"number\\":123,\\"aBoolean\\":true,\\"date\\":\\"2017-01-01\\",\\"dateTime\\":\\"2017-01-01T01:23:45\\",\\"time\\":\\"01:02:34\\",\\"valueWithoutAMatcher\\":\\"foo\\",\\"valueWithTypeMatch\\":\\"string\\",\\"valueWithMin\\":[1,2,3],\\"valueWithMax\\":[1,2,3],\\"valueWithMinMax\\":[1,2,3],\\"valueWithOccurrence\\":[1,2,3,4]}", "headers" : { "Content-Type" : "application/json" }, @@ -6933,8 +6933,8 @@ public class ApplicationTests { mockMvc.perform(post("/resource") .content("{\"id\":\"123456\",\"message\":\"Hello World\"}")) .andExpect(status().isOk()) - .andDo(verify().jsonPath("$.id") - .stub("resource")); + .andDo(verify().jsonPath("$.id")) + .andDo(document("resource")); } }

This contract specifies that any valid POST with an "id" field receives the response defined in this test. You can chain together calls to .jsonPath() to add additional @@ -6950,8 +6950,8 @@ following example:

"/resource"))
-						.withRequestBody(matchingJsonPath("$.id"))
-                       .stub("post-resource"));
+						.withRequestBody(matchingJsonPath("$.id")))
+                       .andDo(document("post-resource"));
 }

The WireMock API is rich. You can match headers, query parameters, and request body by regex as well as by JSON path. These features can be used to create stubs with a wider range of parameters. The above example generates a stub resembling the following example:

post-resource.json.  @@ -6994,8 +6994,7 @@ is there because it makes sense to generate both the contracts and the stubs.

// first WireMock .andDo(WireMockRestDocs.verify().jsonPath("$[?(@.foo >= 20)]") .jsonPath("$[?(@.bar in ['baz','bazz','bazzz'])]") - .contentType(MediaType.valueOf("application/json")) - .stub("shouldGrantABeerIfOldEnough")) + .contentType(MediaType.valueOf("application/json"))) // then Contract DSL documentation .andDo(document("index", SpringCloudContractRestDocs.dslContract()));

The preceding test creates the stub presented in the previous section, generating both the contract and a documentation file.

The contract is called index.groovy and might look like the following example:

import org.springframework.cloud.contract.spec.Contract
diff --git a/2.1.x/spring-cloud-contract.xml b/2.1.x/spring-cloud-contract.xml
index 08f20844ef..4b7fe3a24e 100644
--- a/2.1.x/spring-cloud-contract.xml
+++ b/2.1.x/spring-cloud-contract.xml
@@ -8697,7 +8697,7 @@ the method name and passed the proper JSON path as a parameter to it.
   },
   "response" : {
     "status" : 200,
-    "body" : "{\\"date\\":\\"2017-01-01\\",\\"dateTime\\":\\"2017-01-01T01:23:45\\",\\"aBoolean\\":true,\\"valueWithMax\\":[1,2,3],\\"valueWithOccurrence\\":[1,2,3,4],\\"number\\":123,\\"duck\\":123,\\"alpha\\":\\"abc\\",\\"valueWithMin\\":[1,2,3],\\"time\\":\\"01:02:34\\",\\"valueWithTypeMatch\\":\\"string\\",\\"valueWithMinMax\\":[1,2,3],\\"valueWithoutAMatcher\\":\\"foo\\"}",
+    "body" : "{\\"duck\\":123,\\"alpha\\":\\"abc\\",\\"number\\":123,\\"aBoolean\\":true,\\"date\\":\\"2017-01-01\\",\\"dateTime\\":\\"2017-01-01T01:23:45\\",\\"time\\":\\"01:02:34\\",\\"valueWithoutAMatcher\\":\\"foo\\",\\"valueWithTypeMatch\\":\\"string\\",\\"valueWithMin\\":[1,2,3],\\"valueWithMax\\":[1,2,3],\\"valueWithMinMax\\":[1,2,3],\\"valueWithOccurrence\\":[1,2,3,4]}",
     "headers" : {
       "Content-Type" : "application/json"
     },
@@ -10755,8 +10755,8 @@ public class ApplicationTests {
 		mockMvc.perform(post("/resource")
                 .content("{\"id\":\"123456\",\"message\":\"Hello World\"}"))
 				.andExpect(status().isOk())
-				.andDo(verify().jsonPath("$.id")
-                        .stub("resource"));
+				.andDo(verify().jsonPath("$.id"))
+                .andDo(document("resource"));
 	}
 }
 This contract specifies that any valid POST with an "id" field receives the response
@@ -10775,8 +10775,8 @@ public void contextLoads() throws Exception {
 			.andDo(verify()
 					.wiremock(WireMock.post(
 						urlPathEquals("/resource"))
-						.withRequestBody(matchingJsonPath("$.id"))
-                       .stub("post-resource"));
+						.withRequestBody(matchingJsonPath("$.id")))
+                       .andDo(document("post-resource"));
 }
 The WireMock API is rich. You can match headers, query parameters, and request body by
 regex as well as by JSON path. These features can be used to create stubs with a wider
@@ -10838,8 +10838,7 @@ is there because it makes sense to generate both the contracts and the stubs.
 The preceding test creates the stub presented in the previous section, generating both