diff --git a/examples/WireMock.Net.Client/WireMock.Net.Client.csproj b/examples/WireMock.Net.Client/WireMock.Net.Client.csproj index 172526bc..bb713b33 100644 --- a/examples/WireMock.Net.Client/WireMock.Net.Client.csproj +++ b/examples/WireMock.Net.Client/WireMock.Net.Client.csproj @@ -8,7 +8,7 @@ - + diff --git a/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj b/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj index 821c04c7..46e88614 100644 --- a/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj +++ b/examples/WireMock.Net.StandAlone.Net461/WireMock.Net.StandAlone.Net461.csproj @@ -204,8 +204,8 @@ ..\..\packages\Owin.1.0\lib\net40\Owin.dll - - ..\..\packages\RestEase.1.5.5\lib\net45\RestEase.dll + + ..\..\packages\RestEase.1.5.7\lib\net452\RestEase.dll ..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll diff --git a/examples/WireMock.Net.StandAlone.Net461/packages.config b/examples/WireMock.Net.StandAlone.Net461/packages.config index 6a81b1b3..b07a4777 100644 --- a/examples/WireMock.Net.StandAlone.Net461/packages.config +++ b/examples/WireMock.Net.StandAlone.Net461/packages.config @@ -59,7 +59,7 @@ - + diff --git a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj index e5f92a87..420a9cda 100644 --- a/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj +++ b/src/WireMock.Net.Abstractions/WireMock.Net.Abstractions.csproj @@ -35,7 +35,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj index fff55ebe..bf7112a4 100644 --- a/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj +++ b/src/WireMock.Net.RestClient/WireMock.Net.RestClient.csproj @@ -31,7 +31,7 @@ - + diff --git a/src/WireMock.Net/ResponseBuilders/IHeadersResponseBuilder.cs b/src/WireMock.Net/ResponseBuilders/IHeadersResponseBuilder.cs index 3590576a..0d47eb26 100644 --- a/src/WireMock.Net/ResponseBuilders/IHeadersResponseBuilder.cs +++ b/src/WireMock.Net/ResponseBuilders/IHeadersResponseBuilder.cs @@ -1,41 +1,40 @@ -using JetBrains.Annotations; +using JetBrains.Annotations; using System.Collections.Generic; using WireMock.Types; -namespace WireMock.ResponseBuilders +namespace WireMock.ResponseBuilders; + +/// +/// The HeadersResponseBuilder interface. +/// +public interface IHeadersResponseBuilder : IBodyResponseBuilder { /// - /// The HeadersResponseBuilder interface. + /// The with header. /// - public interface IHeadersResponseBuilder : IBodyResponseBuilder - { - /// - /// The with header. - /// - /// The name. - /// The values. - /// The . - IResponseBuilder WithHeader([NotNull] string name, params string[] values); + /// The name. + /// The values. + /// The . + IResponseBuilder WithHeader(string name, params string[] values); - /// - /// The with headers. - /// - /// The headers. - /// The . - IResponseBuilder WithHeaders([NotNull] IDictionary headers); + /// + /// The with headers. + /// + /// The headers. + /// The . + IResponseBuilder WithHeaders(IDictionary headers); - /// - /// The with headers. - /// - /// The headers. - /// The . - IResponseBuilder WithHeaders([NotNull] IDictionary headers); + /// + /// The with headers. + /// + /// The headers. + /// The . + IResponseBuilder WithHeaders(IDictionary headers); - /// - /// The with headers. - /// - /// The headers. - /// The . - IResponseBuilder WithHeaders([NotNull] IDictionary> headers); - } + /// + /// The with headers. + /// + /// The headers. + /// The . + IResponseBuilder WithHeaders(IDictionary> headers); } \ No newline at end of file diff --git a/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs b/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs index 044e48f2..fccb0bd8 100644 --- a/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs +++ b/src/WireMock.Net/Server/WireMockServer.ImportWireMockOrg.cs @@ -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 + /// + /// Read WireMock.org mapping json file. + /// + /// The path to the WireMock.org mapping json file. + [PublicAPI] + public void ReadStaticWireMockOrgMappingAndAddOrUpdate(string path) { - /// - /// Read WireMock.org mapping json file. - /// - /// The path to the WireMock.org mapping json file. - [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(value); + foreach (var mapping in mappings) { - var mappings = DeserializeJsonToArray(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(requestMessage); + if (mappingModels.Length == 1) { - var mappingModels = DeserializeRequestMessageToArray(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(); + 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(); - 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> action) - { - var dict = new Dictionary(); - foreach (var item in items) + if (response.BodyFileName != null) { - var key = item.Key; - var valueAsString = item.Value.Value(); - dict.Add(key, valueAsString); - } - - action(dict); - } - - private void ProcessWireMockOrgJObjectAndUseStringMatcher(JObject items, Action action) - { - foreach (var item in items) - { - var key = item.Key; - var match = item.Value.First as JProperty; - var valueAsString = match?.Value.Value(); - 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 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> action) + { + var dict = new Dictionary(); + foreach (var item in items) + { + var key = item.Key; + var valueAsString = item.Value?.Value(); + 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 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(); + if (string.IsNullOrEmpty(valueAsString)) + { + continue; + } + + var matcher = ProcessAsStringMatcher(match, valueAsString!); + if (matcher != null) + { + action(key, matcher); + } + } + } + + private static void ProcessWireMockOrgJObjectAndUseIMatcher(JObject items, Action 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, + }; + } } \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/GetAdminMappingsByStubMappingIdResult.cs b/src/WireMock.Org.Abstractions/GetAdminMappingsByStubMappingIdResult.cs new file mode 100644 index 00000000..78900e39 --- /dev/null +++ b/src/WireMock.Org.Abstractions/GetAdminMappingsByStubMappingIdResult.cs @@ -0,0 +1,59 @@ +namespace WireMock.Org.Abstractions +{ + public class GetAdminMappingsByStubMappingIdResult + { + /// + /// This stub mapping's unique identifier + /// + public string Id { get; set; } + + /// + /// Alias for the id + /// + public string Uuid { get; set; } + + /// + /// The stub mapping's name + /// + public string Name { get; set; } + + public WireMockOrgRequest Request { get; set; } + + public WireMockOrgResponse Response { get; set; } + + /// + /// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default. + /// + public bool Persistent { get; set; } + + /// + /// This stub mapping's priority relative to others. 1 is highest. + /// + public int Priority { get; set; } + + /// + /// The name of the scenario that this stub mapping is part of + /// + public string ScenarioName { get; set; } + + /// + /// The required state of the scenario in order for this stub to be matched. + /// + public string RequiredScenarioState { get; set; } + + /// + /// The new state for the scenario to be updated to after this stub is served. + /// + public string NewScenarioState { get; set; } + + /// + /// A map of the names of post serve action extensions to trigger and their parameters. + /// + public object PostServeActions { get; set; } + + /// + /// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs. + /// + public object Metadata { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/GetAdminMappingsResponse.cs b/src/WireMock.Org.Abstractions/GetAdminMappingsResponse.cs deleted file mode 100644 index 336b72cf..00000000 --- a/src/WireMock.Org.Abstractions/GetAdminMappingsResponse.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace WireMock.Org.Abstractions -{ - public class GetAdminMappingsResponse - { - public Mapping[] Mappings { get; set; } - - public Meta Meta { get; set; } - } -} diff --git a/src/WireMock.Org.Abstractions/GetAdminMappingsResult.cs b/src/WireMock.Org.Abstractions/GetAdminMappingsResult.cs new file mode 100644 index 00000000..29bd0b45 --- /dev/null +++ b/src/WireMock.Org.Abstractions/GetAdminMappingsResult.cs @@ -0,0 +1,9 @@ +namespace WireMock.Org.Abstractions +{ + public class GetAdminMappingsResult + { + public Mappings Mappings { get; set; } + + public Meta Meta { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/GetAdminRecordingsStatusResponse.cs b/src/WireMock.Org.Abstractions/GetAdminRecordingsStatusResult.cs similarity index 64% rename from src/WireMock.Org.Abstractions/GetAdminRecordingsStatusResponse.cs rename to src/WireMock.Org.Abstractions/GetAdminRecordingsStatusResult.cs index 0dc8fc91..6d97044b 100644 --- a/src/WireMock.Org.Abstractions/GetAdminRecordingsStatusResponse.cs +++ b/src/WireMock.Org.Abstractions/GetAdminRecordingsStatusResult.cs @@ -1,7 +1,7 @@ namespace WireMock.Org.Abstractions { - public class GetAdminRecordingsStatusResponse + public class GetAdminRecordingsStatusResult { public string Status { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/GetAdminRequestsUnmatchedNearMissesResponse.cs b/src/WireMock.Org.Abstractions/GetAdminRequestsUnmatchedNearMissesResponse.cs deleted file mode 100644 index 335f0280..00000000 --- a/src/WireMock.Org.Abstractions/GetAdminRequestsUnmatchedNearMissesResponse.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace WireMock.Org.Abstractions -{ - public class GetAdminRequestsUnmatchedNearMissesResponse - { - public NearMiss[] NearMisses { get; set; } - } -} diff --git a/src/WireMock.Org.Abstractions/GetAdminRequestsUnmatchedNearMissesResult.cs b/src/WireMock.Org.Abstractions/GetAdminRequestsUnmatchedNearMissesResult.cs new file mode 100644 index 00000000..0e189fef --- /dev/null +++ b/src/WireMock.Org.Abstractions/GetAdminRequestsUnmatchedNearMissesResult.cs @@ -0,0 +1,7 @@ +namespace WireMock.Org.Abstractions +{ + public class GetAdminRequestsUnmatchedNearMissesResult + { + public NearMisses NearMisses { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/GetAdminScenariosResponse.cs b/src/WireMock.Org.Abstractions/GetAdminScenariosResponse.cs deleted file mode 100644 index e4b98405..00000000 --- a/src/WireMock.Org.Abstractions/GetAdminScenariosResponse.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace WireMock.Org.Abstractions -{ - public class GetAdminScenariosResponse - { - public Scenario[] Scenarios { get; set; } - } -} diff --git a/src/WireMock.Org.Abstractions/GetAdminScenariosResult.cs b/src/WireMock.Org.Abstractions/GetAdminScenariosResult.cs new file mode 100644 index 00000000..c25cf1b1 --- /dev/null +++ b/src/WireMock.Org.Abstractions/GetAdminScenariosResult.cs @@ -0,0 +1,7 @@ +namespace WireMock.Org.Abstractions +{ + public class GetAdminScenariosResult + { + public Scenarios Scenarios { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/Mapping.cs b/src/WireMock.Org.Abstractions/Mappings.cs similarity index 92% rename from src/WireMock.Org.Abstractions/Mapping.cs rename to src/WireMock.Org.Abstractions/Mappings.cs index 12676d7c..15b5a8c4 100644 --- a/src/WireMock.Org.Abstractions/Mapping.cs +++ b/src/WireMock.Org.Abstractions/Mappings.cs @@ -1,6 +1,6 @@ namespace WireMock.Org.Abstractions { - public class Mapping + public class Mappings { /// /// This stub mapping's unique identifier @@ -17,9 +17,9 @@ namespace WireMock.Org.Abstractions /// 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; } /// /// 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 /// public object Metadata { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/MappingsRequest.cs b/src/WireMock.Org.Abstractions/MappingsRequest.cs new file mode 100644 index 00000000..acbddc1f --- /dev/null +++ b/src/WireMock.Org.Abstractions/MappingsRequest.cs @@ -0,0 +1,55 @@ +namespace WireMock.Org.Abstractions +{ + public class MappingsRequest + { + /// + /// The HTTP request method e.g. GET + /// + public string Method { get; set; } + + /// + /// The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified. + /// + public string Url { get; set; } + + /// + /// The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified. + /// + public string UrlPath { get; set; } + + /// + /// The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified. + /// + public string UrlPathPattern { get; set; } + + /// + /// The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified. + /// + public string UrlPattern { get; set; } + + /// + /// Query parameter patterns to match against in the : { "": "" } form + /// + public object QueryParameters { get; set; } + + /// + /// Header patterns to match against in the : { "": "" } form + /// + public object Headers { get; set; } + + /// + /// Pre-emptive basic auth credentials to match against + /// + public MappingsRequestBasicAuthCredentials BasicAuthCredentials { get; set; } + + /// + /// Cookie patterns to match against in the : { "": "" } form + /// + public object Cookies { get; set; } + + /// + /// Request body patterns to match against in the : { "": "" } form + /// + public object[] BodyPatterns { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/MappingsRequestBasicAuthCredentials.cs b/src/WireMock.Org.Abstractions/MappingsRequestBasicAuthCredentials.cs new file mode 100644 index 00000000..476c8c29 --- /dev/null +++ b/src/WireMock.Org.Abstractions/MappingsRequestBasicAuthCredentials.cs @@ -0,0 +1,12 @@ +namespace WireMock.Org.Abstractions +{ + /// + /// Pre-emptive basic auth credentials to match against + /// + public class MappingsRequestBasicAuthCredentials + { + public string Password { get; set; } + + public string Username { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/MappingsResponse.cs b/src/WireMock.Org.Abstractions/MappingsResponse.cs new file mode 100644 index 00000000..1c33bb06 --- /dev/null +++ b/src/WireMock.Org.Abstractions/MappingsResponse.cs @@ -0,0 +1,80 @@ +namespace WireMock.Org.Abstractions +{ + public class MappingsResponse + { + /// + /// The HTTP status code to be returned + /// + public int Status { get; set; } + + /// + /// The HTTP status message to be returned + /// + public string StatusMessage { get; set; } + + /// + /// Map of response headers to send + /// + public object Headers { get; set; } + + /// + /// Extra request headers to send when proxying to another host. + /// + public object AdditionalProxyRequestHeaders { get; set; } + + /// + /// The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified. + /// + public string Body { get; set; } + + /// + /// The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified. + /// + public string Base64Body { get; set; } + + /// + /// The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified. + /// + public object JsonBody { get; set; } + + /// + /// 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. + /// + public string BodyFileName { get; set; } + + /// + /// The fault to apply (instead of a full, valid response). + /// + public string Fault { get; set; } + + /// + /// Number of milliseconds to delay be before sending the response. + /// + public int FixedDelayMilliseconds { get; set; } + + /// + /// The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper. + /// + public object DelayDistribution { get; set; } + + /// + /// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise. + /// + public bool FromConfiguredStub { get; set; } + + /// + /// The base URL of the target to proxy matching requests to. + /// + public string ProxyBaseUrl { get; set; } + + /// + /// Parameters to apply to response transformers. + /// + public object TransformerParameters { get; set; } + + /// + /// List of names of transformers to apply to this response. + /// + public string[] Transformers { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/MappingsResponseFaultConstants.cs b/src/WireMock.Org.Abstractions/MappingsResponseFaultConstants.cs new file mode 100644 index 00000000..50bc8435 --- /dev/null +++ b/src/WireMock.Org.Abstractions/MappingsResponseFaultConstants.cs @@ -0,0 +1,16 @@ +namespace WireMock.Org.Abstractions +{ + /// + /// The fault to apply (instead of a full, valid response). + /// + 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"; + } +} diff --git a/src/WireMock.Org.Abstractions/Meta.cs b/src/WireMock.Org.Abstractions/Meta.cs index bab36106..938c6405 100644 --- a/src/WireMock.Org.Abstractions/Meta.cs +++ b/src/WireMock.Org.Abstractions/Meta.cs @@ -4,4 +4,4 @@ namespace WireMock.Org.Abstractions { public int Total { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/NearMiss.cs b/src/WireMock.Org.Abstractions/NearMisses.cs similarity index 75% rename from src/WireMock.Org.Abstractions/NearMiss.cs rename to src/WireMock.Org.Abstractions/NearMisses.cs index 4ea19722..1042eb36 100644 --- a/src/WireMock.Org.Abstractions/NearMiss.cs +++ b/src/WireMock.Org.Abstractions/NearMisses.cs @@ -1,6 +1,6 @@ namespace WireMock.Org.Abstractions { - public class NearMiss + public class NearMisses { /// /// The HTTP request method @@ -18,12 +18,12 @@ namespace WireMock.Org.Abstractions public string AbsoluteUrl { get; set; } /// - /// Header patterns to match against in the <key>: { "<predicate>": "<value>" } form + /// Header patterns to match against in the : { "": "" } form /// public object Headers { get; set; } /// - /// Cookie patterns to match against in the <key>: { "<predicate>": "<value>" } form + /// Cookie patterns to match against in the : { "": "" } form /// public object Cookies { get; set; } @@ -32,4 +32,4 @@ namespace WireMock.Org.Abstractions /// public string Body { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminMappingsFindByMetadataResult.cs b/src/WireMock.Org.Abstractions/PostAdminMappingsFindByMetadataResult.cs new file mode 100644 index 00000000..2c784ab8 --- /dev/null +++ b/src/WireMock.Org.Abstractions/PostAdminMappingsFindByMetadataResult.cs @@ -0,0 +1,9 @@ +namespace WireMock.Org.Abstractions +{ + public class PostAdminMappingsFindByMetadataResult + { + public Mappings Mappings { get; set; } + + public Meta Meta { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminMappingsResult.cs b/src/WireMock.Org.Abstractions/PostAdminMappingsResult.cs new file mode 100644 index 00000000..8ba3bedb --- /dev/null +++ b/src/WireMock.Org.Abstractions/PostAdminMappingsResult.cs @@ -0,0 +1,59 @@ +namespace WireMock.Org.Abstractions +{ + public class PostAdminMappingsResult + { + /// + /// This stub mapping's unique identifier + /// + public string Id { get; set; } + + /// + /// Alias for the id + /// + public string Uuid { get; set; } + + /// + /// The stub mapping's name + /// + public string Name { get; set; } + + public WireMockOrgRequest Request { get; set; } + + public WireMockOrgResponse Response { get; set; } + + /// + /// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default. + /// + public bool Persistent { get; set; } + + /// + /// This stub mapping's priority relative to others. 1 is highest. + /// + public int Priority { get; set; } + + /// + /// The name of the scenario that this stub mapping is part of + /// + public string ScenarioName { get; set; } + + /// + /// The required state of the scenario in order for this stub to be matched. + /// + public string RequiredScenarioState { get; set; } + + /// + /// The new state for the scenario to be updated to after this stub is served. + /// + public string NewScenarioState { get; set; } + + /// + /// A map of the names of post serve action extensions to trigger and their parameters. + /// + public object PostServeActions { get; set; } + + /// + /// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs. + /// + public object Metadata { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminNearMissesRequestPatternResult.cs b/src/WireMock.Org.Abstractions/PostAdminNearMissesRequestPatternResult.cs new file mode 100644 index 00000000..cd14a90a --- /dev/null +++ b/src/WireMock.Org.Abstractions/PostAdminNearMissesRequestPatternResult.cs @@ -0,0 +1,7 @@ +namespace WireMock.Org.Abstractions +{ + public class PostAdminNearMissesRequestPatternResult + { + public NearMisses NearMisses { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminNearMissesRequestResult.cs b/src/WireMock.Org.Abstractions/PostAdminNearMissesRequestResult.cs new file mode 100644 index 00000000..ce899888 --- /dev/null +++ b/src/WireMock.Org.Abstractions/PostAdminNearMissesRequestResult.cs @@ -0,0 +1,7 @@ +namespace WireMock.Org.Abstractions +{ + public class PostAdminNearMissesRequestResult + { + public NearMisses NearMisses { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminRecordingsSnapshotResult.cs b/src/WireMock.Org.Abstractions/PostAdminRecordingsSnapshotResult.cs new file mode 100644 index 00000000..5f3a65a5 --- /dev/null +++ b/src/WireMock.Org.Abstractions/PostAdminRecordingsSnapshotResult.cs @@ -0,0 +1,9 @@ +namespace WireMock.Org.Abstractions +{ + public class PostAdminRecordingsSnapshotResult + { + public Mappings Mappings { get; set; } + + public Meta Meta { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminRecordingsStopResult.cs b/src/WireMock.Org.Abstractions/PostAdminRecordingsStopResult.cs new file mode 100644 index 00000000..5a1d8067 --- /dev/null +++ b/src/WireMock.Org.Abstractions/PostAdminRecordingsStopResult.cs @@ -0,0 +1,9 @@ +namespace WireMock.Org.Abstractions +{ + public class PostAdminRecordingsStopResult + { + public Mappings Mappings { get; set; } + + public Meta Meta { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PostAdminRequestsCountResponse.cs b/src/WireMock.Org.Abstractions/PostAdminRequestsCountResult.cs similarity index 64% rename from src/WireMock.Org.Abstractions/PostAdminRequestsCountResponse.cs rename to src/WireMock.Org.Abstractions/PostAdminRequestsCountResult.cs index 4043f54e..d8c36dde 100644 --- a/src/WireMock.Org.Abstractions/PostAdminRequestsCountResponse.cs +++ b/src/WireMock.Org.Abstractions/PostAdminRequestsCountResult.cs @@ -1,7 +1,7 @@ namespace WireMock.Org.Abstractions { - public class PostAdminRequestsCountResponse + public class PostAdminRequestsCountResult { public int Count { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/PutAdminMappingsByStubMappingIdResult.cs b/src/WireMock.Org.Abstractions/PutAdminMappingsByStubMappingIdResult.cs new file mode 100644 index 00000000..166e2046 --- /dev/null +++ b/src/WireMock.Org.Abstractions/PutAdminMappingsByStubMappingIdResult.cs @@ -0,0 +1,59 @@ +namespace WireMock.Org.Abstractions +{ + public class PutAdminMappingsByStubMappingIdResult + { + /// + /// This stub mapping's unique identifier + /// + public string Id { get; set; } + + /// + /// Alias for the id + /// + public string Uuid { get; set; } + + /// + /// The stub mapping's name + /// + public string Name { get; set; } + + public WireMockOrgRequest Request { get; set; } + + public WireMockOrgResponse Response { get; set; } + + /// + /// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default. + /// + public bool Persistent { get; set; } + + /// + /// This stub mapping's priority relative to others. 1 is highest. + /// + public int Priority { get; set; } + + /// + /// The name of the scenario that this stub mapping is part of + /// + public string ScenarioName { get; set; } + + /// + /// The required state of the scenario in order for this stub to be matched. + /// + public string RequiredScenarioState { get; set; } + + /// + /// The new state for the scenario to be updated to after this stub is served. + /// + public string NewScenarioState { get; set; } + + /// + /// A map of the names of post serve action extensions to trigger and their parameters. + /// + public object PostServeActions { get; set; } + + /// + /// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs. + /// + public object Metadata { get; set; } + } +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/Request.cs b/src/WireMock.Org.Abstractions/Request.cs index 33e896fe..a76beb34 100644 --- a/src/WireMock.Org.Abstractions/Request.cs +++ b/src/WireMock.Org.Abstractions/Request.cs @@ -1,6 +1,6 @@ namespace WireMock.Org.Abstractions { - public class Request + public class WireMockOrgRequest { /// /// The HTTP request method e.g. GET @@ -28,28 +28,28 @@ namespace WireMock.Org.Abstractions public string UrlPattern { get; set; } /// - /// Query parameter patterns to match against in the <key>: { "<predicate>": "<value>" } form + /// Query parameter patterns to match against in the : { "": "" } form /// public object QueryParameters { get; set; } /// - /// Header patterns to match against in the <key>: { "<predicate>": "<value>" } form + /// Header patterns to match against in the : { "": "" } form /// public object Headers { get; set; } /// /// Pre-emptive basic auth credentials to match against /// - public BasicAuthCredentials BasicAuthCredentials { get; set; } + public RequestBasicAuthCredentials BasicAuthCredentials { get; set; } /// - /// Cookie patterns to match against in the <key>: { "<predicate>": "<value>" } form + /// Cookie patterns to match against in the : { "": "" } form /// public object Cookies { get; set; } /// - /// Request body patterns to match against in the <key>: { "<predicate>": "<value>" } form + /// Request body patterns to match against in the : { "": "" } form /// public object[] BodyPatterns { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/BasicAuthCredentials.cs b/src/WireMock.Org.Abstractions/RequestBasicAuthCredentials.cs similarity index 83% rename from src/WireMock.Org.Abstractions/BasicAuthCredentials.cs rename to src/WireMock.Org.Abstractions/RequestBasicAuthCredentials.cs index c66476eb..57a82c5e 100644 --- a/src/WireMock.Org.Abstractions/BasicAuthCredentials.cs +++ b/src/WireMock.Org.Abstractions/RequestBasicAuthCredentials.cs @@ -3,10 +3,10 @@ namespace WireMock.Org.Abstractions /// /// Pre-emptive basic auth credentials to match against /// - public class BasicAuthCredentials + public class RequestBasicAuthCredentials { public string Password { get; set; } public string Username { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/Response.cs b/src/WireMock.Org.Abstractions/Response.cs index d15e5b91..d6d91b0f 100644 --- a/src/WireMock.Org.Abstractions/Response.cs +++ b/src/WireMock.Org.Abstractions/Response.cs @@ -1,6 +1,6 @@ namespace WireMock.Org.Abstractions { - public class Response + public class WireMockOrgResponse { /// /// The HTTP status code to be returned @@ -52,6 +52,11 @@ namespace WireMock.Org.Abstractions /// public int FixedDelayMilliseconds { get; set; } + /// + /// The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper. + /// + public object DelayDistribution { get; set; } + /// /// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise. /// @@ -70,6 +75,6 @@ namespace WireMock.Org.Abstractions /// /// List of names of transformers to apply to this response. /// - public string Transformers { get; set; } + public string[] Transformers { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/ResponseFaultConstants.cs b/src/WireMock.Org.Abstractions/ResponseFaultConstants.cs new file mode 100644 index 00000000..85c9f9d5 --- /dev/null +++ b/src/WireMock.Org.Abstractions/ResponseFaultConstants.cs @@ -0,0 +1,16 @@ +namespace WireMock.Org.Abstractions +{ + /// + /// The fault to apply (instead of a full, valid response). + /// + 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"; + } +} diff --git a/src/WireMock.Org.Abstractions/ResponseLogNormal.cs b/src/WireMock.Org.Abstractions/ResponseLogNormal.cs deleted file mode 100644 index cce37656..00000000 --- a/src/WireMock.Org.Abstractions/ResponseLogNormal.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace WireMock.Org.Abstractions -{ - /// - /// Log normal randomly distributed response delay. - /// - public class ResponseLogNormal - { - public int Median { get; set; } - - public double Sigma { get; set; } - - public string Type { get; set; } - } -} diff --git a/src/WireMock.Org.Abstractions/ResponseLogUniformlyDistributed.cs b/src/WireMock.Org.Abstractions/ResponseLogUniformlyDistributed.cs deleted file mode 100644 index 1b65bcde..00000000 --- a/src/WireMock.Org.Abstractions/ResponseLogUniformlyDistributed.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace WireMock.Org.Abstractions -{ - /// - /// Uniformly distributed random response delay. - /// - public class ResponseLogUniformlyDistributed - { - public int Lower { get; set; } - - public string Type { get; set; } - - public int Upper { get; set; } - } -} diff --git a/src/WireMock.Org.Abstractions/Scenario.cs b/src/WireMock.Org.Abstractions/Scenarios.cs similarity index 70% rename from src/WireMock.Org.Abstractions/Scenario.cs rename to src/WireMock.Org.Abstractions/Scenarios.cs index 48456e33..bcb57e52 100644 --- a/src/WireMock.Org.Abstractions/Scenario.cs +++ b/src/WireMock.Org.Abstractions/Scenarios.cs @@ -1,6 +1,6 @@ namespace WireMock.Org.Abstractions { - public class Scenario + public class Scenarios { /// /// The scenario ID @@ -12,11 +12,14 @@ namespace WireMock.Org.Abstractions /// public string Name { get; set; } - public string PossibleStates { get; set; } + /// + /// All the states this scenario can be in + /// + public string[] PossibleStates { get; set; } /// /// The current state of this scenario /// public string State { get; set; } } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.Abstractions/StatusConstants.cs b/src/WireMock.Org.Abstractions/StatusConstants.cs new file mode 100644 index 00000000..830105b1 --- /dev/null +++ b/src/WireMock.Org.Abstractions/StatusConstants.cs @@ -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"; + } +} diff --git a/src/WireMock.Org.Abstractions/wiremock.org.json b/src/WireMock.Org.Abstractions/wiremock.org.json deleted file mode 100644 index 3acd1392..00000000 --- a/src/WireMock.Org.Abstractions/wiremock.org.json +++ /dev/null @@ -1,6332 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "WireMock", - "version": "2.31.0" - }, - "externalDocs": { - "description": "WireMock user documentation", - "url": "http://wiremock.org/docs/" - }, - "servers": [ - { - "url": "/" - } - ], - "tags": [ - { - "name": "Stub Mappings", - "description": "Operations on stub mappings", - "externalDocs": { - "description": "User documentation", - "url": "http://wiremock.org/docs/stubbing/" - } - }, - { - "name": "Requests", - "description": "Logged requests and responses received by the mock service", - "externalDocs": { - "description": "User documentation", - "url": "http://wiremock.org/docs/verifying/" - } - }, - { - "name": "Near Misses", - "description": "Near misses allow querying of received requests or request patterns according to similarity", - "externalDocs": { - "description": "User documentation", - "url": "http://wiremock.org/docs/verifying/#near-misses" - } - }, - { - "name": "Recordings", - "description": "Stub mapping record and snapshot functions", - "externalDocs": { - "description": "User documentation", - "url": "http://wiremock.org/docs/record-playback/" - } - }, - { - "name": "Scenarios", - "description": "Scenarios support modelling of stateful behaviour", - "externalDocs": { - "description": "User documentation", - "url": "http://wiremock.org/docs/stateful-behaviour/" - } - }, - { - "name": "System", - "description": "Global operations" - } - ], - "paths": { - "/__admin/mappings": { - "get": { - "summary": "Get all stub mappings", - "tags": [ - "Stub Mappings" - ], - "parameters": [ - { - "description": "The maximum number of results to return", - "in": "query", - "name": "limit", - "required": false, - "example": 10, - "schema": { - "type": "integer" - } - }, - { - "description": "The start index of the results to return", - "in": "query", - "name": "offset", - "required": false, - "example": 0, - "schema": { - "type": "integer" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "mappings": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - } - }, - "meta": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "example": 4 - } - }, - "required": [ - "total" - ] - } - } - }, - "example": { - "meta": { - "total": 2 - }, - "mappings": [ - { - "id": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "uuid": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "request": { - "method": "GET", - "url": "/search?q=things", - "headers": { - "Accept": { - "equalTo": "application/json" - } - } - }, - "response": { - "status": 200, - "jsonBody": [ - "thing1", - "thing2" - ], - "headers": { - "Content-Type": "application/json" - } - } - }, - { - "request": { - "method": "POST", - "urlPath": "/some/things", - "bodyPatterns": [ - { - "equalToXml": "" - } - ] - }, - "response": { - "status": 201 - } - } - ] - } - } - }, - "description": "All stub mappings" - } - } - }, - "post": { - "summary": "Create a new stub mapping", - "tags": [ - "Stub Mappings" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "request": { - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - }, - "responses": { - "201": { - "description": "The stub mapping", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "id": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "priority": 3, - "request": { - "headers": { - "Accept": { - "equalTo": "text/plain" - } - }, - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - } - } - }, - "delete": { - "summary": "Delete all stub mappings", - "tags": [ - "Stub Mappings" - ], - "responses": { - "200": { - "description": "Successfully deleted" - } - } - } - }, - "/__admin/mappings/reset": { - "post": { - "summary": "Reset stub mappings", - "description": "Restores stub mappings to the defaults defined back in the backing store", - "tags": [ - "Stub Mappings" - ], - "responses": { - "200": { - "description": "Successfully reset" - } - } - } - }, - "/__admin/mappings/save": { - "post": { - "summary": "Persist stub mappings", - "description": "Save all persistent stub mappings to the backing store", - "tags": [ - "Stub Mappings" - ], - "responses": { - "200": { - "description": "Successfully saved" - } - } - } - }, - "/__admin/mappings/{stubMappingId}": { - "parameters": [ - { - "description": "The UUID of stub mapping", - "in": "path", - "name": "stubMappingId", - "required": true, - "example": "730d3e32-d098-4169-a20c-554c3bedce58", - "schema": { - "type": "string" - } - } - ], - "get": { - "summary": "Get stub mapping by ID", - "tags": [ - "Stub Mappings" - ], - "responses": { - "200": { - "description": "The stub mapping", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "id": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "priority": 3, - "request": { - "headers": { - "Accept": { - "equalTo": "text/plain" - } - }, - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - }, - "404": { - "description": "Stub mapping not found" - } - } - }, - "put": { - "summary": "Update a stub mapping", - "tags": [ - "Stub Mappings" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "request": { - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - }, - "responses": { - "200": { - "description": "The stub mapping", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "id": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "priority": 3, - "request": { - "headers": { - "Accept": { - "equalTo": "text/plain" - } - }, - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - }, - "404": { - "description": "Stub mapping not found" - } - } - }, - "delete": { - "summary": "Delete a stub mapping", - "tags": [ - "Stub Mappings" - ], - "responses": { - "200": { - "description": "OK" - }, - "404": { - "description": "Stub mapping not found" - } - } - } - }, - "/__admin/mappings/find-by-metadata": { - "post": { - "description": "Find stubs by matching on their metadata", - "tags": [ - "Stub Mappings" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "oneOf": [ - { - "title": "String equals", - "type": "object", - "properties": { - "equalTo": { - "type": "boolean" - }, - "caseInsensitive": { - "type": "boolean" - } - }, - "required": [ - "equalTo" - ] - }, - { - "title": "String contains", - "type": "object", - "properties": { - "contains": { - "type": "string" - } - }, - "required": [ - "contains" - ] - }, - { - "title": "Regular expression match", - "type": "object", - "properties": { - "matches": { - "type": "string" - } - }, - "required": [ - "matches" - ] - }, - { - "title": "Negative regular expression match", - "type": "object", - "properties": { - "doesNotMatch": { - "type": "string" - } - }, - "required": [ - "doesNotMatch" - ] - }, - { - "title": "JSON equals", - "type": "object", - "properties": { - "equalToJson": { - "type": "string" - } - }, - "required": [ - "equalToJson" - ] - }, - { - "title": "JSONPath match", - "type": "object", - "properties": { - "matchesJsonPath": { - "type": "string" - }, - "ignoreArrayOrder": { - "type": "boolean" - }, - "ignoreExtraElements": { - "type": "boolean" - } - }, - "required": [ - "matchesJsonPath" - ] - }, - { - "title": "XML equality", - "type": "object", - "properties": { - "equalToXml": { - "type": "string" - } - }, - "required": [ - "equalToXml" - ] - }, - { - "title": "XPath match", - "type": "object", - "properties": { - "matchesXpath": { - "type": "string" - }, - "namespaces": { - "type": "object" - }, - "valuePattern": { - "type": "object" - } - }, - "required": [ - "matchesXpath" - ] - } - ] - }, - "example": { - "matchesJsonPath": { - "expression": "$.outer", - "equalToJson": "{ \"inner\": 42 }" - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "mappings": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - } - }, - "meta": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "example": 4 - } - }, - "required": [ - "total" - ] - } - } - }, - "example": { - "meta": { - "total": 2 - }, - "mappings": [ - { - "id": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "uuid": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "request": { - "method": "GET", - "url": "/search?q=things", - "headers": { - "Accept": { - "equalTo": "application/json" - } - } - }, - "response": { - "status": 200, - "jsonBody": [ - "thing1", - "thing2" - ], - "headers": { - "Content-Type": "application/json" - } - } - }, - { - "request": { - "method": "POST", - "urlPath": "/some/things", - "bodyPatterns": [ - { - "equalToXml": "" - } - ] - }, - "response": { - "status": 201 - } - } - ] - } - } - }, - "description": "Matched stub mappings" - } - } - } - }, - "/__admin/mappings/remove-by-metadata": { - "post": { - "summary": "Delete stub mappings matching metadata", - "tags": [ - "Stub Mappings" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "oneOf": [ - { - "title": "String equals", - "type": "object", - "properties": { - "equalTo": { - "type": "boolean" - }, - "caseInsensitive": { - "type": "boolean" - } - }, - "required": [ - "equalTo" - ] - }, - { - "title": "String contains", - "type": "object", - "properties": { - "contains": { - "type": "string" - } - }, - "required": [ - "contains" - ] - }, - { - "title": "Regular expression match", - "type": "object", - "properties": { - "matches": { - "type": "string" - } - }, - "required": [ - "matches" - ] - }, - { - "title": "Negative regular expression match", - "type": "object", - "properties": { - "doesNotMatch": { - "type": "string" - } - }, - "required": [ - "doesNotMatch" - ] - }, - { - "title": "JSON equals", - "type": "object", - "properties": { - "equalToJson": { - "type": "string" - } - }, - "required": [ - "equalToJson" - ] - }, - { - "title": "JSONPath match", - "type": "object", - "properties": { - "matchesJsonPath": { - "type": "string" - }, - "ignoreArrayOrder": { - "type": "boolean" - }, - "ignoreExtraElements": { - "type": "boolean" - } - }, - "required": [ - "matchesJsonPath" - ] - }, - { - "title": "XML equality", - "type": "object", - "properties": { - "equalToXml": { - "type": "string" - } - }, - "required": [ - "equalToXml" - ] - }, - { - "title": "XPath match", - "type": "object", - "properties": { - "matchesXpath": { - "type": "string" - }, - "namespaces": { - "type": "object" - }, - "valuePattern": { - "type": "object" - } - }, - "required": [ - "matchesXpath" - ] - } - ] - }, - "example": { - "matchesJsonPath": { - "expression": "$.outer", - "equalToJson": "{ \"inner\": 42 }" - } - } - } - } - }, - "responses": { - "200": { - "description": "The stub mappings were successfully removed" - } - } - } - }, - "/__admin/requests": { - "get": { - "summary": "Get all requests in journal", - "tags": [ - "Requests" - ], - "parameters": [ - { - "description": "The maximum number of results to return", - "in": "query", - "name": "limit", - "example": 10, - "schema": { - "type": "string" - } - }, - { - "description": "Only return logged requests after this date", - "in": "query", - "name": "since", - "example": "2016-10-05T12:33:01.000Z", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "content": { - "application/json": { - "example": { - "requests": [ - { - "id": "45760a03-eebb-4387-ad0d-bb89b5d3d662", - "request": { - "url": "/received-request/9", - "absoluteUrl": "http://localhost:56715/received-request/9", - "method": "GET", - "clientIp": "127.0.0.1", - "headers": { - "Connection": "keep-alive", - "Host": "localhost:56715", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1471442494809, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-08-17T14:01:34Z" - }, - "responseDefinition": { - "status": 404, - "transformers": [], - "fromConfiguredStub": false, - "transformerParameters": {} - } - }, - { - "id": "6ae78311-0178-46c9-987a-fbfc528d54d8", - "request": { - "url": "/received-request/8", - "absoluteUrl": "http://localhost:56715/received-request/8", - "method": "GET", - "clientIp": "127.0.0.1", - "headers": { - "Connection": "keep-alive", - "Host": "localhost:56715", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1471442494802, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-08-17T14:01:34Z" - }, - "responseDefinition": { - "status": 404, - "transformers": [], - "fromConfiguredStub": false, - "transformerParameters": {} - } - }, - { - "id": "aba8e4ad-1b5b-4518-8f05-b2170a24de35", - "request": { - "url": "/received-request/7", - "absoluteUrl": "http://localhost:56715/received-request/7", - "method": "GET", - "clientIp": "127.0.0.1", - "headers": { - "Connection": "keep-alive", - "Host": "localhost:56715", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1471442494795, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-08-17T14:01:34Z" - }, - "responseDefinition": { - "status": 404, - "transformers": [], - "fromConfiguredStub": false, - "transformerParameters": {} - } - } - ], - "meta": { - "total": 9 - }, - "requestJournalDisabled": false - } - } - }, - "description": "List of received requests" - } - } - }, - "delete": { - "summary": "Delete all requests in journal", - "tags": [ - "Requests" - ], - "responses": { - "200": { - "description": "Successfully deleted" - } - } - } - }, - "/__admin/requests/{requestId}": { - "get": { - "summary": "Get request by ID", - "tags": [ - "Requests" - ], - "parameters": [ - { - "description": "The UUID of the logged request", - "in": "path", - "name": "requestId", - "required": true, - "example": "12fb14bb-600e-4bfa-bd8d-be7f12562c99", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "example": { - "id": "12fb14bb-600e-4bfa-bd8d-be7f12562c99", - "request": { - "url": "/received-request/2", - "absoluteUrl": "http://localhost:56738/received-request/2", - "method": "GET", - "clientIp": "127.0.0.1", - "headers": { - "Connection": "keep-alive", - "Host": "localhost:56738", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1471442557047, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-08-17T14:02:37Z" - }, - "responseDefinition": { - "status": 404, - "transformers": [], - "fromConfiguredStub": false, - "transformerParameters": {} - } - } - } - } - }, - "404": { - "description": "Request not found" - } - } - }, - "delete": { - "summary": "Delete request by ID", - "tags": [ - "Requests" - ], - "parameters": [ - { - "description": "The UUID of the logged request", - "in": "path", - "name": "requestId", - "required": true, - "example": "12fb14bb-600e-4bfa-bd8d-be7f12562c99", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Successfully deleted" - } - } - } - }, - "/__admin/requests/reset": { - "post": { - "deprecated": true, - "summary": "Empty the request journal", - "tags": [ - "Requests" - ], - "responses": { - "200": { - "description": "Successfully reset" - } - } - } - }, - "/__admin/requests/count": { - "post": { - "summary": "Count requests by criteria", - "description": "Count requests logged in the journal matching the specified criteria", - "tags": [ - "Requests" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "example": { - "method": "POST", - "url": "/resource", - "headers": { - "Content-Type": { - "matches": ".*/xml" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Number of matching requests", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "count": { - "type": "integer", - "example": 4 - } - } - } - } - } - } - } - } - }, - "/__admin/requests/remove": { - "post": { - "summary": "Remove requests by criteria", - "description": "Removed requests logged in the journal matching the specified criteria", - "tags": [ - "Requests" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "example": { - "method": "POST", - "url": "/resource", - "headers": { - "Content-Type": { - "matches": ".*/xml" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Removed request details", - "content": { - "application/json": { - "example": { - "requests": [ - { - "url": "/my/url", - "absoluteUrl": "http://mydomain.com/my/url", - "method": "GET", - "headers": { - "Accept-Language": "en-us,en;q=0.5", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0", - "Accept": "image/png,image/*;q=0.8,*/*;q=0.5" - }, - "body": "", - "browserProxyRequest": true, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - }, - { - "url": "/my/other/url", - "absoluteUrl": "http://my.other.domain.com/my/other/url", - "method": "POST", - "headers": { - "Accept": "text/plain", - "Content-Type": "text/plain" - }, - "body": "My text", - "browserProxyRequest": false, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - } - ] - } - } - } - } - } - } - }, - "/__admin/requests/remove-by-metadata": { - "post": { - "summary": "Delete requests mappings matching metadata", - "tags": [ - "Requests" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "oneOf": [ - { - "title": "String equals", - "type": "object", - "properties": { - "equalTo": { - "type": "boolean" - }, - "caseInsensitive": { - "type": "boolean" - } - }, - "required": [ - "equalTo" - ] - }, - { - "title": "String contains", - "type": "object", - "properties": { - "contains": { - "type": "string" - } - }, - "required": [ - "contains" - ] - }, - { - "title": "Regular expression match", - "type": "object", - "properties": { - "matches": { - "type": "string" - } - }, - "required": [ - "matches" - ] - }, - { - "title": "Negative regular expression match", - "type": "object", - "properties": { - "doesNotMatch": { - "type": "string" - } - }, - "required": [ - "doesNotMatch" - ] - }, - { - "title": "JSON equals", - "type": "object", - "properties": { - "equalToJson": { - "type": "string" - } - }, - "required": [ - "equalToJson" - ] - }, - { - "title": "JSONPath match", - "type": "object", - "properties": { - "matchesJsonPath": { - "type": "string" - }, - "ignoreArrayOrder": { - "type": "boolean" - }, - "ignoreExtraElements": { - "type": "boolean" - } - }, - "required": [ - "matchesJsonPath" - ] - }, - { - "title": "XML equality", - "type": "object", - "properties": { - "equalToXml": { - "type": "string" - } - }, - "required": [ - "equalToXml" - ] - }, - { - "title": "XPath match", - "type": "object", - "properties": { - "matchesXpath": { - "type": "string" - }, - "namespaces": { - "type": "object" - }, - "valuePattern": { - "type": "object" - } - }, - "required": [ - "matchesXpath" - ] - } - ] - }, - "example": { - "matchesJsonPath": { - "expression": "$.outer", - "equalToJson": "{ \"inner\": 42 }" - } - } - } - } - }, - "responses": { - "200": { - "description": "Removed request details", - "content": { - "application/json": { - "example": { - "requests": [ - { - "url": "/my/url", - "absoluteUrl": "http://mydomain.com/my/url", - "method": "GET", - "headers": { - "Accept-Language": "en-us,en;q=0.5", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0", - "Accept": "image/png,image/*;q=0.8,*/*;q=0.5" - }, - "body": "", - "browserProxyRequest": true, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - }, - { - "url": "/my/other/url", - "absoluteUrl": "http://my.other.domain.com/my/other/url", - "method": "POST", - "headers": { - "Accept": "text/plain", - "Content-Type": "text/plain" - }, - "body": "My text", - "browserProxyRequest": false, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - } - ] - } - } - } - } - } - } - }, - "/__admin/requests/find": { - "post": { - "summary": "Find requests by criteria", - "description": "Retrieve details of requests logged in the journal matching the specified criteria", - "tags": [ - "Requests" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "example": { - "method": "POST", - "url": "/resource", - "headers": { - "Content-Type": { - "matches": ".*/xml" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Matching request details", - "content": { - "application/json": { - "example": { - "requests": [ - { - "url": "/my/url", - "absoluteUrl": "http://mydomain.com/my/url", - "method": "GET", - "headers": { - "Accept-Language": "en-us,en;q=0.5", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0", - "Accept": "image/png,image/*;q=0.8,*/*;q=0.5" - }, - "body": "", - "browserProxyRequest": true, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - }, - { - "url": "/my/other/url", - "absoluteUrl": "http://my.other.domain.com/my/other/url", - "method": "POST", - "headers": { - "Accept": "text/plain", - "Content-Type": "text/plain" - }, - "body": "My text", - "browserProxyRequest": false, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - } - ] - } - } - } - } - } - } - }, - "/__admin/requests/unmatched": { - "get": { - "summary": "Find unmatched requests", - "description": "Get details of logged requests that weren't matched by any stub mapping", - "tags": [ - "Requests" - ], - "responses": { - "200": { - "description": "Unmatched request details", - "content": { - "application/json": { - "example": { - "requests": [ - { - "url": "/my/url", - "absoluteUrl": "http://mydomain.com/my/url", - "method": "GET", - "headers": { - "Accept-Language": "en-us,en;q=0.5", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0) Gecko/20100101 Firefox/9.0", - "Accept": "image/png,image/*;q=0.8,*/*;q=0.5" - }, - "body": "", - "browserProxyRequest": true, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - }, - { - "url": "/my/other/url", - "absoluteUrl": "http://my.other.domain.com/my/other/url", - "method": "POST", - "headers": { - "Accept": "text/plain", - "Content-Type": "text/plain" - }, - "body": "My text", - "browserProxyRequest": false, - "loggedDate": 1339083581823, - "loggedDateString": "2012-06-07 16:39:41" - } - ] - } - } - } - } - } - } - }, - "/__admin/requests/unmatched/near-misses": { - "get": { - "description": "Retrieve near-misses for all unmatched requests", - "tags": [ - "Near Misses" - ], - "responses": { - "200": { - "description": "Near misses matching criteria", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "nearMisses": { - "type": "array", - "items": { - "type": "object", - "properties": { - "method": { - "description": "The HTTP request method", - "type": "string", - "example": "GET" - }, - "url": { - "description": "The path and query to match exactly against", - "type": "string", - "example": "/received-request/2" - }, - "absoluteUrl": { - "description": "The full URL to match against", - "type": "string", - "example": "http://localhost:56738/received-request/2" - }, - "headers": { - "description": "Header patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": { - "Connection": "keep-alive", - "Host": "localhost:56738", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - } - }, - "cookies": { - "description": "Cookie patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": {} - }, - "body": { - "description": "Body string to match against", - "type": "string", - "example": "Hello world" - } - } - } - } - } - }, - "example": { - "nearMisses": [ - { - "request": { - "url": "/nomatch", - "absoluteUrl": "http://localhost:8080/nomatch", - "method": "GET", - "clientIp": "0:0:0:0:0:0:0:1", - "headers": { - "User-Agent": "curl/7.30.0", - "Accept": "*/*", - "Host": "localhost:8080" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1467402464520, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-07-01T19:47:44Z" - }, - "requestPattern": { - "url": "/almostmatch", - "method": "GET" - }, - "matchResult": { - "distance": 0.06944444444444445 - } - } - ] - } - } - } - } - } - } - }, - "/__admin/near-misses/request": { - "post": { - "summary": "Find near misses matching specific request", - "description": "Find at most 3 near misses for closest stub mappings to the specified request", - "tags": [ - "Near Misses" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "method": { - "description": "The HTTP request method", - "type": "string", - "example": "GET" - }, - "url": { - "description": "The path and query to match exactly against", - "type": "string", - "example": "/received-request/2" - }, - "absoluteUrl": { - "description": "The full URL to match against", - "type": "string", - "example": "http://localhost:56738/received-request/2" - }, - "headers": { - "description": "Header patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": { - "Connection": "keep-alive", - "Host": "localhost:56738", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - } - }, - "cookies": { - "description": "Cookie patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": {} - }, - "body": { - "description": "Body string to match against", - "type": "string", - "example": "Hello world" - } - } - }, - "example": { - "url": "/actual", - "absoluteUrl": "http://localhost:8080/actual", - "method": "GET", - "clientIp": "0:0:0:0:0:0:0:1", - "headers": { - "User-Agent": "curl/7.30.0", - "Accept": "*/*", - "Host": "localhost:8080" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1467402464520, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-07-01T19:47:44Z" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Near misses matching criteria", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "nearMisses": { - "type": "array", - "items": { - "type": "object", - "properties": { - "method": { - "description": "The HTTP request method", - "type": "string", - "example": "GET" - }, - "url": { - "description": "The path and query to match exactly against", - "type": "string", - "example": "/received-request/2" - }, - "absoluteUrl": { - "description": "The full URL to match against", - "type": "string", - "example": "http://localhost:56738/received-request/2" - }, - "headers": { - "description": "Header patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": { - "Connection": "keep-alive", - "Host": "localhost:56738", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - } - }, - "cookies": { - "description": "Cookie patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": {} - }, - "body": { - "description": "Body string to match against", - "type": "string", - "example": "Hello world" - } - } - } - } - } - }, - "example": { - "nearMisses": [ - { - "request": { - "url": "/nomatch", - "absoluteUrl": "http://localhost:8080/nomatch", - "method": "GET", - "clientIp": "0:0:0:0:0:0:0:1", - "headers": { - "User-Agent": "curl/7.30.0", - "Accept": "*/*", - "Host": "localhost:8080" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1467402464520, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-07-01T19:47:44Z" - }, - "requestPattern": { - "url": "/almostmatch", - "method": "GET" - }, - "matchResult": { - "distance": 0.06944444444444445 - } - } - ] - } - } - } - } - } - } - }, - "/__admin/near-misses/request-pattern": { - "post": { - "summary": "Find near misses matching request pattern", - "description": "Find at most 3 near misses for closest logged requests to the specified request pattern", - "tags": [ - "Near Misses" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "example": { - "method": "POST", - "url": "/resource", - "headers": { - "Content-Type": { - "matches": ".*/xml" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Near misses matching criteria", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "nearMisses": { - "type": "array", - "items": { - "type": "object", - "properties": { - "method": { - "description": "The HTTP request method", - "type": "string", - "example": "GET" - }, - "url": { - "description": "The path and query to match exactly against", - "type": "string", - "example": "/received-request/2" - }, - "absoluteUrl": { - "description": "The full URL to match against", - "type": "string", - "example": "http://localhost:56738/received-request/2" - }, - "headers": { - "description": "Header patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": { - "Connection": "keep-alive", - "Host": "localhost:56738", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - } - }, - "cookies": { - "description": "Cookie patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": {} - }, - "body": { - "description": "Body string to match against", - "type": "string", - "example": "Hello world" - } - } - } - } - } - }, - "example": { - "nearMisses": [ - { - "request": { - "url": "/nomatch", - "absoluteUrl": "http://localhost:8080/nomatch", - "method": "GET", - "clientIp": "0:0:0:0:0:0:0:1", - "headers": { - "User-Agent": "curl/7.30.0", - "Accept": "*/*", - "Host": "localhost:8080" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1467402464520, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-07-01T19:47:44Z" - }, - "requestPattern": { - "url": "/almostmatch", - "method": "GET" - }, - "matchResult": { - "distance": 0.06944444444444445 - } - } - ] - } - } - } - } - } - } - }, - "/__admin/recordings/start": { - "post": { - "summary": "Start recording", - "description": "Begin recording stub mappings", - "tags": [ - "Recordings" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "type": "object", - "properties": { - "captureHeaders": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": false, - "properties": { - "caseInsensitive": { - "type": "boolean" - } - } - }, - "description": "Headers from the request to include in the generated stub mappings, mapped to parameter objects. The only parameter available is \"caseInsensitive\", which defaults to false", - "example": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - } - }, - "extractBodyCriteria": { - "type": "object", - "description": "Criteria for extracting response bodies to a separate file instead of including it in the stub mapping", - "example": [ - { - "binarySizeThreshold": "1 Mb", - "textSizeThreshold": "2 kb" - } - ], - "properties": { - "binarySizeThreshold": { - "type": "string", - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB" - }, - "textSizeThreshold": { - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB", - "type": "string" - } - } - }, - "persist": { - "type": "boolean", - "default": true, - "description": "Whether to save stub mappings to the file system or just return them" - }, - "repeatsAsScenarios": { - "type": "boolean", - "default": true, - "description": "When true, duplicate requests will be added to a Scenario. When false, duplicates are discarded" - }, - "requestBodyPattern": { - "type": "object", - "description": "Control the request body matcher used in generated stub mappings", - "oneOf": [ - { - "type": "object", - "description": "Automatically determine matcher based on content type (the default)", - "properties": { - "caseInsensitive": { - "type": "boolean", - "default": false, - "description": "If equalTo is used, match body use case-insensitive string comparison" - }, - "ignoreArrayOrder": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, ignore order of array elements" - }, - "ignoreExtraElements": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, matcher ignores extra elements in objects" - }, - "matcher": { - "type": "string", - "enum": [ - "auto" - ] - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalTo", - "properties": { - "caseInsensitive": { - "default": false, - "description": "Match body using case-insensitive string comparison", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalTo" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToJson", - "properties": { - "ignoreArrayOrder": { - "default": true, - "description": "Ignore order of array elements", - "type": "boolean" - }, - "ignoreExtraElements": { - "default": true, - "description": "Ignore extra elements in objects", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalToJson" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToXml", - "properties": { - "matcher": { - "type": "string", - "enum": [ - "equalToXml" - ] - } - } - } - ] - }, - "transformerParameters": { - "type": "object", - "description": "List of names of stub mappings transformers to apply to generated stubs" - }, - "transformers": { - "type": "array", - "description": "Parameters to pass to stub mapping transformers", - "items": { - "type": "string" - } - } - } - }, - { - "properties": { - "filters": { - "allOf": [ - { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - { - "description": "Filter requests for which to create stub mapping" - } - ] - }, - "targetBaseUrl": { - "type": "string", - "description": "Target URL when using the record and playback API", - "example": "http://example.mocklab.io" - } - } - } - ] - }, - "example": { - "targetBaseUrl": "http://example.mocklab.io", - "filters": { - "urlPathPattern": "/api/.*", - "method": "GET" - }, - "captureHeaders": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - }, - "requestBodyPattern": { - "matcher": "equalToJson", - "ignoreArrayOrder": false, - "ignoreExtraElements": true - }, - "extractBodyCriteria": { - "textSizeThreshold": "2048", - "binarySizeThreshold": "10240" - }, - "persist": false, - "repeatsAsScenarios": false, - "transformers": [ - "modify-response-header" - ], - "transformerParameters": { - "headerValue": "123" - } - } - } - } - }, - "responses": { - "200": { - "description": "Successfully started recording" - } - } - } - }, - "/__admin/recordings/stop": { - "post": { - "summary": "Stop recording", - "description": "End recording of stub mappings", - "tags": [ - "Recordings" - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "mappings": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - } - }, - "meta": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "example": 4 - } - }, - "required": [ - "total" - ] - } - } - }, - "example": { - "mappings": [ - { - "id": "093f1027-e5e0-4921-9e6d-e619dfd5d2c7", - "name": "recordables_123", - "request": { - "url": "/recordables/123", - "method": "GET" - }, - "response": { - "status": 200, - "body": "{\n \"message\": \"Congratulations on your first recording!\"\n}", - "headers": { - "Content-Type": "application/json" - } - }, - "uuid": "093f1027-e5e0-4921-9e6d-e619dfd5d2c7", - "persistent": true - } - ] - } - } - }, - "description": "Successfully stopped recording" - } - } - } - }, - "/__admin/recordings/status": { - "get": { - "summary": "Get recording status", - "tags": [ - "Recordings" - ], - "responses": { - "200": { - "description": "Successfully got the record status", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "status": { - "type": "string", - "example": "Stopped", - "enum": [ - "NeverStarted", - "Recording", - "Stopped" - ] - } - } - } - } - } - } - } - } - }, - "/__admin/recordings/snapshot": { - "post": { - "summary": "Take a snapshot recording", - "tags": [ - "Recordings" - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "allOf": [ - { - "type": "object", - "properties": { - "captureHeaders": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": false, - "properties": { - "caseInsensitive": { - "type": "boolean" - } - } - }, - "description": "Headers from the request to include in the generated stub mappings, mapped to parameter objects. The only parameter available is \"caseInsensitive\", which defaults to false", - "example": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - } - }, - "extractBodyCriteria": { - "type": "object", - "description": "Criteria for extracting response bodies to a separate file instead of including it in the stub mapping", - "example": [ - { - "binarySizeThreshold": "1 Mb", - "textSizeThreshold": "2 kb" - } - ], - "properties": { - "binarySizeThreshold": { - "type": "string", - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB" - }, - "textSizeThreshold": { - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB", - "type": "string" - } - } - }, - "persist": { - "type": "boolean", - "default": true, - "description": "Whether to save stub mappings to the file system or just return them" - }, - "repeatsAsScenarios": { - "type": "boolean", - "default": true, - "description": "When true, duplicate requests will be added to a Scenario. When false, duplicates are discarded" - }, - "requestBodyPattern": { - "type": "object", - "description": "Control the request body matcher used in generated stub mappings", - "oneOf": [ - { - "type": "object", - "description": "Automatically determine matcher based on content type (the default)", - "properties": { - "caseInsensitive": { - "type": "boolean", - "default": false, - "description": "If equalTo is used, match body use case-insensitive string comparison" - }, - "ignoreArrayOrder": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, ignore order of array elements" - }, - "ignoreExtraElements": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, matcher ignores extra elements in objects" - }, - "matcher": { - "type": "string", - "enum": [ - "auto" - ] - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalTo", - "properties": { - "caseInsensitive": { - "default": false, - "description": "Match body using case-insensitive string comparison", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalTo" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToJson", - "properties": { - "ignoreArrayOrder": { - "default": true, - "description": "Ignore order of array elements", - "type": "boolean" - }, - "ignoreExtraElements": { - "default": true, - "description": "Ignore extra elements in objects", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalToJson" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToXml", - "properties": { - "matcher": { - "type": "string", - "enum": [ - "equalToXml" - ] - } - } - } - ] - }, - "transformerParameters": { - "type": "object", - "description": "List of names of stub mappings transformers to apply to generated stubs" - }, - "transformers": { - "type": "array", - "description": "Parameters to pass to stub mapping transformers", - "items": { - "type": "string" - } - } - } - }, - { - "properties": { - "filters": { - "type": "object", - "allOf": [ - { - "properties": { - "ids": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "type": "object", - "description": "Filter requests for which to create stub mapping" - }, - { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - } - ] - } - } - } - ] - }, - "example": { - "filters": { - "urlPathPattern": "/api/.*", - "method": "GET", - "ids": [ - "40a93c4a-d378-4e07-8321-6158d5dbcb29" - ] - }, - "captureHeaders": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - }, - "requestBodyPattern": { - "matcher": "equalToJson", - "ignoreArrayOrder": false, - "ignoreExtraElements": true - }, - "extractBodyCriteria": { - "textSizeThreshold": "2 kb", - "binarySizeThreshold": "1 Mb" - }, - "outputFormat": "FULL", - "persist": false, - "repeatsAsScenarios": false, - "transformers": [ - "modify-response-header" - ], - "transformerParameters": { - "headerValue": "123" - } - } - } - } - }, - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "mappings": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - } - }, - "meta": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "example": 4 - } - }, - "required": [ - "total" - ] - } - } - }, - "example": { - "mappings": [ - { - "id": "093f1027-e5e0-4921-9e6d-e619dfd5d2c7", - "name": "recordables_123", - "request": { - "url": "/recordables/123", - "method": "GET" - }, - "response": { - "status": 200, - "body": "{\n \"message\": \"Congratulations on your first recording!\"\n}", - "headers": { - "Content-Type": "application/json" - } - }, - "uuid": "093f1027-e5e0-4921-9e6d-e619dfd5d2c7", - "persistent": true - } - ] - } - } - }, - "description": "Successfully took a snapshot recording" - } - } - } - }, - "/__admin/scenarios": { - "get": { - "summary": "Get all scenarios", - "tags": [ - "Scenarios" - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "scenarios": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "The scenario ID", - "example": "c8d249ec-d86d-48b1-88a8-a660e6848042" - }, - "name": { - "type": "string", - "description": "The scenario name", - "example": "my_scenario" - }, - "possibleStates": { - "type": "array", - "items": { - "default": "Started", - "description": "All the states this scenario can be in", - "type": "string" - }, - "example": [ - "Started", - "state_1", - "state_2" - ] - }, - "state": { - "type": "string", - "default": "Started", - "description": "The current state of this scenario", - "example": "state_2" - } - } - } - } - } - } - } - }, - "description": "All scenarios" - } - } - } - }, - "/__admin/scenarios/reset": { - "post": { - "summary": "Reset the state of all scenarios", - "tags": [ - "Scenarios" - ], - "responses": { - "200": { - "description": "Successfully reset" - } - } - } - }, - "/__admin/settings": { - "post": { - "summary": "Update global settings", - "tags": [ - "System" - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "fixedDelay": { - "type": "number" - } - }, - "example": { - "fixedDelay": 500 - } - } - ] - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Settings successfully updated" - } - } - } - }, - "/__admin/reset": { - "post": { - "summary": "Reset mappings and request journal", - "description": "Reset mappings to the default state and reset the request journal", - "tags": [ - "System" - ], - "responses": { - "200": { - "description": "Successfully reset" - } - } - } - }, - "/__admin/shutdown": { - "post": { - "description": "Shutdown the WireMock server", - "tags": [ - "System" - ], - "responses": { - "200": { - "description": "Server will be shut down" - } - } - } - } - }, - "components": { - "requestBodies": { - "requestPattern": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "example": { - "method": "POST", - "url": "/resource", - "headers": { - "Content-Type": { - "matches": ".*/xml" - } - } - } - } - } - }, - "stubMapping": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "request": { - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - }, - "startRecording": { - "required": true, - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "type": "object", - "properties": { - "captureHeaders": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": false, - "properties": { - "caseInsensitive": { - "type": "boolean" - } - } - }, - "description": "Headers from the request to include in the generated stub mappings, mapped to parameter objects. The only parameter available is \"caseInsensitive\", which defaults to false", - "example": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - } - }, - "extractBodyCriteria": { - "type": "object", - "description": "Criteria for extracting response bodies to a separate file instead of including it in the stub mapping", - "example": [ - { - "binarySizeThreshold": "1 Mb", - "textSizeThreshold": "2 kb" - } - ], - "properties": { - "binarySizeThreshold": { - "type": "string", - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB" - }, - "textSizeThreshold": { - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB", - "type": "string" - } - } - }, - "persist": { - "type": "boolean", - "default": true, - "description": "Whether to save stub mappings to the file system or just return them" - }, - "repeatsAsScenarios": { - "type": "boolean", - "default": true, - "description": "When true, duplicate requests will be added to a Scenario. When false, duplicates are discarded" - }, - "requestBodyPattern": { - "type": "object", - "description": "Control the request body matcher used in generated stub mappings", - "oneOf": [ - { - "type": "object", - "description": "Automatically determine matcher based on content type (the default)", - "properties": { - "caseInsensitive": { - "type": "boolean", - "default": false, - "description": "If equalTo is used, match body use case-insensitive string comparison" - }, - "ignoreArrayOrder": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, ignore order of array elements" - }, - "ignoreExtraElements": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, matcher ignores extra elements in objects" - }, - "matcher": { - "type": "string", - "enum": [ - "auto" - ] - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalTo", - "properties": { - "caseInsensitive": { - "default": false, - "description": "Match body using case-insensitive string comparison", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalTo" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToJson", - "properties": { - "ignoreArrayOrder": { - "default": true, - "description": "Ignore order of array elements", - "type": "boolean" - }, - "ignoreExtraElements": { - "default": true, - "description": "Ignore extra elements in objects", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalToJson" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToXml", - "properties": { - "matcher": { - "type": "string", - "enum": [ - "equalToXml" - ] - } - } - } - ] - }, - "transformerParameters": { - "type": "object", - "description": "List of names of stub mappings transformers to apply to generated stubs" - }, - "transformers": { - "type": "array", - "description": "Parameters to pass to stub mapping transformers", - "items": { - "type": "string" - } - } - } - }, - { - "properties": { - "filters": { - "allOf": [ - { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - { - "description": "Filter requests for which to create stub mapping" - } - ] - }, - "targetBaseUrl": { - "type": "string", - "description": "Target URL when using the record and playback API", - "example": "http://example.mocklab.io" - } - } - } - ] - }, - "example": { - "targetBaseUrl": "http://example.mocklab.io", - "filters": { - "urlPathPattern": "/api/.*", - "method": "GET" - }, - "captureHeaders": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - }, - "requestBodyPattern": { - "matcher": "equalToJson", - "ignoreArrayOrder": false, - "ignoreExtraElements": true - }, - "extractBodyCriteria": { - "textSizeThreshold": "2048", - "binarySizeThreshold": "10240" - }, - "persist": false, - "repeatsAsScenarios": false, - "transformers": [ - "modify-response-header" - ], - "transformerParameters": { - "headerValue": "123" - } - } - } - } - }, - "snapshotRecording": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "allOf": [ - { - "type": "object", - "properties": { - "captureHeaders": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": false, - "properties": { - "caseInsensitive": { - "type": "boolean" - } - } - }, - "description": "Headers from the request to include in the generated stub mappings, mapped to parameter objects. The only parameter available is \"caseInsensitive\", which defaults to false", - "example": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - } - }, - "extractBodyCriteria": { - "type": "object", - "description": "Criteria for extracting response bodies to a separate file instead of including it in the stub mapping", - "example": [ - { - "binarySizeThreshold": "1 Mb", - "textSizeThreshold": "2 kb" - } - ], - "properties": { - "binarySizeThreshold": { - "type": "string", - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB" - }, - "textSizeThreshold": { - "default": "0", - "description": "Size threshold for extracting binary response bodies. Supports humanized size strings, e.g. \"56 Mb\". Default unit is bytes.", - "example": "18.2 GB", - "type": "string" - } - } - }, - "persist": { - "type": "boolean", - "default": true, - "description": "Whether to save stub mappings to the file system or just return them" - }, - "repeatsAsScenarios": { - "type": "boolean", - "default": true, - "description": "When true, duplicate requests will be added to a Scenario. When false, duplicates are discarded" - }, - "requestBodyPattern": { - "type": "object", - "description": "Control the request body matcher used in generated stub mappings", - "oneOf": [ - { - "type": "object", - "description": "Automatically determine matcher based on content type (the default)", - "properties": { - "caseInsensitive": { - "type": "boolean", - "default": false, - "description": "If equalTo is used, match body use case-insensitive string comparison" - }, - "ignoreArrayOrder": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, ignore order of array elements" - }, - "ignoreExtraElements": { - "type": "boolean", - "default": true, - "description": "If equalToJson is used, matcher ignores extra elements in objects" - }, - "matcher": { - "type": "string", - "enum": [ - "auto" - ] - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalTo", - "properties": { - "caseInsensitive": { - "default": false, - "description": "Match body using case-insensitive string comparison", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalTo" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToJson", - "properties": { - "ignoreArrayOrder": { - "default": true, - "description": "Ignore order of array elements", - "type": "boolean" - }, - "ignoreExtraElements": { - "default": true, - "description": "Ignore extra elements in objects", - "type": "boolean" - }, - "matcher": { - "enum": [ - "equalToJson" - ], - "type": "string" - } - } - }, - { - "type": "object", - "description": "Always match request bodies using equalToXml", - "properties": { - "matcher": { - "type": "string", - "enum": [ - "equalToXml" - ] - } - } - } - ] - }, - "transformerParameters": { - "type": "object", - "description": "List of names of stub mappings transformers to apply to generated stubs" - }, - "transformers": { - "type": "array", - "description": "Parameters to pass to stub mapping transformers", - "items": { - "type": "string" - } - } - } - }, - { - "properties": { - "filters": { - "type": "object", - "allOf": [ - { - "properties": { - "ids": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "type": "object", - "description": "Filter requests for which to create stub mapping" - }, - { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - } - ] - } - } - } - ] - }, - "example": { - "filters": { - "urlPathPattern": "/api/.*", - "method": "GET", - "ids": [ - "40a93c4a-d378-4e07-8321-6158d5dbcb29" - ] - }, - "captureHeaders": { - "Accept": {}, - "Content-Type": { - "caseInsensitive": true - } - }, - "requestBodyPattern": { - "matcher": "equalToJson", - "ignoreArrayOrder": false, - "ignoreExtraElements": true - }, - "extractBodyCriteria": { - "textSizeThreshold": "2 kb", - "binarySizeThreshold": "1 Mb" - }, - "outputFormat": "FULL", - "persist": false, - "repeatsAsScenarios": false, - "transformers": [ - "modify-response-header" - ], - "transformerParameters": { - "headerValue": "123" - } - } - } - } - } - }, - "responses": { - "stubMapping": { - "description": "The stub mapping", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "string", - "description": "This stub mapping's unique identifier" - }, - "uuid": { - "type": "string", - "description": "Alias for the id" - }, - "name": { - "type": "string", - "description": "The stub mapping's name" - }, - "request": { - "type": "object", - "example": { - "bodyPatterns": [ - { - "equalToJson": "{ \"numbers\": [1, 2, 3] }" - } - ], - "headers": { - "Content-Type": { - "equalTo": "application/json" - } - }, - "method": "POST", - "url": "/some/thing" - }, - "properties": { - "method": { - "type": "string", - "description": "The HTTP request method e.g. GET" - }, - "url": { - "type": "string", - "description": "The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPath": { - "type": "string", - "description": "The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPathPattern": { - "type": "string", - "description": "The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "urlPattern": { - "type": "string", - "description": "The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified." - }, - "queryParameters": { - "type": "object", - "description": "Query parameter patterns to match against in the : { \"\": \"\" } form" - }, - "headers": { - "type": "object", - "description": "Header patterns to match against in the : { \"\": \"\" } form" - }, - "basicAuthCredentials": { - "type": "object", - "description": "Pre-emptive basic auth credentials to match against", - "properties": { - "password": { - "type": "string" - }, - "username": { - "type": "string" - } - }, - "required": [ - "username", - "password" - ] - }, - "cookies": { - "type": "object", - "description": "Cookie patterns to match against in the : { \"\": \"\" } form" - }, - "bodyPatterns": { - "type": "array", - "description": "Request body patterns to match against in the : { \"\": \"\" } form", - "items": { - "type": "object" - } - } - } - }, - "response": { - "allOf": [ - { - "oneOf": [ - { - "title": "Log normal", - "description": "Log normal randomly distributed response delay.", - "type": "object", - "properties": { - "median": { - "type": "integer" - }, - "sigma": { - "type": "number" - }, - "type": { - "enum": [ - "lognormal" - ], - "type": "string" - } - } - }, - { - "title": "Uniform", - "description": "Uniformly distributed random response delay.", - "type": "object", - "properties": { - "lower": { - "type": "integer" - }, - "type": { - "enum": [ - "uniform" - ], - "type": "string" - }, - "upper": { - "type": "integer" - } - } - } - ] - }, - { - "type": "object", - "properties": { - "status": { - "type": "integer", - "description": "The HTTP status code to be returned" - }, - "statusMessage": { - "type": "string", - "description": "The HTTP status message to be returned" - }, - "headers": { - "type": "object", - "description": "Map of response headers to send" - }, - "additionalProxyRequestHeaders": { - "type": "object", - "description": "Extra request headers to send when proxying to another host." - }, - "body": { - "type": "string", - "description": "The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "base64Body": { - "type": "string", - "description": "The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "jsonBody": { - "type": "object", - "description": "The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified." - }, - "bodyFileName": { - "type": "string", - "description": "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." - }, - "fault": { - "type": "string", - "description": "The fault to apply (instead of a full, valid response).", - "enum": [ - "CONNECTION_RESET_BY_PEER", - "EMPTY_RESPONSE", - "MALFORMED_RESPONSE_CHUNK", - "RANDOM_DATA_THEN_CLOSE" - ] - }, - "fixedDelayMilliseconds": { - "type": "integer", - "description": "Number of milliseconds to delay be before sending the response." - }, - "fromConfiguredStub": { - "type": "boolean", - "description": "Read-only flag indicating false if this was the default, unmatched response. Not present otherwise." - }, - "proxyBaseUrl": { - "type": "string", - "description": "The base URL of the target to proxy matching requests to." - }, - "transformerParameters": { - "type": "object", - "description": "Parameters to apply to response transformers." - }, - "transformers": { - "type": "array", - "description": "List of names of transformers to apply to this response.", - "items": { - "type": "string" - } - } - } - } - ] - }, - "persistent": { - "type": "boolean", - "description": "Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default." - }, - "priority": { - "type": "integer", - "description": "This stub mapping's priority relative to others. 1 is highest.", - "minimum": 1 - }, - "scenarioName": { - "type": "string", - "description": "The name of the scenario that this stub mapping is part of" - }, - "requiredScenarioState": { - "type": "string", - "description": "The required state of the scenario in order for this stub to be matched." - }, - "newScenarioState": { - "type": "string", - "description": "The new state for the scenario to be updated to after this stub is served." - }, - "postServeActions": { - "type": "object", - "description": "A map of the names of post serve action extensions to trigger and their parameters." - }, - "metadata": { - "type": "object", - "description": "Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs." - } - } - }, - "example": { - "id": "76ada7b0-49ae-4229-91c4-396a36f18e09", - "priority": 3, - "request": { - "headers": { - "Accept": { - "equalTo": "text/plain" - } - }, - "method": "GET", - "url": "/some/thing" - }, - "response": { - "body": "Hello world!", - "headers": { - "Content-Type": "text/plain" - }, - "status": 200 - } - } - } - } - }, - "nearMisses": { - "description": "Near misses matching criteria", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "nearMisses": { - "type": "array", - "items": { - "type": "object", - "properties": { - "method": { - "description": "The HTTP request method", - "type": "string", - "example": "GET" - }, - "url": { - "description": "The path and query to match exactly against", - "type": "string", - "example": "/received-request/2" - }, - "absoluteUrl": { - "description": "The full URL to match against", - "type": "string", - "example": "http://localhost:56738/received-request/2" - }, - "headers": { - "description": "Header patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": { - "Connection": "keep-alive", - "Host": "localhost:56738", - "User-Agent": "Apache-HttpClient/4.5.1 (Java/1.7.0_51)" - } - }, - "cookies": { - "description": "Cookie patterns to match against in the : { \"\": \"\" } form", - "type": "object", - "example": {} - }, - "body": { - "description": "Body string to match against", - "type": "string", - "example": "Hello world" - } - } - } - } - } - }, - "example": { - "nearMisses": [ - { - "request": { - "url": "/nomatch", - "absoluteUrl": "http://localhost:8080/nomatch", - "method": "GET", - "clientIp": "0:0:0:0:0:0:0:1", - "headers": { - "User-Agent": "curl/7.30.0", - "Accept": "*/*", - "Host": "localhost:8080" - }, - "cookies": {}, - "browserProxyRequest": false, - "loggedDate": 1467402464520, - "bodyAsBase64": "", - "body": "", - "loggedDateString": "2016-07-01T19:47:44Z" - }, - "requestPattern": { - "url": "/almostmatch", - "method": "GET" - }, - "matchResult": { - "distance": 0.06944444444444445 - } - } - ] - } - } - } - } - } - } -} - diff --git a/src/WireMock.Org.RestClient/IWireMockOrgApi.cs b/src/WireMock.Org.RestClient/IWireMockOrgApi.cs index d554ba2b..929d9f6e 100644 --- a/src/WireMock.Org.RestClient/IWireMockOrgApi.cs +++ b/src/WireMock.Org.RestClient/IWireMockOrgApi.cs @@ -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 { /// - /// WireMockOrg + /// Summary: WireMockOrg + /// + /// Title : WireMock + /// Version: 2.33.2 /// public interface IWireMockOrgApi { /// /// Get all stub mappings + /// + /// GetAdminMappings (/__admin/mappings) /// /// The maximum number of results to return /// The start index of the results to return [Get("/__admin/mappings")] - Task GetAdminMappingsAsync([Query] int? limit, [Query] int? offset); + Task GetAdminMappingsAsync([Query] int? limit, [Query] int? offset); /// /// Create a new stub mapping + /// + /// PostAdminMappings (/__admin/mappings) /// - /// [Post("/__admin/mappings")] [Header("Content-Type", "application/json")] - Task PostAdminMappingsAsync([Body] Mapping request); + Task PostAdminMappingsAsync(); /// /// Delete all stub mappings + /// + /// DeleteAdminMappings (/__admin/mappings) /// [Delete("/__admin/mappings")] - Task DeleteAdminMappingsAsync(); + Task DeleteAdminMappingsAsync(); /// /// Reset stub mappings + /// + /// PostAdminMappingsReset (/__admin/mappings/reset) /// [Post("/__admin/mappings/reset")] - Task PostAdminMappingsResetAsync(); + Task PostAdminMappingsResetAsync(); /// /// Persist stub mappings + /// + /// PostAdminMappingsSave (/__admin/mappings/save) /// [Post("/__admin/mappings/save")] - Task PostAdminMappingsSaveAsync(); + Task PostAdminMappingsSaveAsync(); /// /// Get stub mapping by ID + /// + /// GetAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId}) /// + /// The UUID of stub mapping [Get("/__admin/mappings/{stubMappingId}")] - Task GetAdminMappingsByStubMappingIdAsync(); + Task>> GetAdminMappingsByStubMappingIdAsync([Path] string stubMappingId); /// /// Update a stub mapping + /// + /// PutAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId}) /// - /// + /// The UUID of stub mapping [Put("/__admin/mappings/{stubMappingId}")] [Header("Content-Type", "application/json")] - Task PutAdminMappingsByStubMappingIdAsync([Body] Mapping request); + Task>> PutAdminMappingsByStubMappingIdAsync([Path] string stubMappingId); /// /// Delete a stub mapping + /// + /// DeleteAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId}) /// + /// The UUID of stub mapping [Delete("/__admin/mappings/{stubMappingId}")] - Task DeleteAdminMappingsByStubMappingIdAsync(); + Task DeleteAdminMappingsByStubMappingIdAsync([Path] string stubMappingId); /// + /// Find stubs by matching on their metadata + /// /// PostAdminMappingsFindByMetadata (/__admin/mappings/find-by-metadata) /// [Post("/__admin/mappings/find-by-metadata")] [Header("Content-Type", "application/json")] - Task PostAdminMappingsFindByMetadataAsync(); + Task PostAdminMappingsFindByMetadataAsync(); /// /// Delete stub mappings matching metadata + /// + /// PostAdminMappingsRemoveByMetadata (/__admin/mappings/remove-by-metadata) /// [Post("/__admin/mappings/remove-by-metadata")] [Header("Content-Type", "application/json")] - Task PostAdminMappingsRemoveByMetadataAsync(); + Task PostAdminMappingsRemoveByMetadataAsync(); /// /// Get all requests in journal + /// + /// GetAdminRequests (/__admin/requests) /// /// The maximum number of results to return /// Only return logged requests after this date [Get("/__admin/requests")] - Task GetAdminRequestsAsync([Query] string limit, [Query] string since); + Task GetAdminRequestsAsync([Query] string limit, [Query] string since); /// /// Delete all requests in journal + /// + /// DeleteAdminRequests (/__admin/requests) /// [Delete("/__admin/requests")] - Task DeleteAdminRequestsAsync(); + Task DeleteAdminRequestsAsync(); /// /// Get request by ID + /// + /// GetAdminRequestsByRequestId (/__admin/requests/{requestId}) /// /// The UUID of the logged request [Get("/__admin/requests/{requestId}")] - Task GetAdminRequestsByRequestIdAsync([Path] string requestId); + Task GetAdminRequestsByRequestIdAsync([Path] string requestId); /// /// Delete request by ID + /// + /// DeleteAdminRequestsByRequestId (/__admin/requests/{requestId}) /// /// The UUID of the logged request [Delete("/__admin/requests/{requestId}")] - Task DeleteAdminRequestsByRequestIdAsync([Path] string requestId); + Task DeleteAdminRequestsByRequestIdAsync([Path] string requestId); /// /// Empty the request journal + /// + /// PostAdminRequestsReset (/__admin/requests/reset) /// [Post("/__admin/requests/reset")] - Task PostAdminRequestsResetAsync(); + Task PostAdminRequestsResetAsync(); /// /// Count requests by criteria + /// + /// PostAdminRequestsCount (/__admin/requests/count) /// - /// [Post("/__admin/requests/count")] [Header("Content-Type", "application/json")] - Task PostAdminRequestsCountAsync([Body] Request request); + Task PostAdminRequestsCountAsync(); /// /// Remove requests by criteria + /// + /// PostAdminRequestsRemove (/__admin/requests/remove) /// - /// [Post("/__admin/requests/remove")] [Header("Content-Type", "application/json")] - Task PostAdminRequestsRemoveAsync([Body] Request request); + Task PostAdminRequestsRemoveAsync(); /// /// Delete requests mappings matching metadata + /// + /// PostAdminRequestsRemoveByMetadata (/__admin/requests/remove-by-metadata) /// [Post("/__admin/requests/remove-by-metadata")] [Header("Content-Type", "application/json")] - Task PostAdminRequestsRemoveByMetadataAsync(); + Task PostAdminRequestsRemoveByMetadataAsync(); /// /// Find requests by criteria + /// + /// PostAdminRequestsFind (/__admin/requests/find) /// - /// [Post("/__admin/requests/find")] [Header("Content-Type", "application/json")] - Task PostAdminRequestsFindAsync([Body] Request request); + Task PostAdminRequestsFindAsync(); /// /// Find unmatched requests + /// + /// GetAdminRequestsUnmatched (/__admin/requests/unmatched) /// [Get("/__admin/requests/unmatched")] - Task GetAdminRequestsUnmatchedAsync(); + Task GetAdminRequestsUnmatchedAsync(); /// + /// Retrieve near-misses for all unmatched requests + /// /// GetAdminRequestsUnmatchedNearMisses (/__admin/requests/unmatched/near-misses) /// [Get("/__admin/requests/unmatched/near-misses")] - Task GetAdminRequestsUnmatchedNearMissesAsync(); + Task GetAdminRequestsUnmatchedNearMissesAsync(); /// /// Find near misses matching specific request + /// + /// PostAdminNearMissesRequest (/__admin/near-misses/request) /// - /// [Post("/__admin/near-misses/request")] [Header("Content-Type", "application/json")] - Task PostAdminNearMissesRequestAsync([Body] NearMiss request); + Task PostAdminNearMissesRequestAsync(); /// /// Find near misses matching request pattern + /// + /// PostAdminNearMissesRequestPattern (/__admin/near-misses/request-pattern) /// - /// [Post("/__admin/near-misses/request-pattern")] [Header("Content-Type", "application/json")] - Task PostAdminNearMissesRequestPatternAsync([Body] Request request); + Task PostAdminNearMissesRequestPatternAsync(); /// /// Start recording + /// + /// PostAdminRecordingsStart (/__admin/recordings/start) /// [Post("/__admin/recordings/start")] [Header("Content-Type", "application/json")] - Task PostAdminRecordingsStartAsync(); + Task PostAdminRecordingsStartAsync(); /// /// Stop recording + /// + /// PostAdminRecordingsStop (/__admin/recordings/stop) /// [Post("/__admin/recordings/stop")] - Task PostAdminRecordingsStopAsync(); + Task PostAdminRecordingsStopAsync(); /// /// Get recording status + /// + /// GetAdminRecordingsStatus (/__admin/recordings/status) /// [Get("/__admin/recordings/status")] - Task GetAdminRecordingsStatusAsync(); + Task GetAdminRecordingsStatusAsync(); /// /// Take a snapshot recording + /// + /// PostAdminRecordingsSnapshot (/__admin/recordings/snapshot) /// - /// [Post("/__admin/recordings/snapshot")] [Header("Content-Type", "application/json")] - Task PostAdminRecordingsSnapshotAsync([Body] object request); + Task PostAdminRecordingsSnapshotAsync(); /// /// Get all scenarios + /// + /// GetAdminScenarios (/__admin/scenarios) /// [Get("/__admin/scenarios")] - Task GetAdminScenariosAsync(); + Task GetAdminScenariosAsync(); /// /// Reset the state of all scenarios + /// + /// PostAdminScenariosReset (/__admin/scenarios/reset) /// [Post("/__admin/scenarios/reset")] - Task PostAdminScenariosResetAsync(); + Task PostAdminScenariosResetAsync(); /// /// Update global settings + /// + /// PostAdminSettings (/__admin/settings) /// [Post("/__admin/settings")] [Header("Content-Type", "application/json")] - Task PostAdminSettingsAsync(); + Task PostAdminSettingsAsync(); /// /// Reset mappings and request journal + /// + /// PostAdminReset (/__admin/reset) /// [Post("/__admin/reset")] - Task PostAdminResetAsync(); + Task PostAdminResetAsync(); /// + /// Shutdown the WireMock server + /// /// PostAdminShutdown (/__admin/shutdown) /// [Post("/__admin/shutdown")] - Task PostAdminShutdownAsync(); + Task PostAdminShutdownAsync(); } -} +} \ No newline at end of file diff --git a/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj b/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj index 80c5df43..b18b8056 100644 --- a/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj +++ b/src/WireMock.Org.RestClient/WireMock.Org.RestClient.csproj @@ -30,8 +30,9 @@ + - + diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 86e04868..37f522c2 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -52,7 +52,7 @@ - +