mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-12 05:20:35 +01:00
[PR #539] [MERGED] Support for partial JSON matching #958
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/539
Author: @gleb-osokin
Created: 11/16/2020
Status: ✅ Merged
Merged: 11/17/2020
Merged by: @StefH
Base:
master← Head:master📝 Commits (10+)
91e3e9csupport Json partial match with JsonPartialMatcherf7edfa0fix erroneous filenamesd3838d6add newlineb0efe08newlines fix4af601eadd JsonPartialMatcher to mapper9378d4dcurly braces for ifs1c109bdfix JToken type comparison099368emore test casesa08318brename AreEqual -> IsMatch + more test cases4a2adb9separate tests for JPath matcher values📊 Changes
5 files changed (+578 additions, -17 deletions)
View changed files
📝
src/WireMock.Net/Matchers/JsonMatcher.cs(+21 -16)➕
src/WireMock.Net/Matchers/JsonPartialMatcher.cs(+87 -0)📝
src/WireMock.Net/Serialization/MatcherMapper.cs(+4 -0)➕
test/WireMock.Net.Tests/Matchers/JsonPartialMatcherTests.cs(+385 -0)📝
test/WireMock.Net.Tests/Serialization/MatcherMapperTests.cs(+81 -1)📄 Description
Current JsonMatcher only support exact match (via JToken.DeepEquals).
This PR introduces new JsonPartialMatcher, which tolerates input properties, not existing on the Matcher value.
Example:
Matcher value {"test": "abc"} against input {"test":"abc"} is matched by both JsonMatcher and JsonPartialMatcher
Matcher value {"test":"abc"} against input {"test":"abc","other":"xyz"} is not matched by JsonMatcher, but is matched by JsonPartialMatcher
One side benefit of this PR is that JsonMatcher (and JsonPartialMatcher) are now extensible via virtual AreEqual(JToken, JToken) method.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.