From 1e45f3b46a5cd4d0b86e0a11c5d949471c53622c Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 27 Jul 2016 09:57:05 +0100 Subject: [PATCH] Add JSON stub example to wiremock restdocs section --- .../main/asciidoc/spring-cloud-wiremock.adoc | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/spring-cloud-wiremock.adoc b/docs/src/main/asciidoc/spring-cloud-wiremock.adoc index 6c17813ec1..8cf85abaf8 100644 --- a/docs/src/main/asciidoc/spring-cloud-wiremock.adoc +++ b/docs/src/main/asciidoc/spring-cloud-wiremock.adoc @@ -184,7 +184,30 @@ created stub. Example: The WireMock API is rich - you can match headers, query parameters, and request body by regex as well as by json path - so this can useful -to create stubs with a wider range of parameters. +to create stubs with a wider range of parameters. The above example +will generate a stub something like this: + +.post-resource.json +[source,json] +---- +{ + "request" : { + "url" : "/resource", + "method" : "PUT", + "bodyPatterns" : [ { + "matchesJsonPath" : "$.id" + }] + }, + "response" : { + "status" : 200, + "body" : "Hello World", + "headers" : { + "X-Application-Context" : "application:-1", + "Content-Type" : "text/plain" + } + } +} +---- NOTE: You can use either the `wiremock()` method or the `jsonPath()` and `contentType()` methods to create request matchers, but not both.