mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
[PR #155] [CLOSED] Replace JsonMatcher with JsonObjectMatcher and directly support JSON body matching. #779
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/wiremock/WireMock.Net/pull/155
Author: @DavidKorn
Created: 6/26/2018
Status: ❌ Closed
Base:
master← Head:dk_154_request_bodyasjson📝 Commits (1)
a6910c5Replace the just added JsonMatcher with JsonObjectMatcher, which uses value equality via JSON serialization to support JSON object matches in request bodies. Update the proxy recorder to use JsonObjectMatcher to record the mapping for a Request with a BodyAsJson. #154📊 Changes
9 files changed (+144 additions, -122 deletions)
View changed files
📝
examples/WireMock.Net.ConsoleApplication/MainApp.cs(+1 -1)📝
src/WireMock.Net/Admin/Mappings/MatcherModel.cs(+2 -2)📝
src/WireMock.Net/Matchers/IValueMatcher.cs(+1 -1)📝
src/WireMock.Net/Matchers/JsonObjectMatcher.cs(+14 -11)📝
src/WireMock.Net/Serialization/MatcherMapper.cs(+6 -5)📝
src/WireMock.Net/Server/FluentMockServer.Admin.cs(+6 -2)➖
test/WireMock.Net.Tests/Matchers/JsonMatcherTests.cs(+0 -100)➕
test/WireMock.Net.Tests/Matchers/JsonObjectMatcherTests.cs(+91 -0)📝
test/WireMock.Net.Tests/RequestMatchers/RequestMessageBodyMatcherTests.cs(+23 -0)📄 Description
JsonObjectMatcher uses value equality via JSON serialization to support JSON object matches in request bodies. This allows static mapping files to code JSON bodies as indented JSON syntax directly in the mapping file. For our use, that's much easier to work with than an escaped string.
Also update the proxy recorder to use JsonObjectMatcher to record the mapping for a Request with a BodyAsJson.
Note: I didn't initially intend to remove the just added JsonMatcher, and I apologize if that offends. I was trying to figure out how to work alongside it and support a JsonObjectMatcher, and things got a bit messy for me around the IValueMatcher interface. In the end, with this JsonObjectMatcher class in place, and the existing IStringMatchers already available, the JsonMatcher seemed to me to be mostly redundant. So I didn't work to re-include it, but I'll be glad to try to do so if you prefer.
#154
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.