Fix BodyParser to correctly check for json (#1297)

* Fix BodyParser to correctly check for json

* JsonUtils
This commit is contained in:
Stef Heyenrath
2025-05-21 17:28:29 +02:00
committed by GitHub
parent 1e23c58bf2
commit d628ce2270
7 changed files with 76 additions and 59 deletions

View File

@@ -8,18 +8,8 @@ namespace WireMock.Util;
// ReSharper disable once InconsistentNaming
public static class IBodyDataExtensions
{
public static BodyType GetBodyType(this IBodyData bodyData)
public static BodyType GetDetectedBodyType(this IBodyData bodyData)
{
if (bodyData.DetectedBodyTypeFromContentType is not null and not BodyType.None)
{
return bodyData.DetectedBodyTypeFromContentType.Value;
}
if (bodyData.DetectedBodyType is not null and not BodyType.None)
{
return bodyData.DetectedBodyType.Value;
}
return BodyType.None;
return bodyData.DetectedBodyType ?? BodyType.None;
}
}