mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-18 14:39:45 +02:00
Use latest ProtoBufJsonConverter to support WellKnownTypes (#1161)
* Use latest ProtoBufJsonConverter to support WellKnownTypes * Fix * 02 * WireMockServer_WithBodyAsProtoBuf_WithWellKnownTypes * . * extra test * 0.4.0-preview-06 * 7 * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0-preview-08" /> * Update README.md * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0-preview-09" /> * <PackageReference Include="ProtoBufJsonConverter" Version="0.4.0" /> * Update README.md
This commit is contained in:
@@ -242,7 +242,7 @@ public interface IRespondWithAProvider
|
||||
/// </summary>
|
||||
/// <param name="protoDefinitionOrId">The proto definition as text or as id.</param>
|
||||
/// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
|
||||
IRespondWithAProvider WithProtoDefinition(string protoDefinitionOrId);
|
||||
IRespondWithAProvider WithProtoDefinition(params string[] protoDefinitionOrId);
|
||||
|
||||
/// <summary>
|
||||
/// Define a GraphQL Schema which is used for the request and the response.
|
||||
|
||||
@@ -37,7 +37,7 @@ internal class RespondWithAProvider : IRespondWithAProvider
|
||||
private int _timesInSameState = 1;
|
||||
private bool? _useWebhookFireAndForget;
|
||||
private double? _probability;
|
||||
private IdOrText? _protoDefinition;
|
||||
private IdOrTexts? _protoDefinition;
|
||||
private GraphQLSchemaDetails? _graphQLSchemaDetails;
|
||||
|
||||
public Guid Guid { get; private set; }
|
||||
@@ -351,18 +351,27 @@ internal class RespondWithAProvider : IRespondWithAProvider
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRespondWithAProvider WithProtoDefinition(string protoDefinitionOrId)
|
||||
public IRespondWithAProvider WithProtoDefinition(params string[] protoDefinitionOrId)
|
||||
{
|
||||
Guard.NotNullOrWhiteSpace(protoDefinitionOrId);
|
||||
Guard.NotNull(protoDefinitionOrId);
|
||||
|
||||
if (_settings.ProtoDefinitions?.TryGetValue(protoDefinitionOrId, out var protoDefinition) == true)
|
||||
if (protoDefinitionOrId.Length == 1)
|
||||
{
|
||||
_protoDefinition = new (protoDefinitionOrId, protoDefinition);
|
||||
var idOrText = protoDefinitionOrId[0];
|
||||
if (_settings.ProtoDefinitions?.TryGetValue(idOrText, out var protoDefinitions) == true)
|
||||
{
|
||||
_protoDefinition = new(idOrText, protoDefinitions);
|
||||
}
|
||||
else
|
||||
{
|
||||
_protoDefinition = new(null, protoDefinitionOrId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_protoDefinition = new(null, protoDefinitionOrId);
|
||||
}
|
||||
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -595,12 +595,12 @@ public partial class WireMockServer : IWireMockServer
|
||||
/// <param name="protoDefinition">The ProtoDefinition as text.</param>
|
||||
/// <returns><see cref="WireMockServer"/></returns>
|
||||
[PublicAPI]
|
||||
public WireMockServer AddProtoDefinition(string id, string protoDefinition)
|
||||
public WireMockServer AddProtoDefinition(string id, params string[] protoDefinition)
|
||||
{
|
||||
Guard.NotNullOrWhiteSpace(id);
|
||||
Guard.NotNullOrWhiteSpace(protoDefinition);
|
||||
Guard.NotNullOrEmpty(protoDefinition);
|
||||
|
||||
_settings.ProtoDefinitions ??= new Dictionary<string, string>();
|
||||
_settings.ProtoDefinitions ??= new Dictionary<string, string[]>();
|
||||
|
||||
_settings.ProtoDefinitions[id] = protoDefinition;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user