mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-25 01:38:27 +02:00
Add Grpc ProtoBuf support (request-response) (#1047)
* ProtoBuf
* .
* x
* ---
* x
* fx
* ...
* sc
* ...
* .
* groen
* x
* fix tests
* ok!?
* fix tests
* fix tests
* !
* x
* 6
* .
* x
* ivaluematcher
* transformer
* .
* sc
* .
* mapping
* x
* tra
* com
* ...
* .
* .
* .
* AddProtoDefinition
* .
* set
* grpahj
* .
* .
* IdOrText
* ...
* async
* async2
* .
* t
* nuget
* <PackageReference Include="ProtoBufJsonConverter" Version="0.2.0-preview-04" />
* http version
* tests
* .WithHttpVersion("2")
* <PackageReference Include="ProtoBufJsonConverter" Version="0.2.0" />
* HttpVersionParser
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Stef.Validation;
|
||||
@@ -10,12 +9,12 @@ namespace WireMock.Matchers;
|
||||
/// <summary>
|
||||
/// JsonMatcher
|
||||
/// </summary>
|
||||
public class JsonMatcher : IValueMatcher, IIgnoreCaseMatcher
|
||||
public class JsonMatcher : IJsonMatcher
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public virtual string Name => "JsonMatcher";
|
||||
public virtual string Name => nameof(JsonMatcher);
|
||||
|
||||
/// <inheritdoc cref="IValueMatcher.Value"/>
|
||||
/// <inheritdoc />
|
||||
public object Value { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -59,7 +58,7 @@ public class JsonMatcher : IValueMatcher, IIgnoreCaseMatcher
|
||||
IgnoreCase = ignoreCase;
|
||||
|
||||
Value = value;
|
||||
_valueAsJToken = ConvertValueToJToken(value);
|
||||
_valueAsJToken = JsonUtils.ConvertValueToJToken(value);
|
||||
_jTokenConverter = ignoreCase ? Rename : jToken => jToken;
|
||||
}
|
||||
|
||||
@@ -74,7 +73,7 @@ public class JsonMatcher : IValueMatcher, IIgnoreCaseMatcher
|
||||
{
|
||||
try
|
||||
{
|
||||
var inputAsJToken = ConvertValueToJToken(input);
|
||||
var inputAsJToken = JsonUtils.ConvertValueToJToken(input);
|
||||
|
||||
var match = IsMatch(_jTokenConverter(_valueAsJToken), _jTokenConverter(inputAsJToken));
|
||||
score = MatchScores.ToScore(match);
|
||||
@@ -99,25 +98,6 @@ public class JsonMatcher : IValueMatcher, IIgnoreCaseMatcher
|
||||
return JToken.DeepEquals(value, input);
|
||||
}
|
||||
|
||||
private static JToken ConvertValueToJToken(object value)
|
||||
{
|
||||
// Check if JToken, string, IEnumerable or object
|
||||
switch (value)
|
||||
{
|
||||
case JToken tokenValue:
|
||||
return tokenValue;
|
||||
|
||||
case string stringValue:
|
||||
return JsonUtils.Parse(stringValue);
|
||||
|
||||
case IEnumerable enumerableValue:
|
||||
return JArray.FromObject(enumerableValue);
|
||||
|
||||
default:
|
||||
return JObject.FromObject(value);
|
||||
}
|
||||
}
|
||||
|
||||
private static string? ToUpper(string? input)
|
||||
{
|
||||
return input?.ToUpperInvariant();
|
||||
|
||||
Reference in New Issue
Block a user