This commit is contained in:
Stef Heyenrath
2026-02-14 08:59:23 +01:00
23 changed files with 533 additions and 110 deletions

View File

@@ -1,5 +1,6 @@
// Copyright © WireMock.Net
using JsonConverter.Abstractions;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
@@ -7,24 +8,30 @@ namespace WireMock.Serialization;
internal static class JsonSerializationConstants
{
public static readonly JsonSerializerSettings JsonSerializerSettingsDefault = new()
internal static readonly JsonConverterOptions JsonConverterOptionsDefault = new()
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore
WriteIndented = true,
IgnoreNullValues = true
};
public static readonly JsonSerializerSettings JsonSerializerSettingsIncludeNullValues = new()
//internal static readonly JsonSerializerSettings JsonSerializerSettingsDefault = new()
//{
// Formatting = Formatting.Indented,
// NullValueHandling = NullValueHandling.Ignore
//};
internal static readonly JsonSerializerSettings JsonSerializerSettingsIncludeNullValues = new()
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Include
};
public static readonly JsonSerializerSettings JsonDeserializerSettingsWithDateParsingNone = new()
internal static readonly JsonSerializerSettings JsonDeserializerSettingsWithDateParsingNone = new()
{
DateParseHandling = DateParseHandling.None
};
public static readonly JsonSerializerSettings JsonSerializerSettingsPact = new()
internal static readonly JsonSerializerSettings JsonSerializerSettingsPact = new()
{
Formatting = Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,

View File

@@ -1,20 +1,20 @@
// Copyright © WireMock.Net
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using HandlebarsDotNet;
using JetBrains.Annotations;
using JsonConverter.Abstractions;
using JsonConverter.Newtonsoft.Json;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using WireMock.Admin.Mappings;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.Models;
using WireMock.RegularExpressions;
using WireMock.Types;
using System.Globalization;
using WireMock.Models;
using Microsoft.Extensions.DependencyInjection;
namespace WireMock.Settings;
@@ -148,7 +148,7 @@ public class WireMockServerSettings
[JsonIgnore]
public Action<object>? PostWireMockMiddlewareInit { get; set; }
//#if USE_ASPNETCORE
//#if USE_ASPNETCORE
/// <summary>
/// Action which is called with IServiceCollection when ASP.NET Core DI is being configured. [Optional]
/// </summary>
@@ -161,7 +161,7 @@ public class WireMockServerSettings
/// </summary>
[PublicAPI]
public CorsPolicyOptions? CorsPolicyOptions { get; set; }
//#endif
//#endif
/// <summary>
/// The IWireMockLogger which logs Debug, Info, Warning or Error
@@ -246,7 +246,7 @@ public class WireMockServerSettings
[PublicAPI]
public bool CustomCertificateDefined => CertificateSettings?.IsDefined == true;
//#if USE_ASPNETCORE
//#if USE_ASPNETCORE
/// <summary>
/// Client certificate mode for the server
/// </summary>
@@ -257,7 +257,7 @@ public class WireMockServerSettings
/// Whether to accept any client certificate
/// </summary>
public bool AcceptAnyClientCertificate { get; set; }
//#endif
//#endif
/// <summary>
/// Defines the global IWebhookSettings to use.
@@ -347,6 +347,16 @@ public class WireMockServerSettings
[PublicAPI]
public ActivityTracingOptions? ActivityTracingOptions { get; set; }
/// <summary>
/// Gets or sets the default JSON converter used for serialization.
/// </summary>
/// <remarks>
/// Set this property to customize how objects are serialized to and deserialized from JSON during mapping.
/// Default is <see cref="NewtonsoftJsonConverter"/>.
/// </remarks>
[PublicAPI]
public IJsonConverter DefaultJsonSerializer { get; set; } = new NewtonsoftJsonConverter();
/// <summary>
/// WebSocket settings.
/// </summary>

View File

@@ -2,7 +2,6 @@
<PropertyGroup>
<Description>Shared interfaces, models, enumerations and types.</Description>
<Authors>Stef Heyenrath</Authors>
<!--<TargetFrameworks>net451;net452;net46;net462;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>-->
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>tdd;mock;http;wiremock;test;server;shared</PackageTags>
@@ -30,9 +29,8 @@
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.9" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="AnyOf" Version="0.5.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="JsonConverter.Abstractions" Version="0.7.2" />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.8.0" />
</ItemGroup>
<ItemGroup>