mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:43:48 +01:00
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:
@@ -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}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user