Compare commits

..

6 Commits
1.5.0 ... 1.5.1

Author SHA1 Message Date
Stef Heyenrath
9b7e5908cb 1.5.1 2022-07-08 17:41:43 +02:00
Stef Heyenrath
b1032c9dcd Update WireMock.Org.Abstractions and WireMock.Org.RestClient (#765)
* Update WireMock.Org.Abstractions and WireMock.Org.RestClient

* .

* rename
2022-07-08 11:02:18 +02:00
Stef Heyenrath
4d0f96eabe Rename (WireMock.Pact.Models.V2)-Request to PactRequest and -Response to PactResponse (#767) 2022-07-08 10:32:12 +02:00
dependabot[bot]
ef12cb70cc Bump Microsoft.AspNetCore.Http (#766)
Bumps [Microsoft.AspNetCore.Http](https://github.com/aspnet/AspNetCore) from 2.1.1 to 2.1.22.
- [Release notes](https://github.com/aspnet/AspNetCore/releases)
- [Changelog](https://github.com/dotnet/aspnetcore/blob/main/docs/ReleasePlanning.md)
- [Commits](https://github.com/aspnet/AspNetCore/compare/2.1.1...v2.1.22)

---
updated-dependencies:
- dependency-name: Microsoft.AspNetCore.Http
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-08 08:34:19 +02:00
dependabot[bot]
c212d07c53 Bump Newtonsoft.Json in /examples/WireMock.Net.Client.Net472 (#763)
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.1 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.1...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-23 11:58:49 +02:00
dependabot[bot]
b9afb126cf Bump Newtonsoft.Json in /examples/WireMock.Net.WebApplication.NETCore2 (#762)
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 11.0.2 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/11.0.2...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-23 10:53:43 +02:00
52 changed files with 896 additions and 6758 deletions

View File

@@ -1,3 +1,11 @@
# 1.5.1 (08 July 2022)
- [#762](https://github.com/WireMock-Net/WireMock.Net/pull/762) - Bump Newtonsoft.Json from 11.0.2 to 13.0.1 in /examples/WireMock.Net.WebApplication.NETCore2 [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#763](https://github.com/WireMock-Net/WireMock.Net/pull/763) - Bump Newtonsoft.Json from 6.0.1 to 13.0.1 in /examples/WireMock.Net.Client.Net472 [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#765](https://github.com/WireMock-Net/WireMock.Net/pull/765) - Update WireMock.Org.Abstractions and WireMock.Org.RestClient [feature] contributed by [StefH](https://github.com/StefH)
- [#766](https://github.com/WireMock-Net/WireMock.Net/pull/766) - Bump Microsoft.AspNetCore.Http from 2.1.1 to 2.1.22 in /examples/WireMock.Net.StandAlone.Net461 [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#767](https://github.com/WireMock-Net/WireMock.Net/pull/767) - Rename (WireMock.Pact.Models.V2)-Request to PactRequest and -Response to PactResponse [feature] contributed by [StefH](https://github.com/StefH)
- [#764](https://github.com/WireMock-Net/WireMock.Net/issues/764) - Wrong mapping of method GetAdminMappingsAsync from IWireMockOrgApi [bug]
# 1.5.0 (09 June 2022)
- [#755](https://github.com/WireMock-Net/WireMock.Net/pull/755) - Add MatchOperator &quot;Or&quot;, &quot;And&quot; and &quot;Average&quot; for patterns [feature] contributed by [StefH](https://github.com/StefH)

View File

@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.5.0</VersionPrefix>
<VersionPrefix>1.5.1</VersionPrefix>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>

View File

@@ -1,6 +1,6 @@
rem https://github.com/StefH/GitHubReleaseNotes
SET version=1.5.0
SET version=1.5.1
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN%

View File

@@ -1,4 +1,9 @@
# 1.5.0 (09 June 2022)
- #755 Add MatchOperator &quot;Or&quot;, &quot;And&quot; and &quot;Average&quot; for patterns [feature]
# 1.5.1 (08 July 2022)
- #762 Bump Newtonsoft.Json from 11.0.2 to 13.0.1 in /examples/WireMock.Net.WebApplication.NETCore2 [dependencies]
- #763 Bump Newtonsoft.Json from 6.0.1 to 13.0.1 in /examples/WireMock.Net.Client.Net472 [dependencies]
- #765 Update WireMock.Org.Abstractions and WireMock.Org.RestClient [feature]
- #766 Bump Microsoft.AspNetCore.Http from 2.1.1 to 2.1.22 in /examples/WireMock.Net.StandAlone.Net461 [dependencies]
- #767 Rename (WireMock.Pact.Models.V2)-Request to PactRequest and -Response to PactResponse [feature]
- #764 Wrong mapping of method GetAdminMappingsAsync from IWireMockOrgApi [bug]
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Brutal.Dev.StrongNameSigner" version="2.7.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="RestEase" version="1.4.10" targetFramework="net472" />
<package id="WireMock.Net.Abstractions" version="1.2.0" targetFramework="net472" />
<package id="WireMock.Net.RestClient" version="1.2.0" targetFramework="net472" />

View File

@@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RestEase" Version="1.5.6" />
<PackageReference Include="RestEase" Version="1.5.7" />
</ItemGroup>
<ItemGroup>

View File

@@ -204,8 +204,8 @@
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference>
<Reference Include="RestEase, Version=1.5.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\RestEase.1.5.5\lib\net45\RestEase.dll</HintPath>
<Reference Include="RestEase, Version=1.5.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\RestEase.1.5.7\lib\net452\RestEase.dll</HintPath>
</Reference>
<Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL">
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>

View File

@@ -15,7 +15,7 @@
<package id="Microsoft.AspNetCore.Hosting" version="2.1.1" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="2.1.1" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="2.1.1" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Http" version="2.1.1" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Http" version="2.1.22" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Http.Abstractions" version="2.1.1" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Http.Extensions" version="2.1.1" targetFramework="net461" />
<package id="Microsoft.AspNetCore.Http.Features" version="2.1.1" targetFramework="net461" />
@@ -59,7 +59,7 @@
<package id="MimeKitLite" version="2.0.7" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" />
<package id="RestEase" version="1.5.5" targetFramework="net461" />
<package id="RestEase" version="1.5.7" targetFramework="net461" />
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
<package id="System.Buffers" version="4.5.0" targetFramework="net461" />
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net461" />

View File

@@ -12,7 +12,7 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0'">
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1'">

View File

@@ -35,7 +35,7 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<!-- See also https://mstack.nl/blog/20210801-source-generators -->
<PackageReference Include="FluentBuilder" Version="0.4.4">
<PackageReference Include="FluentBuilder" Version="0.4.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

View File

@@ -31,7 +31,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="RestEase" Version="1.5.6" />
<PackageReference Include="RestEase" Version="1.5.7" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,13 +1,12 @@
namespace WireMock.Pact.Models.V2
namespace WireMock.Pact.Models.V2;
public class Interaction
{
public class Interaction
{
public string Description { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string ProviderState { get; set; }
public string ProviderState { get; set; }
public Request Request { get; set; } = new Request();
public PactRequest Request { get; set; } = new PactRequest();
public Response Response { get; set; } = new Response();
}
public PactResponse Response { get; set; } = new PactResponse();
}

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
namespace WireMock.Pact.Models.V2;
public class Request
public class PactRequest
{
public IDictionary<string, string>? Headers { get; set; }

View File

@@ -2,7 +2,7 @@ using System.Collections.Generic;
namespace WireMock.Pact.Models.V2;
public class Response
public class PactResponse
{
public object? Body { get; set; }

View File

@@ -1,41 +1,40 @@
using JetBrains.Annotations;
using JetBrains.Annotations;
using System.Collections.Generic;
using WireMock.Types;
namespace WireMock.ResponseBuilders
namespace WireMock.ResponseBuilders;
/// <summary>
/// The HeadersResponseBuilder interface.
/// </summary>
public interface IHeadersResponseBuilder : IBodyResponseBuilder
{
/// <summary>
/// The HeadersResponseBuilder interface.
/// The with header.
/// </summary>
public interface IHeadersResponseBuilder : IBodyResponseBuilder
{
/// <summary>
/// The with header.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="values">The values.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeader([NotNull] string name, params string[] values);
/// <param name="name">The name.</param>
/// <param name="values">The values.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeader(string name, params string[] values);
/// <summary>
/// The with headers.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders([NotNull] IDictionary<string, string> headers);
/// <summary>
/// The with headers.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders(IDictionary<string, string> headers);
/// <summary>
/// The with headers.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders([NotNull] IDictionary<string, string[]> headers);
/// <summary>
/// The with headers.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders(IDictionary<string, string[]> headers);
/// <summary>
/// The with headers.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders([NotNull] IDictionary<string, WireMockList<string>> headers);
}
/// <summary>
/// The with headers.
/// </summary>
/// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders(IDictionary<string, WireMockList<string>> headers);
}

View File

@@ -53,9 +53,9 @@ internal static class PactMapper
return (filename, JsonUtils.SerializeAsPactFile(pact));
}
private static Request MapRequest(RequestModel request, string path)
private static PactRequest MapRequest(RequestModel request, string path)
{
return new Request
return new PactRequest
{
Method = request.Methods?.FirstOrDefault() ?? DefaultMethod,
Path = path,
@@ -65,14 +65,14 @@ internal static class PactMapper
};
}
private static Response MapResponse(ResponseModel? response)
private static PactResponse MapResponse(ResponseModel? response)
{
if (response == null)
{
return new Response();
return new PactResponse();
}
return new Response
return new PactResponse
{
Status = MapStatusCode(response.StatusCode),
Headers = MapResponseHeaders(response.Headers),

View File

@@ -10,299 +10,302 @@ using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Util;
using Stef.Validation;
using OrgMapping = WireMock.Org.Abstractions.Mapping;
using OrgMappings = WireMock.Org.Abstractions.Mappings;
namespace WireMock.Server
namespace WireMock.Server;
public partial class WireMockServer
{
public partial class WireMockServer
/// <summary>
/// Read WireMock.org mapping json file.
/// </summary>
/// <param name="path">The path to the WireMock.org mapping json file.</param>
[PublicAPI]
public void ReadStaticWireMockOrgMappingAndAddOrUpdate(string path)
{
/// <summary>
/// Read WireMock.org mapping json file.
/// </summary>
/// <param name="path">The path to the WireMock.org mapping json file.</param>
[PublicAPI]
public void ReadStaticWireMockOrgMappingAndAddOrUpdate(string path)
Guard.NotNull(path, nameof(path));
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
if (FileHelper.TryReadMappingFileWithRetryAndDelay(_settings.FileSystemHandler, path, out string value))
{
Guard.NotNull(path, nameof(path));
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
if (FileHelper.TryReadMappingFileWithRetryAndDelay(_settings.FileSystemHandler, path, out string value))
var mappings = DeserializeJsonToArray<OrgMappings>(value);
foreach (var mapping in mappings)
{
var mappings = DeserializeJsonToArray<OrgMapping>(value);
foreach (var mapping in mappings)
if (mappings.Length == 1 && Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename))
{
if (mappings.Length == 1 && Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename))
{
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, guidFromFilename, path);
}
else
{
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, null, path);
}
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, guidFromFilename, path);
}
else
{
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, null, path);
}
}
}
}
private IResponseMessage MappingsPostWireMockOrg(IRequestMessage requestMessage)
private IResponseMessage MappingsPostWireMockOrg(IRequestMessage requestMessage)
{
try
{
try
var mappingModels = DeserializeRequestMessageToArray<OrgMappings>(requestMessage);
if (mappingModels.Length == 1)
{
var mappingModels = DeserializeRequestMessageToArray<OrgMapping>(requestMessage);
if (mappingModels.Length == 1)
{
Guid? guid = ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModels[0]);
return ResponseMessageBuilder.Create("Mapping added", 201, guid);
}
foreach (var mappingModel in mappingModels)
{
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModel);
}
return ResponseMessageBuilder.Create("Mappings added", 201);
Guid? guid = ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModels[0]);
return ResponseMessageBuilder.Create("Mapping added", 201, guid);
}
catch (ArgumentException a)
foreach (var mappingModel in mappingModels)
{
_settings.Logger.Error("HttpStatusCode set to 400 {0}", a);
return ResponseMessageBuilder.Create(a.Message, 400);
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModel);
}
catch (Exception e)
return ResponseMessageBuilder.Create("Mappings added", 201);
}
catch (ArgumentException a)
{
_settings.Logger.Error("HttpStatusCode set to 400 {0}", a);
return ResponseMessageBuilder.Create(a.Message, 400);
}
catch (Exception e)
{
_settings.Logger.Error("HttpStatusCode set to 500 {0}", e);
return ResponseMessageBuilder.Create(e.ToString(), 500);
}
}
private Guid? ConvertWireMockOrgMappingAndRegisterAsRespondProvider(OrgMappings mapping, Guid? guid = null, string? path = null)
{
var requestBuilder = Request.Create();
var request = mapping.Request;
if (request != null)
{
if (request.Url != null)
{
_settings.Logger.Error("HttpStatusCode set to 500 {0}", e);
return ResponseMessageBuilder.Create(e.ToString(), 500);
requestBuilder = requestBuilder.WithUrl(request.Url);
}
else if (request.UrlPattern != null)
{
requestBuilder = requestBuilder.WithUrl(new RegexMatcher(request.UrlPattern));
}
else if (request.UrlPath != null)
{
requestBuilder = requestBuilder.WithPath(request.UrlPath);
}
else if (request.UrlPathPattern != null)
{
requestBuilder = requestBuilder.WithPath(new RegexMatcher(request.UrlPathPattern));
}
if (request.Method != null)
{
requestBuilder = requestBuilder.UsingMethod(request.Method);
}
/*
"headers" : {
"Accept" : {
"contains" : "xml"
}
}
*/
if (request.Headers is JObject headers)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(headers, (key, match) =>
{
requestBuilder = requestBuilder.WithHeader(key, match);
});
}
if (request.Cookies is JObject cookies)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(cookies, (key, match) =>
{
requestBuilder = requestBuilder.WithCookie(key, match);
});
}
/*
"queryParameters" : {
"search_term" : {
"equalTo" : "WireMock"
}
}
*/
if (request.QueryParameters is JObject queryParameters)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(queryParameters, (key, match) =>
{
requestBuilder = requestBuilder.WithParam(key, match);
});
}
/*
"bodyPatterns" : [ {
"equalToJson" : "{ "cityName": "São Paulo", "cityCode": 5001 },
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true
} ]
*/
if (request.BodyPatterns?.Any() == true)
{
var jObjectArray = request.BodyPatterns.Cast<JObject>();
var bodyPattern = jObjectArray.First();
ProcessWireMockOrgJObjectAndUseIMatcher(bodyPattern, match =>
{
requestBuilder = requestBuilder.WithBody(match);
});
}
}
private Guid? ConvertWireMockOrgMappingAndRegisterAsRespondProvider(OrgMapping mapping, Guid? guid = null, string path = null)
IResponseBuilder responseBuilder = Response.Create();
var response = mapping.Response;
if (response != null)
{
var requestBuilder = Request.Create();
responseBuilder = responseBuilder.WithStatusCode(response.Status);
var request = mapping.Request;
if (request != null)
if (response.Headers is JObject responseHeaders)
{
if (request.Url != null)
var rb = responseBuilder;
ProcessWireMockOrgJObjectAndConvertToIDictionary(responseHeaders, headers =>
{
requestBuilder = requestBuilder.WithUrl(request.Url);
}
else if (request.UrlPattern != null)
{
requestBuilder = requestBuilder.WithUrl(new RegexMatcher(request.UrlPattern));
}
else if (request.UrlPath != null)
{
requestBuilder = requestBuilder.WithPath(request.Url);
}
else if (request.UrlPathPattern != null)
{
requestBuilder = requestBuilder.WithPath(new RegexMatcher(request.UrlPathPattern));
}
if (request.Method != null)
{
requestBuilder = requestBuilder.UsingMethod(request.Method);
}
/*
"headers" : {
"Accept" : {
"contains" : "xml"
}
}
*/
if (request.Headers is JObject headers)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(headers, (key, match) =>
{
requestBuilder = requestBuilder.WithHeader(key, match);
});
}
if (request.Cookies is JObject cookies)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(cookies, (key, match) =>
{
requestBuilder = requestBuilder.WithCookie(key, match);
});
}
/*
"queryParameters" : {
"search_term" : {
"equalTo" : "WireMock"
}
}
*/
if (request.QueryParameters is JObject queryParameters)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(queryParameters, (key, match) =>
{
requestBuilder = requestBuilder.WithParam(key, match);
});
}
/*
"bodyPatterns" : [ {
"equalToJson" : "{ "cityName": "São Paulo", "cityCode": 5001 },
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true
} ]
*/
if (request.BodyPatterns?.Any() == true)
{
var jObjectArray = request.BodyPatterns.Cast<JObject>();
var bodyPattern = jObjectArray.First();
ProcessWireMockOrgJObjectAndUseIMatcher(bodyPattern, (match) =>
{
requestBuilder = requestBuilder.WithBody(match);
});
}
rb = rb.WithHeaders(headers);
});
}
IResponseBuilder responseBuilder = Response.Create();
var response = mapping.Response;
if (response != null)
if (response.Transformers != null)
{
responseBuilder = responseBuilder.WithStatusCode(response.Status);
if (response.Headers is JObject responseHeaders)
{
ProcessWireMockOrgJObjectAndConvertToIDictionary(responseHeaders, (headers) =>
{
responseBuilder = responseBuilder.WithHeaders(headers);
});
}
if (response.Transformers != null)
{
responseBuilder = responseBuilder.WithTransformer();
}
if (response.Body != null)
{
responseBuilder = responseBuilder.WithBody(response.Body);
}
if (response.JsonBody != null)
{
responseBuilder = responseBuilder.WithBodyAsJson(response.JsonBody);
}
if (response.Base64Body != null)
{
responseBuilder = responseBuilder.WithBody(Encoding.UTF8.GetString(Convert.FromBase64String(response.Base64Body)));
}
if (response.BodyFileName != null)
{
responseBuilder = responseBuilder.WithBodyFromFile(response.BodyFileName);
}
responseBuilder = responseBuilder.WithTransformer();
}
var respondProvider = Given(requestBuilder);
if (guid != null)
if (response.Body != null)
{
respondProvider = respondProvider.WithGuid(guid.Value);
}
else if (!string.IsNullOrEmpty(mapping.Uuid))
{
respondProvider = respondProvider.WithGuid(new Guid(mapping.Uuid));
responseBuilder = responseBuilder.WithBody(response.Body);
}
if (mapping.Name != null)
if (response.JsonBody != null)
{
respondProvider = respondProvider.WithTitle(mapping.Name);
responseBuilder = responseBuilder.WithBodyAsJson(response.JsonBody);
}
if (path != null)
if (response.Base64Body != null)
{
respondProvider = respondProvider.WithPath(path);
responseBuilder = responseBuilder.WithBody(Encoding.UTF8.GetString(Convert.FromBase64String(response.Base64Body)));
}
respondProvider.RespondWith(responseBuilder);
return respondProvider.Guid;
}
private void ProcessWireMockOrgJObjectAndConvertToIDictionary(JObject items, Action<IDictionary<string, string>> action)
{
var dict = new Dictionary<string, string>();
foreach (var item in items)
if (response.BodyFileName != null)
{
var key = item.Key;
var valueAsString = item.Value.Value<string>();
dict.Add(key, valueAsString);
}
action(dict);
}
private void ProcessWireMockOrgJObjectAndUseStringMatcher(JObject items, Action<string, IStringMatcher> action)
{
foreach (var item in items)
{
var key = item.Key;
var match = item.Value.First as JProperty;
var valueAsString = match?.Value.Value<string>();
if (string.IsNullOrEmpty(valueAsString))
{
continue;
}
var matcher = ProcessAsStringMatcher(match, valueAsString);
if (matcher != null)
{
action(key, matcher);
}
responseBuilder = responseBuilder.WithBodyFromFile(response.BodyFileName);
}
}
private void ProcessWireMockOrgJObjectAndUseIMatcher(JObject items, Action<IMatcher> action)
var respondProvider = Given(requestBuilder);
if (guid != null)
{
if (!(items.First is JProperty firstItem))
respondProvider = respondProvider.WithGuid(guid.Value);
}
else if (!string.IsNullOrEmpty(mapping.Uuid))
{
respondProvider = respondProvider.WithGuid(new Guid(mapping.Uuid));
}
if (mapping.Name != null)
{
respondProvider = respondProvider.WithTitle(mapping.Name);
}
if (path != null)
{
respondProvider = respondProvider.WithPath(path);
}
respondProvider.RespondWith(responseBuilder);
return respondProvider.Guid;
}
private void ProcessWireMockOrgJObjectAndConvertToIDictionary(JObject items, Action<IDictionary<string, string>> action)
{
var dict = new Dictionary<string, string>();
foreach (var item in items)
{
var key = item.Key;
var valueAsString = item.Value?.Value<string>();
if (valueAsString == null)
{
// Skip if the item.Value is null or when the string value is null
continue;
}
dict.Add(key, valueAsString);
}
action(dict);
}
private void ProcessWireMockOrgJObjectAndUseStringMatcher(JObject items, Action<string, IStringMatcher> action)
{
foreach (var item in items)
{
var key = item.Key;
var match = item.Value?.First as JProperty;
if (match == null)
{
continue;
}
var valueAsString = match.Value.Value<string>();
if (string.IsNullOrEmpty(valueAsString))
{
continue;
}
var matcher = ProcessAsStringMatcher(match, valueAsString!);
if (matcher != null)
{
action(key, matcher);
}
}
}
private static void ProcessWireMockOrgJObjectAndUseIMatcher(JObject items, Action<IMatcher> action)
{
if (items.First is not JProperty firstItem)
{
return;
}
IMatcher? matcher;
if (firstItem.Name == "equalToJson")
{
matcher = new JsonMatcher(firstItem.Value);
}
else
{
if ((firstItem.Value as JValue)?.Value is not string valueAsString)
{
return;
}
IMatcher matcher;
if (firstItem.Name == "equalToJson")
{
matcher = new JsonMatcher(firstItem.Value);
}
else
{
var valueAsString = (firstItem.Value as JValue)?.Value as string;
if (valueAsString == null)
{
return;
}
matcher = ProcessAsStringMatcher(firstItem, valueAsString);
}
if (matcher != null)
{
action(matcher);
}
matcher = ProcessAsStringMatcher(firstItem, valueAsString);
}
private static IStringMatcher ProcessAsStringMatcher(JProperty match, string valueAsString)
if (matcher != null)
{
switch (match?.Name)
{
case "contains":
return new WildcardMatcher(valueAsString);
case "matches":
return new RegexMatcher(valueAsString);
case "equalTo":
return new ExactMatcher(valueAsString);
default:
return null;
}
action(matcher);
}
}
private static IStringMatcher? ProcessAsStringMatcher(JProperty match, string valueAsString)
{
return match.Name switch
{
"contains" => new WildcardMatcher(valueAsString),
"matches" => new RegexMatcher(valueAsString),
"equalTo" => new ExactMatcher(valueAsString),
_ => null,
};
}
}

