mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-24 18:32:13 +01:00
Attempt to fix JSON parsing of text/plain content type (#1172)
* UseContentType * Fix unit tests * Add a unit test and an integration test for the fix. * Simplify body type checking with GetBodyType extension. * Split IBodyDataExtension, and use imperative style instead of functional style * Remove excessive null forgiving operators * Adjust braces --------- Co-authored-by: Ruxo Zheng <rz@just.sent.as>
This commit is contained in:
20
src/WireMock.Net.Abstractions/Models/IBodyDataExtension.cs
Normal file
20
src/WireMock.Net.Abstractions/Models/IBodyDataExtension.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using WireMock.Types;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace WireMock.Util;
|
||||
|
||||
public static class IBodyDataExtension
|
||||
{
|
||||
public static BodyType GetBodyType(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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user