Swagger support (#749)

* r

* fix

* sw

* x

* s

* .

* .

* .

* CreateTypeFromJObject

* .

* .

* f

* c

* .

* .

* .

* .

* .

* .

* ok

* ,

* .

* .

* .

* .

* n

* pact

* fix

* schema

* null

* fluent

* r

* -p

* .

* .

* refs

* .
This commit is contained in:
Stef Heyenrath
2022-05-13 22:01:46 +02:00
committed by GitHub
parent 0d8b3b1438
commit 5e301fd74b
45 changed files with 2371 additions and 1123 deletions

View File

@@ -1,4 +1,4 @@
namespace WireMock.Admin.Mappings
namespace WireMock.Admin.Mappings
{
/// <summary>
/// Body Model
@@ -9,11 +9,11 @@
/// <summary>
/// Gets or sets the matcher.
/// </summary>
public MatcherModel Matcher { get; set; }
public MatcherModel? Matcher { get; set; }
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
public MatcherModel[]? Matchers { get; set; }
}
}

View File

@@ -1,30 +1,31 @@
using System.Collections.Generic;
namespace WireMock.Admin.Mappings;
/// <summary>
/// Cookie Model
/// </summary>
[FluentBuilder.AutoGenerateBuilder]
public class CookieModel
namespace WireMock.Admin.Mappings
{
/// <summary>
/// Gets or sets the name.
/// Cookie Model
/// </summary>
public string Name { get; set; } = null!;
[FluentBuilder.AutoGenerateBuilder]
public class CookieModel
{
/// <summary>
/// Gets or sets the name.
/// </summary>
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

@@ -14,17 +14,17 @@ namespace WireMock.Admin.Mappings
/// <summary>
/// Gets or sets the pattern. Can be a string (default) or an object.
/// </summary>
public object Pattern { get; set; }
public object? Pattern { get; set; }
/// <summary>
/// Gets or sets the patterns. Can be array of strings (default) or an array of objects.
/// </summary>
public object[] Patterns { get; set; }
public object[]? Patterns { get; set; }
/// <summary>
/// Gets or sets the pattern as a file.
/// </summary>
public string PatternAsFile { get; set; }
public string? PatternAsFile { get; set; }
/// <summary>
/// Gets or sets the ignore case.
@@ -36,4 +36,4 @@ namespace WireMock.Admin.Mappings
/// </summary>
public bool? RejectOnMatch { get; set; }
}
}
}

View File

@@ -1,4 +1,4 @@
namespace WireMock.Admin.Mappings
namespace WireMock.Admin.Mappings
{
/// <summary>
/// PathModel
@@ -9,6 +9,6 @@
/// <summary>
/// Gets or sets the matchers.
/// </summary>
public MatcherModel[] Matchers { get; set; }
public MatcherModel[]? Matchers { get; set; }
}
}

View File

@@ -0,0 +1,29 @@
using System.Linq;
using WireMock.Admin.Mappings;
namespace WireMock.Extensions;
public static class RequestModelExtensions
{
public static string? GetPathAsString(this RequestModel request)
{
var path = request.Path switch
{
string pathAsString => pathAsString,
PathModel pathModel => pathModel.Matchers?.FirstOrDefault()?.Pattern as string,
_ => null
};
return FixPath(path);
}
private static string? FixPath(string? path)
{
if (string.IsNullOrEmpty(path))
{
return path;
}
return path!.StartsWith("/") ? path : $"/{path}";
}
}

View File

@@ -0,0 +1,20 @@
using WireMock.Admin.Mappings;
namespace WireMock.Extensions;
public static class ResponseModelExtensions
{
private const string DefaultStatusCode = "200";
public static string GetStatusCodeAsString(this ResponseModel response)
{
return response.StatusCode switch
{
string statusCodeAsString => statusCodeAsString,
int statusCodeAsInt => statusCodeAsInt.ToString(),
_ => response.StatusCode?.ToString() ?? DefaultStatusCode
};
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using WireMock.ResponseBuilders;
using WireMock.Types;
using WireMock.Util;
@@ -13,7 +13,7 @@ namespace WireMock
/// <summary>
/// The Body.
/// </summary>
IBodyData BodyData { get; }
IBodyData? BodyData { get; }
/// <summary>
/// Gets the body destination (SameAsSource, String or Bytes).