View File

@@ -0,0 +1,59 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminMappingsByStubMappingIdResult
{
/// <summary>
/// This stub mapping's unique identifier
/// </summary>
public string Id { get; set; }
/// <summary>
/// Alias for the id
/// </summary>
public string Uuid { get; set; }
/// <summary>
/// The stub mapping's name
/// </summary>
public string Name { get; set; }
public WireMockOrgRequest Request { get; set; }
public WireMockOrgResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
/// </summary>
public bool Persistent { get; set; }
/// <summary>
/// This stub mapping's priority relative to others. 1 is highest.
/// </summary>
public int Priority { get; set; }
/// <summary>
/// The name of the scenario that this stub mapping is part of
/// </summary>
public string ScenarioName { get; set; }
/// <summary>
/// The required state of the scenario in order for this stub to be matched.
/// </summary>
public string RequiredScenarioState { get; set; }
/// <summary>
/// The new state for the scenario to be updated to after this stub is served.
/// </summary>
public string NewScenarioState { get; set; }
/// <summary>
/// A map of the names of post serve action extensions to trigger and their parameters.
/// </summary>
public object PostServeActions { get; set; }
/// <summary>
/// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
/// </summary>
public object Metadata { get; set; }
}
}

View File

@@ -1,9 +0,0 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminMappingsResponse
{
public Mapping[] Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminMappingsResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminRecordingsStatusResponse
public class GetAdminRecordingsStatusResult
{
public string Status { get; set; }
}
}
}

