Skip to content

Commit

Permalink
Initial support for converting the mappings to a Pact(flow) json file (
Browse files Browse the repository at this point in the history
…#748)

* WithDescription

* WithConsumer / WithProvider

* x

* .

* .

* .

* .

* fix

* pact

* nullable

* ficx

* .

* fix
  • Loading branch information
StefH authored Apr 22, 2022
1 parent b06b3c8 commit a6ee2da
Show file tree
Hide file tree
Showing 93 changed files with 1,899 additions and 1,088 deletions.
1 change: 1 addition & 0 deletions WireMock.Net Solution.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=guidb/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Heyenrath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Jmes/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Pacticipant/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Raml/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=randomizer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Scriban/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public void WriteFile(string path, byte[] bytes)
File.WriteAllBytes(AdjustPath(path), bytes);
}

public void WriteFile(string folder, string filename, byte[] bytes)
{
File.WriteAllBytes(Path.Combine(folder, filename), bytes);

}

/// <inheritdoc cref="IFileSystemHandler.DeleteFile"/>
public void DeleteFile(string path)
{
Expand Down
2 changes: 2 additions & 0 deletions examples/WireMock.Net.Console.Net452.Classic/MainApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static void Run()
server
.Given(Request.Create().WithPath(p => p.Contains("x")).UsingGet())
.AtPriority(4)
.WithTitle("t")
.WithDescription("d")
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
Expand Down
45 changes: 22 additions & 23 deletions src/WireMock.Net.Abstractions/Admin/Mappings/CookieModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
6 changes: 3 additions & 3 deletions src/WireMock.Net.Abstractions/Admin/Mappings/HeaderModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;

namespace WireMock.Admin.Mappings
{
Expand All @@ -11,12 +11,12 @@ public class HeaderModel
/// <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.
Expand Down
5 changes: 5 additions & 0 deletions src/WireMock.Net.Abstractions/Admin/Mappings/MappingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public class MappingModel
/// </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>
Expand Down
35 changes: 17 additions & 18 deletions src/WireMock.Net.Abstractions/Admin/Mappings/ParamModel.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
91 changes: 45 additions & 46 deletions src/WireMock.Net.Abstractions/Admin/Mappings/RequestModel.cs
Original file line number Diff line number Diff line change
@@ -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
/// </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; }

/// <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>
/// 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 Cookies.
/// </summary>
public IList<CookieModel> Cookies { get; set; }

/// <summary>
/// Gets or sets the Params.
/// </summary>
public IList<ParamModel> Params { get; set; }
/// Gets or sets the ClientIP. (Can be a string or a ClientIPModel)
/// </summary>
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 Url. (Can be a string or a UrlModel)
/// </summary>
public object? Url { 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 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 body.
/// </summary>
public BodyModel Body { get; set; }
}
/// <summary>
/// Gets or sets the body.
/// </summary>
public BodyModel? Body { get; set; }
}
30 changes: 15 additions & 15 deletions src/WireMock.Net.Abstractions/Admin/Mappings/ResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ public class ResponseModel
/// <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.
Expand All @@ -36,12 +36,12 @@ public class ResponseModel
/// <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?
Expand All @@ -51,7 +51,7 @@ public class ResponseModel
/// <summary>
/// Gets or sets the body encoding.
/// </summary>
public EncodingModel BodyEncoding { get; set; }
public EncodingModel? BodyEncoding { get; set; }

/// <summary>
/// Use ResponseMessage Transformer.
Expand All @@ -61,7 +61,7 @@ public class ResponseModel
/// <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.
Expand All @@ -71,17 +71,17 @@ public class ResponseModel
/// <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.
Expand All @@ -101,21 +101,21 @@ public class ResponseModel
/// <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; }
}
}
Loading

0 comments on commit a6ee2da

Please sign in to comment.