mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 02:38:54 +02:00
Create WireMock.Net.ProtoBuf project (#1350)
* Create WireMock.Net.ProtoBuf project * ok * Update Directory.Build.props Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -241,13 +241,13 @@ public partial class WireMockServer
|
||||
if (requestModel.Body?.Matcher != null)
|
||||
{
|
||||
var bodyMatcher = _matcherMapper.Map(requestModel.Body.Matcher)!;
|
||||
#if PROTOBUF
|
||||
|
||||
// If the BodyMatcher is a ProtoBufMatcher, and if ProtoDefinition is defined on Mapping-level, set the ProtoDefinition from that Mapping.
|
||||
if (bodyMatcher is ProtoBufMatcher protoBufMatcher && mappingModel?.ProtoDefinition != null)
|
||||
if (bodyMatcher is IProtoBufMatcher protoBufMatcher && mappingModel?.ProtoDefinition != null)
|
||||
{
|
||||
protoBufMatcher.ProtoDefinition = () => ProtoDefinitionHelper.GetIdOrTexts(_settings, mappingModel.ProtoDefinition);
|
||||
protoBufMatcher.ProtoDefinition = () => ProtoDefinitionUtils.GetIdOrTexts(_settings, mappingModel.ProtoDefinition);
|
||||
}
|
||||
#endif
|
||||
|
||||
requestBuilder = requestBuilder.WithBody(bodyMatcher);
|
||||
}
|
||||
else if (requestModel.Body?.Matchers != null)
|
||||
@@ -368,18 +368,19 @@ public partial class WireMockServer
|
||||
{
|
||||
if (responseModel.ProtoBufMessageType != null)
|
||||
{
|
||||
var protoBufUtils = TypeLoader.LoadStaticInstance<IProtoBufUtils>();
|
||||
|
||||
if (responseModel.ProtoDefinition != null)
|
||||
{
|
||||
responseBuilder = responseBuilder.WithBodyAsProtoBuf(responseModel.ProtoDefinition, responseModel.ProtoBufMessageType, responseModel.BodyAsJson);
|
||||
responseBuilder = protoBufUtils.UpdateResponseBuilder(responseBuilder, responseModel.ProtoBufMessageType, responseModel.BodyAsJson, responseModel.ProtoDefinition);
|
||||
}
|
||||
else if (responseModel.ProtoDefinitions != null)
|
||||
{
|
||||
responseBuilder = responseBuilder.WithBodyAsProtoBuf(responseModel.ProtoDefinitions, responseModel.ProtoBufMessageType, responseModel.BodyAsJson);
|
||||
responseBuilder = protoBufUtils.UpdateResponseBuilder(responseBuilder, responseModel.ProtoBufMessageType, responseModel.BodyAsJson, responseModel.ProtoDefinitions);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ProtoDefinition(s) is/are defined at Mapping/Server level
|
||||
responseBuilder = responseBuilder.WithBodyAsProtoBuf(responseModel.ProtoBufMessageType, responseModel.BodyAsJson);
|
||||
responseBuilder = protoBufUtils.UpdateResponseBuilder(responseBuilder, responseModel.ProtoBufMessageType, responseModel.BodyAsJson);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user