mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-21 15:36:55 +02:00
fix findings
This commit is contained in:
@@ -276,7 +276,7 @@ public static class WireMockServerSettingsParser
|
||||
var defaultJsonBodyTransformer = parser.GetStringValue(nameof(WireMockServerSettings.DefaultJsonBodyTransformer));
|
||||
settings.DefaultJsonBodyTransformer = defaultJsonBodyTransformer switch
|
||||
{
|
||||
nameof(SystemTextJsonBodyTransformer) => new SystemTextJsonBodyTransformer(),
|
||||
nameof(SystemTextJsonBodyTransformer) => new SystemTextJsonBodyTransformer(settings),
|
||||
_ => new NewtonsoftJsonBodyTransformer(settings),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ public class NewtonsoftJsonBodyTransformer(WireMockServerSettings settings) : IJ
|
||||
}
|
||||
catch
|
||||
{
|
||||
settings.Logger.Warn("Failed to parse string ''{0}'' as JSON. Returning the original string value.", stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text.Json.Nodes;
|
||||
using HandlebarsDotNet.Helpers.Models;
|
||||
using JetBrains.Annotations;
|
||||
using JsonConverter.System.Text.Json;
|
||||
using WireMock.Settings;
|
||||
using WireMock.Types;
|
||||
using WireMock.Util;
|
||||
|
||||
@@ -15,7 +16,7 @@ namespace WireMock.Transformers;
|
||||
/// JSON body transformer implementation based on System.Text.Json.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public class SystemTextJsonBodyTransformer() : IJsonBodyTransformer
|
||||
public class SystemTextJsonBodyTransformer(WireMockServerSettings settings) : IJsonBodyTransformer
|
||||
{
|
||||
private static readonly SystemTextJsonConverter _jsonConverter = new();
|
||||
|
||||
@@ -85,7 +86,7 @@ public class SystemTextJsonBodyTransformer() : IJsonBodyTransformer
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore and return as string.
|
||||
settings.Logger.Warn("Failed to parse string ''{0}'' as JSON. Returning the original string value.", stringValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user