View File

@@ -1,7 +0,0 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminRequestsUnmatchedNearMissesResponse
{
public NearMiss[] NearMisses { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminRequestsUnmatchedNearMissesResult
{
public NearMisses NearMisses { get; set; }
}
}

View File

@@ -1,7 +0,0 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminScenariosResponse
{
public Scenario[] Scenarios { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminScenariosResult
{
public Scenarios Scenarios { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions
{
public class Mapping
public class Mappings
{
/// <summary>
/// This stub mapping's unique identifier
@@ -17,9 +17,9 @@ namespace WireMock.Org.Abstractions
/// </summary>
public string Name { get; set; }
public Request Request { get; set; }
public MappingsRequest Request { get; set; }
public Response Response { get; set; }
public MappingsResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
@@ -56,4 +56,4 @@ namespace WireMock.Org.Abstractions
/// </summary>
public object Metadata { get; set; }
}
}
}

View File

@@ -0,0 +1,55 @@
namespace WireMock.Org.Abstractions
{
public class MappingsRequest
{
/// <summary>
/// The HTTP request method e.g. GET
/// </summary>
public string Method { get; set; }
/// <summary>
/// The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string Url { get; set; }
/// <summary>
/// The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string UrlPath { get; set; }
/// <summary>
/// The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string UrlPathPattern { get; set; }
/// <summary>
/// The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string UrlPattern { get; set; }
/// <summary>
/// Query parameter patterns to match against in the : { "": "" } form
/// </summary>
public object QueryParameters { get; set; }
/// <summary>
/// Header patterns to match against in the : { "": "" } form
/// </summary>
public object Headers { get; set; }
/// <summary>
/// Pre-emptive basic auth credentials to match against
/// </summary>
public MappingsRequestBasicAuthCredentials BasicAuthCredentials { get; set; }
/// <summary>
/// Cookie patterns to match against in the : { "": "" } form
/// </summary>
public object Cookies { get; set; }
/// <summary>
/// Request body patterns to match against in the : { "": "" } form
/// </summary>
public object[] BodyPatterns { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// Pre-emptive basic auth credentials to match against
/// </summary>
public class MappingsRequestBasicAuthCredentials
{
public string Password { get; set; }
public string Username { get; set; }
}
}

View File

@@ -0,0 +1,80 @@
namespace WireMock.Org.Abstractions
{
public class MappingsResponse
{
/// <summary>
/// The HTTP status code to be returned
/// </summary>
public int Status { get; set; }
/// <summary>
/// The HTTP status message to be returned
/// </summary>
public string StatusMessage { get; set; }
/// <summary>
/// Map of response headers to send
/// </summary>
public object Headers { get; set; }
/// <summary>
/// Extra request headers to send when proxying to another host.
/// </summary>
public object AdditionalProxyRequestHeaders { get; set; }
/// <summary>
/// The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public string Body { get; set; }
/// <summary>
/// The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public string Base64Body { get; set; }
/// <summary>
/// The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public object JsonBody { get; set; }
/// <summary>
/// The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public string BodyFileName { get; set; }
/// <summary>
/// The fault to apply (instead of a full, valid response).
/// </summary>
public string Fault { get; set; }
/// <summary>
/// Number of milliseconds to delay be before sending the response.
/// </summary>
public int FixedDelayMilliseconds { get; set; }
/// <summary>
/// The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper.
/// </summary>
public object DelayDistribution { get; set; }
/// <summary>
/// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
/// </summary>
public bool FromConfiguredStub { get; set; }
/// <summary>
/// The base URL of the target to proxy matching requests to.
/// </summary>
public string ProxyBaseUrl { get; set; }
/// <summary>
/// Parameters to apply to response transformers.
/// </summary>
public object TransformerParameters { get; set; }
/// <summary>
/// List of names of transformers to apply to this response.
/// </summary>
public string[] Transformers { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// The fault to apply (instead of a full, valid response).
/// </summary>
public static class MappingsResponseFaultConstants
{
public const string CONNECTIONRESETBYPEER = "CONNECTION_RESET_BY_PEER";
public const string EMPTYRESPONSE = "EMPTY_RESPONSE";
public const string MALFORMEDRESPONSECHUNK = "MALFORMED_RESPONSE_CHUNK";
public const string RANDOMDATATHENCLOSE = "RANDOM_DATA_THEN_CLOSE";
}
}

View File

@@ -4,4 +4,4 @@ namespace WireMock.Org.Abstractions
{
public int Total { get; set; }
}
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions
{
public class NearMiss
public class NearMisses
{
/// <summary>
/// The HTTP request method
@@ -18,12 +18,12 @@ namespace WireMock.Org.Abstractions
public string AbsoluteUrl { get; set; }
/// <summary>
/// Header patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form
/// Header patterns to match against in the : { "": "" } form
/// </summary>
public object Headers { get; set; }
/// <summary>
/// Cookie patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form
/// Cookie patterns to match against in the : { "": "" } form
/// </summary>
public object Cookies { get; set; }
@@ -32,4 +32,4 @@ namespace WireMock.Org.Abstractions
/// </summary>
public string Body { get; set; }
}
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminMappingsFindByMetadataResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -0,0 +1,59 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminMappingsResult
{
/// <summary>
/// This stub mapping's unique identifier
/// </summary>
public string Id { get; set; }
/// <summary>
/// Alias for the id
/// </summary>
public string Uuid { get; set; }
/// <summary>
/// The stub mapping's name
/// </summary>
public string Name { get; set; }
public WireMockOrgRequest Request { get; set; }
public WireMockOrgResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
/// </summary>
public bool Persistent { get; set; }
/// <summary>
/// This stub mapping's priority relative to others. 1 is highest.
/// </summary>
public int Priority { get; set; }
/// <summary>
/// The name of the scenario that this stub mapping is part of
/// </summary>
public string ScenarioName { get; set; }
/// <summary>
/// The required state of the scenario in order for this stub to be matched.
/// </summary>
public string RequiredScenarioState { get; set; }
/// <summary>
/// The new state for the scenario to be updated to after this stub is served.
/// </summary>
public string NewScenarioState { get; set; }
/// <summary>
/// A map of the names of post serve action extensions to trigger and their parameters.
/// </summary>
public object PostServeActions { get; set; }
/// <summary>
/// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
/// </summary>
public object Metadata { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminNearMissesRequestPatternResult
{
public NearMisses NearMisses { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminNearMissesRequestResult
{
public NearMisses NearMisses { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminRecordingsSnapshotResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminRecordingsStopResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminRequestsCountResponse
public class PostAdminRequestsCountResult
{
public int Count { get; set; }
}
}
}

View File

@@ -0,0 +1,59 @@
namespace WireMock.Org.Abstractions
{
public class PutAdminMappingsByStubMappingIdResult
{
/// <summary>
/// This stub mapping's unique identifier
/// </summary>
public string Id { get; set; }
/// <summary>
/// Alias for the id
/// </summary>
public string Uuid { get; set; }
/// <summary>
/// The stub mapping's name
/// </summary>
public string Name { get; set; }
public WireMockOrgRequest Request { get; set; }
public WireMockOrgResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
/// </summary>
public bool Persistent { get; set; }
/// <summary>
/// This stub mapping's priority relative to others. 1 is highest.
/// </summary>
public int Priority { get; set; }
/// <summary>
/// The name of the scenario that this stub mapping is part of
/// </summary>
public string ScenarioName { get; set; }
/// <summary>
/// The required state of the scenario in order for this stub to be matched.
/// </summary>
public string RequiredScenarioState { get; set; }
/// <summary>
/// The new state for the scenario to be updated to after this stub is served.
/// </summary>
public string NewScenarioState { get; set; }
/// <summary>
/// A map of the names of post serve action extensions to trigger and their parameters.
/// </summary>
public object PostServeActions { get; set; }
/// <summary>
/// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
/// </summary>
public object Metadata { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions
{
public class Request
public class WireMockOrgRequest
{
/// <summary>
/// The HTTP request method e.g. GET
@@ -28,28 +28,28 @@ namespace WireMock.Org.Abstractions
public string UrlPattern { get; set; }
/// <summary>
/// Query parameter patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form
/// Query parameter patterns to match against in the : { "": "" } form
/// </summary>
public object QueryParameters { get; set; }
/// <summary>
/// Header patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form
/// Header patterns to match against in the : { "": "" } form
/// </summary>
public object Headers { get; set; }
/// <summary>
/// Pre-emptive basic auth credentials to match against
/// </summary>
public BasicAuthCredentials BasicAuthCredentials { get; set; }
public RequestBasicAuthCredentials BasicAuthCredentials { get; set; }
/// <summary>
/// Cookie patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form
/// Cookie patterns to match against in the : { "": "" } form
/// </summary>
public object Cookies { get; set; }
/// <summary>
/// Request body patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form
/// Request body patterns to match against in the : { "": "" } form
/// </summary>
public object[] BodyPatterns { get; set; }
}
}
}

View File

@@ -3,10 +3,10 @@ namespace WireMock.Org.Abstractions
/// <summary>
/// Pre-emptive basic auth credentials to match against
/// </summary>
public class BasicAuthCredentials
public class RequestBasicAuthCredentials
{
public string Password { get; set; }
public string Username { get; set; }
}
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions
{
public class Response
public class WireMockOrgResponse
{
/// <summary>
/// The HTTP status code to be returned
@@ -52,6 +52,11 @@ namespace WireMock.Org.Abstractions
/// </summary>
public int FixedDelayMilliseconds { get; set; }
/// <summary>
/// The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper.
/// </summary>
public object DelayDistribution { get; set; }
/// <summary>
/// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
/// </summary>
@@ -70,6 +75,6 @@ namespace WireMock.Org.Abstractions
/// <summary>
/// List of names of transformers to apply to this response.
/// </summary>
public string Transformers { get; set; }
public string[] Transformers { get; set; }
}
}
}

View File

@@ -0,0 +1,16 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// The fault to apply (instead of a full, valid response).
/// </summary>
public static class ResponseFaultConstants
{
public const string CONNECTIONRESETBYPEER = "CONNECTION_RESET_BY_PEER";
public const string EMPTYRESPONSE = "EMPTY_RESPONSE";
public const string MALFORMEDRESPONSECHUNK = "MALFORMED_RESPONSE_CHUNK";
public const string RANDOMDATATHENCLOSE = "RANDOM_DATA_THEN_CLOSE";
}
}

View File

@@ -1,14 +0,0 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// Log normal randomly distributed response delay.
/// </summary>
public class ResponseLogNormal
{
public int Median { get; set; }
public double Sigma { get; set; }
public string Type { get; set; }
}
}

View File

@@ -1,14 +0,0 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// Uniformly distributed random response delay.
/// </summary>
public class ResponseLogUniformlyDistributed
{
public int Lower { get; set; }
public string Type { get; set; }
public int Upper { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions
{
public class Scenario
public class Scenarios
{
/// <summary>
/// The scenario ID
@@ -12,11 +12,14 @@ namespace WireMock.Org.Abstractions
/// </summary>
public string Name { get; set; }
public string PossibleStates { get; set; }
/// <summary>
/// All the states this scenario can be in
/// </summary>
public string[] PossibleStates { get; set; }
/// <summary>
/// The current state of this scenario
/// </summary>
public string State { get; set; }
}
}
}

View File

@@ -0,0 +1,11 @@
namespace WireMock.Org.Abstractions
{
public static class StatusConstants
{
public const string NeverStarted = "NeverStarted";
public const string Recording = "Recording";
public const string Stopped = "Stopped";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,232 +1,299 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using AnyOfTypes;
using RestEase;
using WireMock.Org.Abstractions;
namespace WireMock.Org.RestClient
{
/// <summary>
/// WireMockOrg
/// Summary: WireMockOrg
///
/// Title : WireMock
/// Version: 2.33.2
/// </summary>
public interface IWireMockOrgApi
{
/// <summary>
/// Get all stub mappings
///
/// GetAdminMappings (/__admin/mappings)
/// </summary>
/// <param name="limit">The maximum number of results to return</param>
/// <param name="offset">The start index of the results to return</param>
[Get("/__admin/mappings")]
Task<GetAdminMappingsResponse> GetAdminMappingsAsync([Query] int? limit, [Query] int? offset);
Task<GetAdminMappingsResult> GetAdminMappingsAsync([Query] int? limit, [Query] int? offset);
/// <summary>
/// Create a new stub mapping
///
/// PostAdminMappings (/__admin/mappings)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/mappings")]
[Header("Content-Type", "application/json")]
Task<Mapping> PostAdminMappingsAsync([Body] Mapping request);
Task<PostAdminMappingsResult> PostAdminMappingsAsync();
/// <summary>
/// Delete all stub mappings
///
/// DeleteAdminMappings (/__admin/mappings)
/// </summary>
[Delete("/__admin/mappings")]
Task DeleteAdminMappingsAsync();
Task<object> DeleteAdminMappingsAsync();
/// <summary>
/// Reset stub mappings
///
/// PostAdminMappingsReset (/__admin/mappings/reset)
/// </summary>
[Post("/__admin/mappings/reset")]
Task PostAdminMappingsResetAsync();
Task<object> PostAdminMappingsResetAsync();
/// <summary>
/// Persist stub mappings
///
/// PostAdminMappingsSave (/__admin/mappings/save)
/// </summary>
[Post("/__admin/mappings/save")]
Task PostAdminMappingsSaveAsync();
Task<object> PostAdminMappingsSaveAsync();
/// <summary>
/// Get stub mapping by ID
///
/// GetAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId})
/// </summary>
/// <param name="stubMappingId">The UUID of stub mapping</param>
[Get("/__admin/mappings/{stubMappingId}")]
Task<Mapping> GetAdminMappingsByStubMappingIdAsync();
Task<Response<AnyOf<GetAdminMappingsByStubMappingIdResult, object>>> GetAdminMappingsByStubMappingIdAsync([Path] string stubMappingId);
/// <summary>
/// Update a stub mapping
///
/// PutAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId})
/// </summary>
/// <param name="request"></param>
/// <param name="stubMappingId">The UUID of stub mapping</param>
[Put("/__admin/mappings/{stubMappingId}")]
[Header("Content-Type", "application/json")]
Task<Mapping> PutAdminMappingsByStubMappingIdAsync([Body] Mapping request);
Task<Response<AnyOf<PutAdminMappingsByStubMappingIdResult, object>>> PutAdminMappingsByStubMappingIdAsync([Path] string stubMappingId);
/// <summary>
/// Delete a stub mapping
///
/// DeleteAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId})
/// </summary>
/// <param name="stubMappingId">The UUID of stub mapping</param>
[Delete("/__admin/mappings/{stubMappingId}")]
Task DeleteAdminMappingsByStubMappingIdAsync();
Task<object> DeleteAdminMappingsByStubMappingIdAsync([Path] string stubMappingId);
/// <summary>
/// Find stubs by matching on their metadata
///
/// PostAdminMappingsFindByMetadata (/__admin/mappings/find-by-metadata)
/// </summary>
[Post("/__admin/mappings/find-by-metadata")]
[Header("Content-Type", "application/json")]
Task<GetAdminMappingsResponse> PostAdminMappingsFindByMetadataAsync();
Task<PostAdminMappingsFindByMetadataResult> PostAdminMappingsFindByMetadataAsync();
/// <summary>
/// Delete stub mappings matching metadata
///
/// PostAdminMappingsRemoveByMetadata (/__admin/mappings/remove-by-metadata)
/// </summary>
[Post("/__admin/mappings/remove-by-metadata")]
[Header("Content-Type", "application/json")]
Task PostAdminMappingsRemoveByMetadataAsync();
Task<object> PostAdminMappingsRemoveByMetadataAsync();
/// <summary>
/// Get all requests in journal
///
/// GetAdminRequests (/__admin/requests)
/// </summary>
/// <param name="limit">The maximum number of results to return</param>
/// <param name="since">Only return logged requests after this date</param>
[Get("/__admin/requests")]
Task GetAdminRequestsAsync([Query] string limit, [Query] string since);
Task<object> GetAdminRequestsAsync([Query] string limit, [Query] string since);
/// <summary>
/// Delete all requests in journal
///
/// DeleteAdminRequests (/__admin/requests)
/// </summary>
[Delete("/__admin/requests")]
Task DeleteAdminRequestsAsync();
Task<object> DeleteAdminRequestsAsync();
/// <summary>
/// Get request by ID
///
/// GetAdminRequestsByRequestId (/__admin/requests/{requestId})
/// </summary>
/// <param name="requestId">The UUID of the logged request</param>
[Get("/__admin/requests/{requestId}")]
Task GetAdminRequestsByRequestIdAsync([Path] string requestId);
Task<object> GetAdminRequestsByRequestIdAsync([Path] string requestId);
/// <summary>
/// Delete request by ID
///
/// DeleteAdminRequestsByRequestId (/__admin/requests/{requestId})
/// </summary>
/// <param name="requestId">The UUID of the logged request</param>
[Delete("/__admin/requests/{requestId}")]
Task DeleteAdminRequestsByRequestIdAsync([Path] string requestId);
Task<object> DeleteAdminRequestsByRequestIdAsync([Path] string requestId);
/// <summary>
/// Empty the request journal
///
/// PostAdminRequestsReset (/__admin/requests/reset)
/// </summary>
[Post("/__admin/requests/reset")]
Task PostAdminRequestsResetAsync();
Task<object> PostAdminRequestsResetAsync();
/// <summary>
/// Count requests by criteria
///
/// PostAdminRequestsCount (/__admin/requests/count)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/requests/count")]
[Header("Content-Type", "application/json")]
Task<PostAdminRequestsCountResponse> PostAdminRequestsCountAsync([Body] Request request);
Task<PostAdminRequestsCountResult> PostAdminRequestsCountAsync();
/// <summary>
/// Remove requests by criteria
///
/// PostAdminRequestsRemove (/__admin/requests/remove)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/requests/remove")]
[Header("Content-Type", "application/json")]
Task PostAdminRequestsRemoveAsync([Body] Request request);
Task<object> PostAdminRequestsRemoveAsync();
/// <summary>
/// Delete requests mappings matching metadata
///
/// PostAdminRequestsRemoveByMetadata (/__admin/requests/remove-by-metadata)
/// </summary>
[Post("/__admin/requests/remove-by-metadata")]
[Header("Content-Type", "application/json")]
Task PostAdminRequestsRemoveByMetadataAsync();
Task<object> PostAdminRequestsRemoveByMetadataAsync();
/// <summary>
/// Find requests by criteria
///
/// PostAdminRequestsFind (/__admin/requests/find)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/requests/find")]
[Header("Content-Type", "application/json")]
Task PostAdminRequestsFindAsync([Body] Request request);
Task<object> PostAdminRequestsFindAsync();
/// <summary>
/// Find unmatched requests
///
/// GetAdminRequestsUnmatched (/__admin/requests/unmatched)
/// </summary>
[Get("/__admin/requests/unmatched")]
Task GetAdminRequestsUnmatchedAsync();
Task<object> GetAdminRequestsUnmatchedAsync();
/// <summary>
/// Retrieve near-misses for all unmatched requests
///
/// GetAdminRequestsUnmatchedNearMisses (/__admin/requests/unmatched/near-misses)
/// </summary>
[Get("/__admin/requests/unmatched/near-misses")]
Task<GetAdminRequestsUnmatchedNearMissesResponse> GetAdminRequestsUnmatchedNearMissesAsync();
Task<GetAdminRequestsUnmatchedNearMissesResult> GetAdminRequestsUnmatchedNearMissesAsync();
/// <summary>
/// Find near misses matching specific request
///
/// PostAdminNearMissesRequest (/__admin/near-misses/request)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/near-misses/request")]
[Header("Content-Type", "application/json")]
Task<GetAdminRequestsUnmatchedNearMissesResponse> PostAdminNearMissesRequestAsync([Body] NearMiss request);
Task<PostAdminNearMissesRequestResult> PostAdminNearMissesRequestAsync();
/// <summary>
/// Find near misses matching request pattern
///
/// PostAdminNearMissesRequestPattern (/__admin/near-misses/request-pattern)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/near-misses/request-pattern")]
[Header("Content-Type", "application/json")]
Task<GetAdminRequestsUnmatchedNearMissesResponse> PostAdminNearMissesRequestPatternAsync([Body] Request request);
Task<PostAdminNearMissesRequestPatternResult> PostAdminNearMissesRequestPatternAsync();
/// <summary>
/// Start recording
///
/// PostAdminRecordingsStart (/__admin/recordings/start)
/// </summary>
[Post("/__admin/recordings/start")]
[Header("Content-Type", "application/json")]
Task PostAdminRecordingsStartAsync();
Task<object> PostAdminRecordingsStartAsync();
/// <summary>
/// Stop recording
///
/// PostAdminRecordingsStop (/__admin/recordings/stop)
/// </summary>
[Post("/__admin/recordings/stop")]
Task<GetAdminMappingsResponse> PostAdminRecordingsStopAsync();
Task<PostAdminRecordingsStopResult> PostAdminRecordingsStopAsync();
/// <summary>
/// Get recording status
///
/// GetAdminRecordingsStatus (/__admin/recordings/status)
/// </summary>
[Get("/__admin/recordings/status")]
Task<GetAdminRecordingsStatusResponse> GetAdminRecordingsStatusAsync();
Task<GetAdminRecordingsStatusResult> GetAdminRecordingsStatusAsync();
/// <summary>
/// Take a snapshot recording
///
/// PostAdminRecordingsSnapshot (/__admin/recordings/snapshot)
/// </summary>
/// <param name="request"></param>
[Post("/__admin/recordings/snapshot")]
[Header("Content-Type", "application/json")]
Task<GetAdminMappingsResponse> PostAdminRecordingsSnapshotAsync([Body] object request);
Task<PostAdminRecordingsSnapshotResult> PostAdminRecordingsSnapshotAsync();
/// <summary>
/// Get all scenarios
///
/// GetAdminScenarios (/__admin/scenarios)
/// </summary>
[Get("/__admin/scenarios")]
Task<GetAdminScenariosResponse> GetAdminScenariosAsync();
Task<GetAdminScenariosResult> GetAdminScenariosAsync();
/// <summary>
/// Reset the state of all scenarios
///
/// PostAdminScenariosReset (/__admin/scenarios/reset)
/// </summary>
[Post("/__admin/scenarios/reset")]
Task PostAdminScenariosResetAsync();
Task<object> PostAdminScenariosResetAsync();
/// <summary>
/// Update global settings
///
/// PostAdminSettings (/__admin/settings)
/// </summary>
[Post("/__admin/settings")]
[Header("Content-Type", "application/json")]
Task PostAdminSettingsAsync();
Task<object> PostAdminSettingsAsync();
/// <summary>
/// Reset mappings and request journal
///
/// PostAdminReset (/__admin/reset)
/// </summary>
[Post("/__admin/reset")]
Task PostAdminResetAsync();
Task<object> PostAdminResetAsync();
/// <summary>
/// Shutdown the WireMock server
///
/// PostAdminShutdown (/__admin/shutdown)
/// </summary>
[Post("/__admin/shutdown")]
Task PostAdminShutdownAsync();
Task<object> PostAdminShutdownAsync();
}
}
}

View File

@@ -30,8 +30,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AnyOf" Version="0.3.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="RestEase" Version="1.5.6" />
<PackageReference Include="RestEase" Version="1.5.7" />
</ItemGroup>
<ItemGroup>

View File

@@ -52,7 +52,7 @@
<PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="RestEase" Version="1.5.6" />
<PackageReference Include="RestEase" Version="1.5.7" />
<!--<PackageReference Include="RandomDataGenerator.Net" Version="1.0.14" />-->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />