WireMock.Net
WireMock.Net copied to clipboard
When using C# code generation WithBody() matcher is not generated for POST Request
Describe the bug
When you generate C# code using MappingConverterType=Builder the created code doesn't contains .WithBody for the request.
Expected behavior:
A clear and concise description of what you expected to happen.
Test to reproduce
- 1 Record a POST request with a JSON body
- 2 In
__admin\mappingsObserver the JSON file generated has a Body Matcher defined
"Request": {
"Path": {
"Matchers": [
{
"Name": "WildcardMatcher",
"Pattern": "/rest/v4/users",
"IgnoreCase": false
}
]
},
"Methods": [
"POST"
],
"Body": {
"Matcher": {
"Name": "JsonMatcher",
"Pattern": {
"addressLine1": "123 Main Street",
"city": "New York",
"clientUserId": "integration-test-user-1",
"country": "US",
"dateOfBirth": "1980-01-01",
"email": "[email protected]",
"firstName": "Alex",
"lastName": "Test",
"postalCode": "10016",
"profileType": "BUSINESS",
"businessName": "Integration Test 1",
"programToken": "prg-3f63490c-e249-46e7-97f5-31c725d51f3a",
"stateProvince": "NY"
},
"IgnoreCase": true,
"Regex": false
}
}
},
- 3 Make a GET request to
http://localhost:9095/__admin/mappings/code?MappingConverterType=Builder - 4 Observe C# code doesn't have Body match on Request
builder
.Given(Request.Create()
.UsingMethod("POST")
.WithPath("/rest/v4/users")
.WithHeader("Accept", "*/*", true)
.WithHeader("Connection", "keep-alive", true)
.WithHeader("User-Agent", "PostmanRuntime/7.37.3", true)
.WithHeader("Accept-Encoding", "gzip, deflate, br", true)
.WithHeader("Content-Type", "application/json", true)
.WithHeader("Content-Length", "443", true)
.WithHttpVersion("1.1")
)
.WithGuid("66cb85f5-6a2c-4f67-b685-3fcb9275e17a");
Thanks for the detailed description, I'll take look.
https://github.com/WireMock-Net/WireMock.Net/pull/1101
Solved