Updated Stubbing and Request Matching (markdown)

Stef Heyenrath
2018-06-26 17:34:44 +02:00
parent f5faab808d
commit 8c6c254130

@@ -52,22 +52,22 @@ WireMock supports matching of requests to stubs and verification queries using t
* Request Body
### JSON (JsonMatcher)
Checks if a JSON object is DeepEqual.
Checks if a JSON object (or JSON as string) is DeepEqual.
#### C#
#### C# option 1
```csharp
var server = FluentMockServer.Start();
server
.Given(Request
.Create()
.WithPath("/jsonmatcher")
.WithPath("/jsonmatcher1")
.WithBody(new JsonMatcher("{ \"x\": 42, \"s\": \"s\" }"))
.UsingPost())
.WithGuid("debaf408-3b23-4c04-9d18-ef1c020e79f2")
.RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonbodytest"" }"));
.RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonbodytest1"" }"));
```
#### JSON Mapping
#### JSON Mapping option 1
``` js
{
"Guid": "debaf408-3b23-4c04-9d18-ef1c020e79f2",
@@ -99,6 +99,51 @@ server
}
```
#### C# option 2
```csharp
var server = FluentMockServer.Start();
server
.Given(Request
.Create()
.WithPath("/jsonmatcher2")
.WithBody(new JsonMatcher({ x = 42, s = "s" }))
.UsingPost())
.WithGuid("debaf408-3b23-4c04-9d18-ef1c020e79f2")
.RespondWith(Response.Create().WithBody(@"{ ""result"": ""jsonbodytest2"" }"));
```
#### JSON Mapping option 2
``` js
{
"Guid": "debaf408-3b23-4c04-9d18-ef1c020e79f2",
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/jsonbodytest2",
"IgnoreCase": false
}
]
},
"Methods": [
"post"
],
"Body": {
"Matcher": {
"Name": "JsonMatcher",
"Pattern": { "x": 42, "s": "s" }
}
}
},
"Response": {
"StatusCode": 200,
"Body": "{ \"result\": \"jsonbodytest2\" }",
"UseTransformer": false
}
}
```
```
// matching
{ "x": 1, "s": "s" }