Files
WireMock.Net-wiremock/src/WireMock.Net.Abstractions/Extensions/RequestModelExtensions.cs
Stef Heyenrath 5e301fd74b Swagger support (#749)
* r

* fix

* sw

* x

* s

* .

* .

* .

* CreateTypeFromJObject

* .

* .

* f

* c

* .

* .

* .

* .

* .

* .

* ok

* ,

* .

* .

* .

* .

* n

* pact

* fix

* schema

* null

* fluent

* r

* -p

* .

* .

* refs

* .
2022-05-13 22:01:46 +02:00

29 lines
670 B
C#

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}";
}
}