Initial support for converting the mappings to a Pact(flow) json file (#748)

* WithDescription

* WithConsumer / WithProvider

* x

* .

* .

* .

* .

* fix

* pact

* nullable

* ficx

* .

* fix
This commit is contained in:
Stef Heyenrath
2022-04-22 16:17:50 +02:00
committed by GitHub
parent b06b3c8e8b
commit a6ee2dacc7
93 changed files with 1876 additions and 1065 deletions

View File

@@ -1,31 +1,30 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace WireMock.Admin.Mappings
namespace WireMock.Admin.Mappings;
/// <summary>
/// Cookie Model
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class CookieModel
{
/// <summary>
/// Cookie Model
/// Gets or sets the name.
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class CookieModel
{
/// <summary>
/// Gets or sets the name.
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = null!;
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public IList<MatcherModel> Matchers { get; set; }
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public IList<MatcherModel>? Matchers { get; set; }
/// <summary>
/// Gets or sets the ignore case.
/// </summary>
public bool? IgnoreCase { get; set; }
/// <summary>
/// Gets or sets the ignore case.
/// </summary>
public bool? IgnoreCase { get; set; }
/// <summary>
/// Reject on match.
/// </summary>
public bool? RejectOnMatch { get; set; }
}
/// <summary>
/// Reject on match.
/// </summary>
public bool? RejectOnMatch { get; set; }
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace WireMock.Admin.Mappings
{
@@ -11,12 +11,12 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets or sets the name.
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = null!;
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public IList<MatcherModel> Matchers { get; set; }
public IList<MatcherModel>? Matchers { get; set; }
/// <summary>
/// Gets or sets the ignore case.

View File

@@ -24,6 +24,11 @@ namespace WireMock.Admin.Mappings
/// </summary>
public string Title { get; set; }
/// <summary>
/// The description.
/// </summary>
public string Description { get; set; }
/// <summary>
/// The priority. (A low value means higher priority.)
/// </summary>

View File

@@ -1,24 +1,23 @@
namespace WireMock.Admin.Mappings
namespace WireMock.Admin.Mappings;
/// <summary>
/// Param Model
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class ParamModel
{
/// <summary>
/// Param Model
/// Gets or sets the name.
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class ParamModel
{
/// <summary>
/// Gets or sets the name.
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = null!;
/// <summary>
/// Defines if the key should be matched using case-ignore.
/// </summary>
public bool? IgnoreCase { get; set; }
/// <summary>
/// Defines if the key should be matched using case-ignore.
/// </summary>
public bool? IgnoreCase { get; set; }
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
}
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[]? Matchers { get; set; }
}

View File

@@ -1,51 +1,50 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace WireMock.Admin.Mappings
namespace WireMock.Admin.Mappings;
/// <summary>
/// RequestModel
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class RequestModel
{
/// <summary>
/// RequestModel
/// Gets or sets the ClientIP. (Can be a string or a ClientIPModel)
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class RequestModel
{
/// <summary>
/// Gets or sets the ClientIP. (Can be a string or a ClientIPModel)
/// </summary>
public object ClientIP { get; set; }
public object? ClientIP { get; set; }
/// <summary>
/// Gets or sets the Path. (Can be a string or a PathModel)
/// </summary>
public object Path { get; set; }
/// <summary>
/// Gets or sets the Path. (Can be a string or a PathModel)
/// </summary>
public object? Path { get; set; }
/// <summary>
/// Gets or sets the Url. (Can be a string or a UrlModel)
/// </summary>
public object Url { get; set; }
/// <summary>
/// Gets or sets the Url. (Can be a string or a UrlModel)
/// </summary>
public object? Url { get; set; }
/// <summary>
/// The methods
/// </summary>
public string[] Methods { get; set; }
/// <summary>
/// The methods
/// </summary>
public string[]? Methods { get; set; }
/// <summary>
/// Gets or sets the Headers.
/// </summary>
public IList<HeaderModel> Headers { get; set; }
/// <summary>
/// Gets or sets the Headers.
/// </summary>
public IList<HeaderModel>? Headers { get; set; }
/// <summary>
/// Gets or sets the Cookies.
/// </summary>
public IList<CookieModel> Cookies { get; set; }
/// <summary>
/// Gets or sets the Cookies.
/// </summary>
public IList<CookieModel>? Cookies { get; set; }
/// <summary>
/// Gets or sets the Params.
/// </summary>
public IList<ParamModel> Params { get; set; }
/// <summary>
/// Gets or sets the Params.
/// </summary>
public IList<ParamModel>? Params { get; set; }
/// <summary>
/// Gets or sets the body.
/// </summary>
public BodyModel Body { get; set; }
}
/// <summary>
/// Gets or sets the body.
/// </summary>
public BodyModel? Body { get; set; }
}

View File

@@ -11,22 +11,22 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets or sets the HTTP status.
/// </summary>
public object StatusCode { get; set; }
public object? StatusCode { get; set; }
/// <summary>
/// Gets or sets the body destination (SameAsSource, String or Bytes).
/// </summary>
public string BodyDestination { get; set; }
public string? BodyDestination { get; set; }
/// <summary>
/// Gets or sets the body.
/// </summary>
public string Body { get; set; }
public string? Body { get; set; }
/// <summary>
/// Gets or sets the body (as JSON object).
/// </summary>
public object BodyAsJson { get; set; }
public object? BodyAsJson { get; set; }
/// <summary>
/// Gets or sets a value indicating whether child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings.
@@ -36,12 +36,12 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets or sets the body (as bytearray).
/// </summary>
public byte[] BodyAsBytes { get; set; }
public byte[]? BodyAsBytes { get; set; }
/// <summary>
/// Gets or sets the body as a file.
/// </summary>
public string BodyAsFile { get; set; }
public string? BodyAsFile { get; set; }
/// <summary>
/// Is the body as file cached?
@@ -51,7 +51,7 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets or sets the body encoding.
/// </summary>
public EncodingModel BodyEncoding { get; set; }
public EncodingModel? BodyEncoding { get; set; }
/// <summary>
/// Use ResponseMessage Transformer.
@@ -61,7 +61,7 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets the type of the transformer.
/// </summary>
public string TransformerType { get; set; }
public string? TransformerType { get; set; }
/// <summary>
/// Use the Handlebars transformer for the content from the referenced BodyAsFile.
@@ -71,17 +71,17 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// The ReplaceNodeOptions to use when transforming a JSON node.
/// </summary>
public string TransformerReplaceNodeOptions { get; set; }
public string? TransformerReplaceNodeOptions { get; set; }
/// <summary>
/// Gets or sets the headers.
/// </summary>
public IDictionary<string, object> Headers { get; set; }
public IDictionary<string, object>? Headers { get; set; }
/// <summary>
/// Gets or sets the Headers (Raw).
/// </summary>
public string HeadersRaw { get; set; }
public string? HeadersRaw { get; set; }
/// <summary>
/// Gets or sets the delay in milliseconds.
@@ -101,21 +101,21 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets or sets the Proxy URL.
/// </summary>
public string ProxyUrl { get; set; }
public string? ProxyUrl { get; set; }
/// <summary>
/// The client X509Certificate2 Thumbprint or SubjectName to use.
/// </summary>
public string X509Certificate2ThumbprintOrSubjectName { get; set; }
public string? X509Certificate2ThumbprintOrSubjectName { get; set; }
/// <summary>
/// Gets or sets the fault.
/// </summary>
public FaultModel Fault { get; set; }
public FaultModel? Fault { get; set; }
/// <summary>
/// Gets or sets the WebProxy settings.
/// </summary>
public WebProxyModel WebProxy { get; set; }
public WebProxyModel? WebProxy { get; set; }
}
}

View File

@@ -1,56 +1,54 @@
using System;
using System;
namespace WireMock.Admin.Requests
namespace WireMock.Admin.Requests;
/// <summary>
/// Request Log Model
/// </summary>
public class LogEntryModel
{
/// <summary>
/// Request Log Model
/// The unique identifier.
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class LogEntryModel
{
/// <summary>
/// The unique identifier.
/// </summary>
public Guid Guid { get; set; }
public Guid Guid { get; set; }
/// <summary>
/// The request.
/// </summary>
public LogRequestModel Request { get; set; }
/// <summary>
/// The request.
/// </summary>
public LogRequestModel Request { get; set; }
/// <summary>
/// The response.
/// </summary>
public LogResponseModel Response { get; set; }
/// <summary>
/// The response.
/// </summary>
public LogResponseModel Response { get; set; }
/// <summary>
/// The mapping unique identifier.
/// </summary>
public Guid? MappingGuid { get; set; }
/// <summary>
/// The mapping unique identifier.
/// </summary>
public Guid? MappingGuid { get; set; }
/// <summary>
/// The mapping unique title.
/// </summary>
public string MappingTitle { get; set; }
/// <summary>
/// The mapping unique title.
/// </summary>
public string MappingTitle { get; set; }
/// <summary>
/// The request match result.
/// </summary>
public LogRequestMatchModel RequestMatchResult { get; set; }
/// <summary>
/// The request match result.
/// </summary>
public LogRequestMatchModel RequestMatchResult { get; set; }
/// <summary>
/// The partial mapping unique identifier.
/// </summary>
public Guid? PartialMappingGuid { get; set; }
/// <summary>
/// The partial mapping unique identifier.
/// </summary>
public Guid? PartialMappingGuid { get; set; }
/// <summary>
/// The partial mapping unique title.
/// </summary>
public string PartialMappingTitle { get; set; }
/// <summary>
/// The partial mapping unique title.
/// </summary>
public string PartialMappingTitle { get; set; }
/// <summary>
/// The partial request match result.
/// </summary>
public LogRequestMatchModel PartialRequestMatchResult { get; set; }
}
/// <summary>
/// The partial request match result.
/// </summary>
public LogRequestMatchModel PartialRequestMatchResult { get; set; }
}

View File

@@ -1,51 +1,49 @@
using System.Collections.Generic;
using System.Collections.Generic;
namespace WireMock.Admin.Requests
namespace WireMock.Admin.Requests;
/// <summary>
/// LogRequestMatchModel
/// </summary>
public class LogRequestMatchModel
{
/// <summary>
/// LogRequestMatchModel
/// Gets or sets the match-score.
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class LogRequestMatchModel
{
/// <summary>
/// Gets or sets the match-score.
/// </summary>
/// <value>
/// The match-score.
/// </value>
public double TotalScore { get; set; }
/// <value>
/// The match-score.
/// </value>
public double TotalScore { get; set; }
/// <summary>
/// Gets or sets the total number of matches.
/// </summary>
/// <value>
/// The total number of matches.
/// </value>
public int TotalNumber { get; set; }
/// <summary>
/// Gets or sets the total number of matches.
/// </summary>
/// <value>
/// The total number of matches.
/// </value>
public int TotalNumber { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is perfect match.
/// </summary>
/// <value>
/// <c>true</c> if this instance is perfect match; otherwise, <c>false</c>.
/// </value>
public bool IsPerfectMatch { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is perfect match.
/// </summary>
/// <value>
/// <c>true</c> if this instance is perfect match; otherwise, <c>false</c>.
/// </value>
public bool IsPerfectMatch { get; set; }
/// <summary>
/// Gets the match percentage.
/// </summary>
/// <value>
/// The match percentage.
/// </value>
public double AverageTotalScore { get; set; }
/// <summary>
/// Gets the match percentage.
/// </summary>
/// <value>
/// The match percentage.
/// </value>
public double AverageTotalScore { get; set; }
/// <summary>
/// Gets the match details.
/// </summary>
/// <value>
/// The match details.
/// </value>
public IList<object> MatchDetails { get; set; }
}
/// <summary>
/// Gets the match details.
/// </summary>
/// <value>
/// The match details.
/// </value>
public IList<object> MatchDetails { get; set; }
}

View File

@@ -1,109 +1,107 @@
using System;
using System;
using System.Collections.Generic;
using WireMock.Admin.Mappings;
using WireMock.Types;
namespace WireMock.Admin.Requests
namespace WireMock.Admin.Requests;
/// <summary>
/// RequestMessage Model
/// </summary>
public class LogRequestModel
{
/// <summary>
/// RequestMessage Model
/// The Client IP Address.
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class LogRequestModel
{
/// <summary>
/// The Client IP Address.
/// </summary>
public string ClientIP { get; set; }
public string ClientIP { get; set; }
/// <summary>
/// The DateTime.
/// </summary>
public DateTime DateTime { get; set; }
/// <summary>
/// The DateTime.
/// </summary>
public DateTime DateTime { get; set; }
/// <summary>
/// The Path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The Path.
/// </summary>
public string Path { get; set; }
/// <summary>
/// The Absolute Path.
/// </summary>
public string AbsolutePath { get; set; }
/// <summary>
/// The Absolute Path.
/// </summary>
public string AbsolutePath { get; set; }
/// <summary>
/// Gets the url (relative).
/// </summary>
public string Url { get; set; }
/// <summary>
/// Gets the url (relative).
/// </summary>
public string Url { get; set; }
/// <summary>
/// The absolute URL.
/// </summary>
public string AbsoluteUrl { get; set; }
/// <summary>
/// The absolute URL.
/// </summary>
public string AbsoluteUrl { get; set; }
/// <summary>
/// The ProxyUrl (if a proxy is used).
/// </summary>
public string ProxyUrl { get; set; }
/// <summary>
/// The ProxyUrl (if a proxy is used).
/// </summary>
public string? ProxyUrl { get; set; }
/// <summary>
/// The query.
/// </summary>
public IDictionary<string, WireMockList<string>> Query { get; set; }
/// <summary>
/// The query.
/// </summary>
public IDictionary<string, WireMockList<string>>? Query { get; set; }
/// <summary>
/// The method.
/// </summary>
public string Method { get; set; }
/// <summary>
/// The method.
/// </summary>
public string Method { get; set; }
/// <summary>
/// The Headers.
/// </summary>
public IDictionary<string, WireMockList<string>> Headers { get; set; }
/// <summary>
/// The Headers.
/// </summary>
public IDictionary<string, WireMockList<string>>? Headers { get; set; }
/// <summary>
/// The Cookies.
/// </summary>
public IDictionary<string, string> Cookies { get; set; }
/// <summary>
/// The Cookies.
/// </summary>
public IDictionary<string, string>? Cookies { get; set; }
/// <summary>
/// The body (as string).
/// </summary>
public string Body { get; set; }
/// <summary>
/// The body (as string).
/// </summary>
public string? Body { get; set; }
/// <summary>
/// The body (as JSON object).
/// </summary>
public object BodyAsJson { get; set; }
/// <summary>
/// The body (as JSON object).
/// </summary>
public object? BodyAsJson { get; set; }
/// <summary>
/// The body (as bytearray).
/// </summary>
public byte[] BodyAsBytes { get; set; }
/// <summary>
/// The body (as bytearray).
/// </summary>
public byte[]? BodyAsBytes { get; set; }
/// <summary>
/// The body encoding.
/// </summary>
public EncodingModel BodyEncoding { get; set; }
/// <summary>
/// The body encoding.
/// </summary>
public EncodingModel? BodyEncoding { get; set; }
/// <summary>
/// The DetectedBodyType, valid values are:
///
/// - None
/// - String
/// - Json
/// - Bytes
/// </summary>
public string DetectedBodyType { get; set; }
/// <summary>
/// The DetectedBodyType, valid values are:
///
/// - None
/// - String
/// - Json
/// - Bytes
/// </summary>
public string? DetectedBodyType { get; set; }
/// <summary>
/// The DetectedBodyTypeFromContentType, valid values are:
///
/// - None
/// - String
/// - Json
/// - Bytes
/// </summary>
public string DetectedBodyTypeFromContentType { get; set; }
}
/// <summary>
/// The DetectedBodyTypeFromContentType, valid values are:
///
/// - None
/// - String
/// - Json
/// - Bytes
/// </summary>
public string? DetectedBodyTypeFromContentType { get; set; }
}

View File

@@ -1,83 +1,81 @@
using System.Collections.Generic;
using System.Collections.Generic;
using WireMock.Admin.Mappings;
using WireMock.Types;
namespace WireMock.Admin.Requests
namespace WireMock.Admin.Requests;
/// <summary>
/// Response MessageModel
/// </summary>
public class LogResponseModel
{
/// <summary>
/// Response MessageModel
/// Gets or sets the status code.
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class LogResponseModel
{
/// <summary>
/// Gets or sets the status code.
/// </summary>
public object StatusCode { get; set; } = 200;
public object? StatusCode { get; set; }
/// <summary>
/// Gets the headers.
/// </summary>
public IDictionary<string, WireMockList<string>> Headers { get; set; }
/// <summary>
/// Gets the headers.
/// </summary>
public IDictionary<string, WireMockList<string>>? Headers { get; set; }
/// <summary>
/// Gets or sets the body destination (SameAsSource, String or Bytes).
/// </summary>
public string BodyDestination { get; set; }
/// <summary>
/// Gets or sets the body destination (SameAsSource, String or Bytes).
/// </summary>
public string? BodyDestination { get; set; }
/// <summary>
/// The body (as string).
/// </summary>
public string Body { get; set; }
/// <summary>
/// The body (as string).
/// </summary>
public string? Body { get; set; }
/// <summary>
/// The body (as JSON object).
/// </summary>
public object BodyAsJson { get; set; }
/// <summary>
/// The body (as JSON object).
/// </summary>
public object? BodyAsJson { get; set; }
/// <summary>
/// The body (as bytearray).
/// </summary>
public byte[] BodyAsBytes { get; set; }
/// <summary>
/// The body (as bytearray).
/// </summary>
public byte[]? BodyAsBytes { get; set; }
/// <summary>
/// Gets or sets the body as file.
/// </summary>
public string BodyAsFile { get; set; }
/// <summary>
/// Gets or sets the body as file.
/// </summary>
public string? BodyAsFile { get; set; }
/// <summary>
/// Is the body as file cached?
/// </summary>
public bool? BodyAsFileIsCached { get; set; }
/// <summary>
/// Is the body as file cached?
/// </summary>
public bool? BodyAsFileIsCached { get; set; }
/// <summary>
/// Gets or sets the original body.
/// </summary>
public string BodyOriginal { get; set; }
/// <summary>
/// Gets or sets the original body.
/// </summary>
public string? BodyOriginal { get; set; }
/// <summary>
/// Gets or sets the body.
/// </summary>
public EncodingModel BodyEncoding { get; set; }
/// <summary>
/// Gets or sets the body.
/// </summary>
public EncodingModel? BodyEncoding { get; set; }
/// <summary>
/// The detected body type (detection based on body content).
/// </summary>
public BodyType DetectedBodyType { get; set; }
/// <summary>
/// The detected body type (detection based on body content).
/// </summary>
public BodyType? DetectedBodyType { get; set; }
/// <summary>
/// The detected body type (detection based on Content-Type).
/// </summary>
public BodyType DetectedBodyTypeFromContentType { get; set; }
/// <summary>
/// The detected body type (detection based on Content-Type).
/// </summary>
public BodyType? DetectedBodyTypeFromContentType { get; set; }
/// <summary>
/// The FaultType.
/// </summary>
public string FaultType { get; set; }
/// <summary>
/// The FaultType.
/// </summary>
public string? FaultType { get; set; }
/// <summary>
/// Gets or sets the Fault percentage.
/// </summary>
public double? FaultPercentage { get; set; }
}
/// <summary>
/// Gets or sets the Fault percentage.
/// </summary>
public double? FaultPercentage { get; set; }
}

View File

@@ -1,4 +1,4 @@
namespace WireMock.Admin.Scenarios
namespace WireMock.Admin.Scenarios
{
/// <summary>
/// ScenarioStateModel
@@ -14,7 +14,7 @@
/// <summary>
/// Gets or sets the NextState.
/// </summary>
public string NextState { get; set; }
public string? NextState { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="ScenarioStateModel"/> is started.

View File

@@ -1,59 +1,58 @@
using JetBrains.Annotations;
namespace WireMock.Admin.Settings;
[FluentBuilder.AutoGenerateBuilder]
public class ProxyAndRecordSettingsModel
namespace WireMock.Admin.Settings
{
/// <summary>
/// The clientCertificate thumbprint or subject name fragment to use.
/// Example thumbprint : "D2DBF135A8D06ACCD0E1FAD9BFB28678DF7A9818". Example subject name: "www.google.com""
/// </summary>
public string ClientX509Certificate2ThumbprintOrSubjectName { get; set; }
[FluentBuilder.AutoGenerateBuilder]
public class ProxyAndRecordSettingsModel
{
/// <summary>
/// The clientCertificate thumbprint or subject name fragment to use.
/// Example thumbprint : "D2DBF135A8D06ACCD0E1FAD9BFB28678DF7A9818". Example subject name: "www.google.com""
/// </summary>
public string ClientX509Certificate2ThumbprintOrSubjectName { get; set; }
/// <summary>
/// Defines the WebProxySettings.
/// </summary>
public WebProxySettingsModel WebProxySettings { get; set; }
/// <summary>
/// Defines the WebProxySettings.
/// </summary>
public WebProxySettingsModel WebProxySettings { get; set; }
/// <summary>
/// Proxy requests should follow redirection (30x).
/// </summary>
public bool? AllowAutoRedirect { get; set; }
/// <summary>
/// Proxy requests should follow redirection (30x).
/// </summary>
public bool? AllowAutoRedirect { get; set; }
/// <summary>
/// The URL to proxy.
/// </summary>
public string Url { get; set; }
/// <summary>
/// The URL to proxy.
/// </summary>
public string Url { get; set; }
/// <summary>
/// Save the mapping for each request/response to the internal Mappings.
/// </summary>
public bool SaveMapping { get; set; }
/// <summary>
/// Save the mapping for each request/response to the internal Mappings.
/// </summary>
public bool SaveMapping { get; set; }
/// <summary>
/// Save the mapping for each request/response also to a file. (Note that SaveMapping must also be set to true.)
/// </summary>
public bool SaveMappingToFile { get; set; }
/// <summary>
/// Save the mapping for each request/response also to a file. (Note that SaveMapping must also be set to true.)
/// </summary>
public bool SaveMappingToFile { get; set; }
/// <summary>
/// Only save request/response to the internal Mappings if the status code is included in this pattern. (Note that SaveMapping must also be set to true.)
/// The pattern can contain a single value like "200", but also ranges like "2xx", "100,300,600" or "100-299,6xx" are supported.
/// </summary>
public string SaveMappingForStatusCodePattern { get; set; } = "*";
/// <summary>
/// Only save request/response to the internal Mappings if the status code is included in this pattern. (Note that SaveMapping must also be set to true.)
/// The pattern can contain a single value like "200", but also ranges like "2xx", "100,300,600" or "100-299,6xx" are supported.
/// </summary>
public string SaveMappingForStatusCodePattern { get; set; } = "*";
/// <summary>
/// Defines a list from headers which will be excluded from the saved mappings.
/// </summary>
public string[] ExcludedHeaders { get; set; }
/// <summary>
/// Defines a list from headers which will be excluded from the saved mappings.
/// </summary>
public string[] ExcludedHeaders { get; set; }
/// <summary>
/// Defines a list of cookies which will be excluded from the saved mappings.
/// </summary>
public string[] ExcludedCookies { get; set; }
/// <summary>
/// Defines a list of cookies which will be excluded from the saved mappings.
/// </summary>
public string[] ExcludedCookies { get; set; }
/// <summary>
/// Prefer the Proxy Mapping over the saved Mapping (in case SaveMapping is set to <c>true</c>).
/// </summary>
// public bool PreferProxyMapping { get; set; }
/// <summary>
/// Prefer the Proxy Mapping over the saved Mapping (in case SaveMapping is set to <c>true</c>).
/// </summary>
// public bool PreferProxyMapping { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using WireMock.Handlers;
namespace WireMock.Admin.Settings
@@ -73,11 +72,11 @@ namespace WireMock.Admin.Settings
/// <summary>
/// Policies to use when using CORS. By default CORS is disabled. [Optional]
/// </summary>
public string CorsPolicyOptions { get; set; }
public string? CorsPolicyOptions { get; set; }
/// <summary>
/// The proxy and record settings.
/// </summary>
public ProxyAndRecordSettingsModel ProxyAndRecordSettings { get; set; }
public ProxyAndRecordSettingsModel? ProxyAndRecordSettings { get; set; }
}
}

View File

@@ -14,11 +14,11 @@ namespace WireMock.Admin.Settings
/// <summary>
/// The user name associated with the credentials.
/// </summary>
public string UserName { get; set; }
public string? UserName { get; set; }
/// <summary>
/// The password for the user name associated with the credentials.
/// </summary>
public string Password { get; set; }
public string? Password { get; set; }
}
}

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace WireMock.Handlers
{
/// <summary>
/// Handler to interact with the file system to handle folders and read and write static mapping files.
/// Handler to interact with the file system to handle folders and read and write (static mapping) files.
/// </summary>
public interface IFileSystemHandler
{
@@ -83,6 +83,14 @@ namespace WireMock.Handlers
/// <param name="bytes">The bytes.</param>
void WriteFile([NotNull] string filename, [NotNull] byte[] bytes);
/// <summary>
/// Write a file.
/// </summary>
/// <param name="folder">The folder.</param>
/// <param name="filename">The filename.</param>
/// <param name="bytes">The bytes.</param>
void WriteFile([NotNull] string folder, [NotNull] string filename, [NotNull] byte[] bytes);
/// <summary>
/// Read a file as bytes.
/// </summary>

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using WireMock.Types;
using WireMock.Util;
@@ -28,7 +28,7 @@ namespace WireMock
/// <summary>
/// The ProxyUrl (if a proxy is used).
/// </summary>
string ProxyUrl { get; }
string ProxyUrl { get; set; }
/// <summary>
/// Gets the DateTime.
@@ -83,7 +83,7 @@ namespace WireMock
/// <summary>
/// The body.
/// </summary>
IBodyData BodyData { get; }
IBodyData? BodyData { get; }
/// <summary>
/// The original body as string. Convenience getter for Handlebars.

View File

@@ -1,4 +1,4 @@
using System;
using System;
using JetBrains.Annotations;
using WireMock.Admin.Requests;
@@ -17,7 +17,7 @@ namespace WireMock.Logging
/// <param name="args">The arguments.</param>
[PublicAPI]
[StringFormatMethod("formatString")]
void Debug([NotNull] string formatString, [NotNull] params object[] args);
void Debug(string formatString, params object[] args);
/// <summary>
/// Writes the message at the Info level using the specified parameters.
@@ -26,7 +26,7 @@ namespace WireMock.Logging
/// <param name="args">The arguments.</param>
[PublicAPI]
[StringFormatMethod("formatString")]
void Info([NotNull] string formatString, [NotNull] params object[] args);
void Info(string formatString, params object[] args);
/// <summary>
/// Writes the message at the Warning level using the specified parameters.
@@ -35,7 +35,7 @@ namespace WireMock.Logging
/// <param name="args">The arguments.</param>
[PublicAPI]
[StringFormatMethod("formatString")]
void Warn([NotNull] string formatString, [NotNull] params object[] args);
void Warn(string formatString, params object[] args);
/// <summary>
/// Writes the message at the Error level using the specified parameters.
@@ -44,7 +44,7 @@ namespace WireMock.Logging
/// <param name="args">The arguments.</param>
[PublicAPI]
[StringFormatMethod("formatString")]
void Error([NotNull] string formatString, [NotNull] params object[] args);
void Error(string formatString, params object[] args);
/// <summary>
/// Writes the message at the Error level using the specified exception.
@@ -53,7 +53,7 @@ namespace WireMock.Logging
/// <param name="exception">The exception.</param>
[PublicAPI]
[StringFormatMethod("formatString")]
void Error([NotNull] string formatString, [NotNull] Exception exception);
void Error(string formatString, Exception exception);
/// <summary>
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
@@ -61,6 +61,6 @@ namespace WireMock.Logging
/// <param name="logEntryModel">The Request Log Model.</param>
/// <param name="isAdminRequest">Defines if this request is an admin request.</param>
[PublicAPI]
void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminRequest);
void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest);
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
namespace WireMock.Matchers.Request
@@ -44,5 +44,13 @@ namespace WireMock.Matchers.Request
/// The match-score.
/// </value>
double TotalScore { get; }
/// <summary>
/// Adds the score.
/// </summary>
/// <param name="matcherType">The matcher Type.</param>
/// <param name="score">The score.</param>
/// <returns>The score.</returns>
double AddScore(Type matcherType, double score);
}
}

View File

@@ -0,0 +1,20 @@
using JetBrains.Annotations;
namespace WireMock.Matchers.Request
{
/// <summary>
/// The RequestMatcher interface.
/// </summary>
public interface IRequestMatcher
{
/// <summary>
/// Determines whether the specified RequestMessage is match.
/// </summary>
/// <param name="requestMessage">The RequestMessage.</param>
/// <param name="requestMatchResult">The RequestMatchResult.</param>
/// <returns>
/// A value between 0.0 - 1.0 of the similarity.
/// </returns>
double GetMatchingScore([NotNull] IRequestMessage requestMessage, [NotNull] IRequestMatchResult requestMatchResult);
}
}

View File

@@ -1,61 +1,62 @@
using System.Text;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using JetBrains.Annotations;
using WireMock.Types;
namespace WireMock.Util
namespace WireMock.Util;
/// <summary>
/// IBodyData
/// </summary>
public interface IBodyData
{
/// <summary>
/// IBodyData
/// The body (as bytearray).
/// </summary>
public interface IBodyData
{
/// <summary>
/// The body (as bytearray).
/// </summary>
byte[] BodyAsBytes { get; set; }
byte[] BodyAsBytes { get; set; }
/// <summary>
/// Gets or sets the body as a file.
/// </summary>
string BodyAsFile { get; set; }
/// <summary>
/// Gets or sets the body as a file.
/// </summary>
string BodyAsFile { get; set; }
/// <summary>
/// Is the body as file cached?
/// </summary>
bool? BodyAsFileIsCached { get; set; }
/// <summary>
/// Is the body as file cached?
/// </summary>
bool? BodyAsFileIsCached { get; set; }
/// <summary>
/// The body (as JSON object).
/// </summary>
object BodyAsJson { get; set; }
/// <summary>
/// The body (as JSON object).
/// </summary>
object? BodyAsJson { get; set; }
/// <summary>
/// Gets or sets a value indicating whether child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings.
/// </summary>
bool? BodyAsJsonIndented { get; set; }
/// <summary>
/// Gets or sets a value indicating whether child objects to be indented according to the Newtonsoft.Json.JsonTextWriter.Indentation and Newtonsoft.Json.JsonTextWriter.IndentChar settings.
/// </summary>
bool? BodyAsJsonIndented { get; set; }
/// <summary>
/// The body as string, this is defined when BodyAsString or BodyAsJson are not null.
/// </summary>
string BodyAsString { get; set; }
/// <summary>
/// The body as string, this is defined when BodyAsString or BodyAsJson are not null.
/// </summary>
string BodyAsString { get; set; }
/// <summary>
/// The detected body type (detection based on body content).
/// </summary>
BodyType DetectedBodyType { get; set; }
/// <summary>
/// The detected body type (detection based on body content).
/// </summary>
BodyType? DetectedBodyType { get; set; }
/// <summary>
/// The detected body type (detection based on Content-Type).
/// </summary>
BodyType DetectedBodyTypeFromContentType { get; set; }
/// <summary>
/// The detected body type (detection based on Content-Type).
/// </summary>
BodyType? DetectedBodyTypeFromContentType { get; set; }
/// <summary>
/// The detected compression.
/// </summary>
string DetectedCompression { get; set; }
/// <summary>
/// The detected compression.
/// </summary>
string? DetectedCompression { get; set; }
/// <summary>
/// The body encoding.
/// </summary>
Encoding Encoding { get; set; }
}
/// <summary>
/// The body encoding.
/// </summary>
Encoding? Encoding { get; set; }
}

View File

@@ -4,6 +4,7 @@ using System.Collections.Specialized;
using JetBrains.Annotations;
using WireMock.Admin.Mappings;
using WireMock.Logging;
using WireMock.Matchers.Request;
namespace WireMock.Server
{
@@ -51,7 +52,17 @@ namespace WireMock.Server
/// <summary>
/// Gets the first url.
/// </summary>
string Url { get; }
string? Url { get; }
/// <summary>
/// Gets the consumer.
/// </summary>
string? Consumer { get; }
/// <summary>
/// Gets the provider.
/// </summary>
string? Provider { get; }
//ConcurrentDictionary<string, ScenarioState> Scenarios { get; }
@@ -94,7 +105,7 @@ namespace WireMock.Server
//IEnumerable<LogEntry> FindLogEntries([NotNull] params IRequestMatcher[] matchers);
//IRespondWithAProvider Given(IRequestMatcher requestMatcher, bool saveToFile = false);
// IRespondWithAProvider Given(IRequestMatcher requestMatcher, bool saveToFile = false);
/// <summary>
/// Reads a static mapping file and adds or updates a single mapping.
@@ -102,7 +113,7 @@ namespace WireMock.Server
/// Calling this method manually forces WireMock.Net to read and apply the specified static mapping file.
/// </summary>
/// <param name="path">The path to the static mapping file.</param>
bool ReadStaticMappingAndAddOrUpdate([NotNull] string path);
bool ReadStaticMappingAndAddOrUpdate(string path);
/// <summary>
/// Reads the static mappings from a folder.
@@ -111,7 +122,7 @@ namespace WireMock.Server
/// Calling this method manually forces WireMock.Net to read and apply all static mapping files in the specified folder.
/// </summary>
/// <param name="folder">The optional folder. If not defined, use {CurrentFolder}/__admin/mappings</param>
void ReadStaticMappings([CanBeNull] string folder = null);
void ReadStaticMappings(string? folder = null);
/// <summary>
/// Removes the authentication.
@@ -142,33 +153,33 @@ namespace WireMock.Server
/// Saves the static mappings.
/// </summary>
/// <param name="folder">The optional folder. If not defined, use {CurrentFolder}/__admin/mappings</param>
void SaveStaticMappings([CanBeNull] string folder = null);
void SaveStaticMappings(string? folder = null);
/// <summary>
/// Sets the basic authentication.
/// </summary>
/// <param name="tenant">The Tenant.</param>
/// <param name="audience">The Audience or Resource.</param>
void SetAzureADAuthentication([NotNull] string tenant, [NotNull] string audience);
void SetAzureADAuthentication(string tenant, string audience);
/// <summary>
/// Sets the basic authentication.
/// </summary>
/// <param name="username">The username.</param>
/// <param name="password">The password.</param>
void SetBasicAuthentication([NotNull] string username, [NotNull] string password);
void SetBasicAuthentication(string username, string password);
/// <summary>
/// Sets the maximum RequestLog count.
/// </summary>
/// <param name="maxRequestLogCount">The maximum RequestLog count.</param>
void SetMaxRequestLogCount([CanBeNull] int? maxRequestLogCount);
void SetMaxRequestLogCount(int? maxRequestLogCount);
/// <summary>
/// Sets RequestLog expiration in hours.
/// </summary>
/// <param name="requestLogExpirationDuration">The RequestLog expiration in hours.</param>
void SetRequestLogExpirationDuration([CanBeNull] int? requestLogExpirationDuration);
void SetRequestLogExpirationDuration(int? requestLogExpirationDuration);
/// <summary>
/// Stop this server.
@@ -179,7 +190,7 @@ namespace WireMock.Server
/// Watches the static mappings for changes.
/// </summary>
/// <param name="folder">The optional folder. If not defined, use {CurrentFolder}/__admin/mappings</param>
void WatchStaticMappings([CanBeNull] string folder = null);
void WatchStaticMappings(string? folder = null);
/// <summary>
/// Register the mappings (via <see cref="MappingModel"/>).