a lot changed
548b714372b0b92c7bcf124a392b128fc7459f4b
15 files changed
src/Mvc.ModelBinding.MultiParameter.Testing/Controllers/ComplexController.cssrc/Mvc.ModelBinding.MultiParameter.Testing/Program.cssrc/Mvc.ModelBinding.MultiParameter/BindingSourceValueProvider.cssrc/Mvc.ModelBinding.MultiParameter/CookyValueProviderFactory.cssrc/Mvc.ModelBinding.MultiParameter/FormValueProviderFactory.cssrc/Mvc.ModelBinding.MultiParameter/FromCookyAttribute.cssrc/Mvc.ModelBinding.MultiParameter/GenericModelBinderProvider.cssrc/Mvc.ModelBinding.MultiParameter/GenericValueProvider.cssrc/Mvc.ModelBinding.MultiParameter/HeaderValueProviderFactory.cssrc/Mvc.ModelBinding.MultiParameter/IBindingSourceValueProvider.cssrc/Mvc.ModelBinding.MultiParameter/JsonValueProviderFactory.cssrc/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csprojsrc/Mvc.ModelBinding.MultiParameter/QueryStringValueProviderFactory.cssrc/Mvc.ModelBinding.MultiParameter/RouteValueProviderFactory.cssrc/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
diff --git a/src/Mvc.ModelBinding.MultiParameter.Testing/Controllers/ComplexController.cs b/src/Mvc.ModelBinding.MultiParameter.Testing/Controllers/ComplexController.cs
index 78d2268..90e7b9c 100644
--- a/src/Mvc.ModelBinding.MultiParameter.Testing/Controllers/ComplexController.cs
+++ b/src/Mvc.ModelBinding.MultiParameter.Testing/Controllers/ComplexController.cs
@@ -507,6 +507,7 @@ public class ApiController : ControllerBase
Length = file.Length;
using var ms = new MemoryStream();
await file.CopyToAsync(ms); // some dummy operation
+
}
return Ok(new
{
diff --git a/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs b/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs
index ca6da5a..2ee08b1 100644
--- a/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs
+++ b/src/Mvc.ModelBinding.MultiParameter.Testing/Program.cs
@@ -6,7 +6,7 @@ var builder = WebApplication.CreateBuilder(new WebApplicationOptions
ContentRootPath = AppDomain.CurrentDomain.BaseDirectory
});
-builder.Services.AddMvcCore().WithMultiParameterModelBinding();
+builder.Services.AddMvcCore().WithMultiParameterModelBinding(SanitizeAll: true);
builder.Services.AddDistributedMemoryCache();
diff --git a/src/Mvc.ModelBinding.MultiParameter/BindingSourceValueProvider.cs b/src/Mvc.ModelBinding.MultiParameter/BindingSourceValueProvider.cs
deleted file mode 100644
index 5e43e30..0000000
--- a/src/Mvc.ModelBinding.MultiParameter/BindingSourceValueProvider.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-
-// BindingSourceValueProvider
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
-namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
-
-public abstract class BindingSourceValueProvider : IBindingSourceValueProvider
-{
- /// <summary>
- /// Initializes a new instance of the <see cref="BindingSourceValueProvider"/> class.
- /// </summary>
- /// <param name="bindingSource">
- /// The <see cref="BindingSource"/> associated with this provider.
- /// Must be a single-source (non-composite) with <see cref="BindingSource.IsGreedy"/> set to <c>false</c>.
- /// </param>
- /// <exception cref="ArgumentNullException">Thrown when <paramref name="bindingSource"/> is null.</exception>
- public BindingSourceValueProvider(BindingSource bindingSource)
- {
- ArgumentNullException.ThrowIfNull(bindingSource);
-
- BindingSource = bindingSource;
- }
-
- /// <summary>
- /// Gets the corresponding <see cref="ModelBinding.BindingSource"/>.
- /// </summary>
- protected BindingSource BindingSource { get; }
-
- /// <inheritdoc />
- public abstract bool ContainsPrefix(string prefix);
-
- /// <inheritdoc />
- public virtual ValueProviderResult GetValue(string key)
- {
- return ValueProviderResult.None;
- }
-
- /// <inheritdoc />
- public virtual IValueProvider? Filter(BindingSource bindingSource)
- {
- ArgumentNullException.ThrowIfNull(bindingSource);
-
- return bindingSource.CanAcceptDataFrom(BindingSource) ? this : null;
- }
-
- public virtual object? GetModel(string key, Type t)
- {
- return null;
- }
-
-}
-
diff --git a/src/Mvc.ModelBinding.MultiParameter/CookyValueProviderFactory.cs b/src/Mvc.ModelBinding.MultiParameter/CookyValueProviderFactory.cs
index fda8d3e..792a5ce 100644
--- a/src/Mvc.ModelBinding.MultiParameter/CookyValueProviderFactory.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/CookyValueProviderFactory.cs
@@ -1,9 +1,3 @@
-
-// CookyValueProviderFactory
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
using System.Text.Json;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
diff --git a/src/Mvc.ModelBinding.MultiParameter/FormValueProviderFactory.cs b/src/Mvc.ModelBinding.MultiParameter/FormValueProviderFactory.cs
index 2f54a64..aa028c8 100644
--- a/src/Mvc.ModelBinding.MultiParameter/FormValueProviderFactory.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/FormValueProviderFactory.cs
@@ -1,16 +1,7 @@
-
-// FormValueProviderFactory
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
-using System.Text.Json;
+using System.Text.Json;
using Microsoft.AspNetCore.Http;
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
/// <summary>
@@ -21,9 +12,10 @@ public class FormValueProviderFactory(JsonSerializerOptions? jsonSerializerOptio
/// <inheritdoc />
public Task CreateValueProviderAsync(ValueProviderFactoryContext? context)
{
- if (context?.ActionContext?.HttpContext?.Request is { HasFormContentType: true })
+ if (context?.ActionContext?.HttpContext?.Request is { HasFormContentType: true } )
{
// Allocating a Task only when the body is form data.
+
return AddValueProviderAsync(context);
}
diff --git a/src/Mvc.ModelBinding.MultiParameter/FromCookyAttribute.cs b/src/Mvc.ModelBinding.MultiParameter/FromCookyAttribute.cs
index da667a9..e19b249 100644
--- a/src/Mvc.ModelBinding.MultiParameter/FromCookyAttribute.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/FromCookyAttribute.cs
@@ -1,10 +1,4 @@
-
-// FromCookyAttribute
-// (C) 2022 Alphons van der Heijden
-// Date: 2022-04-10
-// Version: 1.2
-
-using Microsoft.AspNetCore.Http.Metadata;
+using Microsoft.AspNetCore.Http.Metadata;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
diff --git a/src/Mvc.ModelBinding.MultiParameter/GenericModelBinderProvider.cs b/src/Mvc.ModelBinding.MultiParameter/GenericModelBinderProvider.cs
index e332121..3f0f67d 100644
--- a/src/Mvc.ModelBinding.MultiParameter/GenericModelBinderProvider.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/GenericModelBinderProvider.cs
@@ -1,10 +1,4 @@
-
-// GenericModelBinder
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
-using System.Runtime.ExceptionServices;
+using System.Runtime.ExceptionServices;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
@@ -12,19 +6,8 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
/// <summary>
/// An <see cref="IGetModelProvider"/> sufficient for most objects.
/// </summary>
-public class GenericModelBinder : IModelBinder
+public class GenericModelBinder(Type type) : IModelBinder
{
- private readonly Type type;
-
- /// <summary>
- /// Initializes a new instance of <see cref="GenericModelBinder"/>.
- /// </summary>
- /// <param name="type">The type to create binder for.</param>
- public GenericModelBinder(Type type)
- {
- this.type = type ?? throw new ArgumentNullException(nameof(type));
- }
-
public Task BindModelAsync(ModelBindingContext? bindingContext)
{
ArgumentNullException.ThrowIfNull(bindingContext);
@@ -55,7 +38,7 @@ public class GenericModelBinder : IModelBinder
try
{
- var model = getModelProvider.GetModel(defaultContext.OriginalModelName, this.type);
+ var model = getModelProvider.GetModel(defaultContext.OriginalModelName, type);
bindingContext.Result = ModelBindingResult.Success(model);
diff --git a/src/Mvc.ModelBinding.MultiParameter/GenericValueProvider.cs b/src/Mvc.ModelBinding.MultiParameter/GenericValueProvider.cs
index 76e6948..7fed27d 100644
--- a/src/Mvc.ModelBinding.MultiParameter/GenericValueProvider.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/GenericValueProvider.cs
@@ -1,9 +1,3 @@
-
-// GenericValueProvider
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
using System.Text.Json;
using System.ComponentModel;
@@ -15,12 +9,16 @@ public class GenericValueProvider(
BindingSource bindingSource,
JsonDocument? jsonDocument,
IFormCollection? formCollection,
- JsonSerializerOptions? jsonSerializerOptions) : BindingSourceValueProvider(bindingSource)
+ JsonSerializerOptions? jsonSerializerOptions) : IBindingSourceValueProvider
{
- public override bool ContainsPrefix(string prefix)
- {
- //System.Diagnostics.Debug.WriteLine($"ContainsPrefix({prefix}) BIndingSource:{BindingSource.DisplayName}");
+ public ValueProviderResult GetValue(string key) =>
+ ValueProviderResult.None;
+
+ public IValueProvider? Filter(BindingSource bindingSourceFilter) =>
+ bindingSource.CanAcceptDataFrom(bindingSourceFilter) ? this : null;
+ public bool ContainsPrefix(string prefix)
+ {
if (jsonDocument != null &&
jsonDocument.RootElement.ValueKind == JsonValueKind.Object &&
jsonDocument.RootElement.TryGetProperty(prefix, out _))
@@ -45,7 +43,7 @@ public class GenericValueProvider(
/// <param name="key">name of the model</param>
/// <param name="t">type of the model</param>
/// <returns>null or object model of type</returns>
- public override object? GetModel(string key, Type t)
+ public object? GetModel(string key, Type t)
{
//System.Diagnostics.Debug.WriteLine($"GetModel({key}) BIndingSource:{BindingSource.DisplayName}");
@@ -84,7 +82,9 @@ public class GenericValueProvider(
}
if (formCollection.Files != null && t == typeof(IFormFile))
+ {
return formCollection.Files.FirstOrDefault(x => x.Name == key);
+ }
}
return null;
}
diff --git a/src/Mvc.ModelBinding.MultiParameter/HeaderValueProviderFactory.cs b/src/Mvc.ModelBinding.MultiParameter/HeaderValueProviderFactory.cs
index 6c2bc58..2356d6c 100644
--- a/src/Mvc.ModelBinding.MultiParameter/HeaderValueProviderFactory.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/HeaderValueProviderFactory.cs
@@ -1,10 +1,3 @@
-
-// HeaderValueProviderFactory
-// (C) 2022 Alphons van der Heijden
-// Date: 2022-04-10
-// Version: 1.2
-
-
using System.Text.Json;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
diff --git a/src/Mvc.ModelBinding.MultiParameter/IBindingSourceValueProvider.cs b/src/Mvc.ModelBinding.MultiParameter/IBindingSourceValueProvider.cs
index 39c8430..41edc03 100644
--- a/src/Mvc.ModelBinding.MultiParameter/IBindingSourceValueProvider.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/IBindingSourceValueProvider.cs
@@ -1,31 +1,7 @@
-
-// IBindingSourceValueProvider
-// (C) 2022 Alphons van der Heijden
-// Date: 2022-04-10
-// Version: 1.2
+namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
-
-/// <summary>
-/// A value provider which can filter its contents based on <see cref="BindingSource"/>.
-/// </summary>
-/// <remarks>
-/// Value providers are by-default included. If a model does not specify a <see cref="BindingSource"/>
-/// then all value providers are valid.
-/// </remarks>
public interface IBindingSourceValueProvider : IValueProvider
{
- /// <summary>
- /// Filters the value provider based on <paramref name="bindingSource"/>.
- /// </summary>
- /// <param name="bindingSource">The <see cref="BindingSource"/> associated with a model.</param>
- /// <returns>
- /// The filtered value provider, or <c>null</c> if the value provider does not match
- /// <paramref name="bindingSource"/>.
- /// </returns>
IValueProvider? Filter(BindingSource bindingSource);
object? GetModel(string key, Type t);
diff --git a/src/Mvc.ModelBinding.MultiParameter/JsonValueProviderFactory.cs b/src/Mvc.ModelBinding.MultiParameter/JsonValueProviderFactory.cs
index 84bcd33..fc6c35a 100644
--- a/src/Mvc.ModelBinding.MultiParameter/JsonValueProviderFactory.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/JsonValueProviderFactory.cs
@@ -1,9 +1,4 @@
-// JsonValueProviderFactory
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
using System.Text.Json;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
@@ -25,30 +20,28 @@ public class JsonValueProviderFactory(JsonSerializerOptions? jsonSerializerOptio
return Task.CompletedTask;
}
- private async Task AddValueProviderAsync(ValueProviderFactoryContext context)
+ private async Task AddValueProviderAsync(ValueProviderFactoryContext? context)
{
- var request = context.ActionContext.HttpContext.Request;
- JsonDocument jsonDocument;
+ if (context?.ActionContext?.HttpContext?.Request?.Body is not Stream body)
+ return;
+
try
{
- jsonDocument = await JsonDocument.ParseAsync(request.Body);
+ var jsonDocument = await JsonDocument.ParseAsync(body);
+
+ context.ValueProviders.Add(new GenericValueProvider(
+ BindingSource.Body,
+ jsonDocument: jsonDocument,
+ formCollection: null,
+ jsonSerializerOptions: jsonSerializerOptions));
}
catch (JsonException ex)
{
- // ParseAsync can throw JsonException if the stream is no json element.
- // Wrap it in a ValueProviderException that the CompositeValueProvider special cases.
- throw new ValueProviderException(ex.Message, ex);
+ throw new ValueProviderException("Invalid JSON format.", ex);
}
catch (Exception ex)
{
- // Wrap it in a ValueProviderException that the CompositeValueProvider special cases.
- throw new ValueProviderException(ex.Message, ex);
+ throw new ValueProviderException("An error occurred while adding the value provider.", ex);
}
-
- context.ValueProviders.Add(new GenericValueProvider(
- BindingSource.Body,
- jsonDocument: jsonDocument,
- formCollection: null,
- jsonSerializerOptions: jsonSerializerOptions));
}
}
diff --git a/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj b/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj
index e397438..1fc6d3e 100644
--- a/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj
+++ b/src/Mvc.ModelBinding.MultiParameter/Mvc.ModelBinding.MultiParameter.csproj
@@ -10,11 +10,11 @@
<RepositoryUrl>https://github.com/alphons/Mvc.ModelBinding.MultiParameter.git</RepositoryUrl>
<Description>New ValueProviders and ModelBinder for multi parameters model binding out of the box on AspNetCore</Description>
<PackageDescription>New ValueProviders and ModelBinder for multi parameters model binding out of the box on AspNetCore</PackageDescription>
- <Version>1.2.0</Version>
+ <Version>1.2.1</Version>
<PackageId>Mvc.ModelBinding.MultiParameter</PackageId>
<Authors>alphons</Authors>
- <AssemblyVersion>8.1.2.0</AssemblyVersion>
- <FileVersion>8.1.2.0</FileVersion>
+ <AssemblyVersion>8.1.2.1</AssemblyVersion>
+ <FileVersion>8.1.2.1</FileVersion>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageTags>Microsoft;AspNetCore;Mvc;AspNetCoreMvc;json</PackageTags>
<PackageIcon>icon.png</PackageIcon>
diff --git a/src/Mvc.ModelBinding.MultiParameter/QueryStringValueProviderFactory.cs b/src/Mvc.ModelBinding.MultiParameter/QueryStringValueProviderFactory.cs
index 8d84db1..4ce16ee 100644
--- a/src/Mvc.ModelBinding.MultiParameter/QueryStringValueProviderFactory.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/QueryStringValueProviderFactory.cs
@@ -1,21 +1,8 @@
-// QueryStringValueProviderFactory
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
using System.Text.Json;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
-
-/// <summary>
-/// A <see cref="IValueProviderFactory"/> that creates <see cref="GenericValueProvider"/> instances that
-/// read values from the request query-string.
-/// </summary>
public class QueryStringValueProviderFactory(JsonSerializerOptions? jsonSerializerOptions) : IValueProviderFactory
{
/// <inheritdoc />
diff --git a/src/Mvc.ModelBinding.MultiParameter/RouteValueProviderFactory.cs b/src/Mvc.ModelBinding.MultiParameter/RouteValueProviderFactory.cs
index 85433f0..a5dc828 100644
--- a/src/Mvc.ModelBinding.MultiParameter/RouteValueProviderFactory.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/RouteValueProviderFactory.cs
@@ -1,19 +1,8 @@
-// RouteValueProviderFactory
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
using System.Text.Json;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.MultiParameter;
-/// <summary>
-/// A <see cref="IValueProviderFactory"/> for creating <see cref="GenericValueProvider"/> instances.
-/// </summary>
public class RouteValueProviderFactory(JsonSerializerOptions? jsonSerializerOptions) : IValueProviderFactory
{
/// <inheritdoc />
diff --git a/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs b/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
index c5135e0..eaf1f1c 100644
--- a/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
+++ b/src/Mvc.ModelBinding.MultiParameter/WithMultiParameterModelBindingExtensions.cs
@@ -1,11 +1,4 @@
-
-// WithMultiParameterBindingExtensions
-// (C) 2022 Alphons van der Heijden
-// Version: 1.2 Date: 2022-04-10
-// Version: 1.3 Date: 2024-11-23
-
-
-using System.Text.Json;
+using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
using Microsoft.AspNetCore.Mvc.Formatters;
@@ -21,19 +14,24 @@ public static class WithMultiParameterModelBindingExtensions
/// <param name="builder">IMvcCoreBuilder</param>
/// <param name="jsonSerializerOptions">JsonSerializerOptions</param>
/// <returns>IMvcCoreBuilder</returns>
- public static IMvcCoreBuilder WithMultiParameterModelBinding(this IMvcCoreBuilder builder, JsonSerializerOptions? jsonSerializerOptions = null)
+ public static IMvcCoreBuilder WithMultiParameterModelBinding(this IMvcCoreBuilder builder, JsonSerializerOptions? jsonSerializerOptions = null, bool SanitizeAll = false)
{
return builder.AddMvcOptions(options =>
{
+ if (SanitizeAll)
+ {
+ options.InputFormatters.Clear();
+ options.ModelValidatorProviders.Clear();
+ options.Conventions.Clear();
+ options.Filters.Clear();
+ options.ModelMetadataDetailsProviders.Clear();
+ options.ModelValidatorProviders.Clear();
+ options.ModelMetadataDetailsProviders.Clear();
+ options.OutputFormatters.Clear();
+ }
+
options.InputFormatters.RemoveType<SystemTextJsonInputFormatter>();
- //options.ModelValidatorProviders.Clear();
- //options.Conventions.Clear();
- //options.Filters.Clear();
- //options.ModelMetadataDetailsProviders.Clear();
- //options.ModelValidatorProviders.Clear();
- //options.ModelMetadataDetailsProviders.Clear();
- //options.OutputFormatters.Clear();
jsonSerializerOptions ??= new JsonSerializerOptions();
@@ -57,22 +55,12 @@ public static class WithMultiParameterModelBindingExtensions
options.ValueProviderFactories.Add(new RouteValueProviderFactory(jsonSerializerOptions));
options.ValueProviderFactories.Add(new FormValueProviderFactory(jsonSerializerOptions));
- // Generic binder gettings complete de-serialized models of
- // GenericValueProvider
+ // GenericModelBinderProvider gets de-serialized models of GenericValueProvider
options.ModelBinderProviders.Clear();
options.ModelBinderProviders.Add(new GenericModelBinderProvider());
- // delete existing JsonOutputFormatter
- for (int i = options.OutputFormatters.Count - 1; i >= 0; i--)
- {
- var formatter = options.OutputFormatters[i];
- if (formatter.GetType() == typeof(SystemTextJsonOutputFormatter))
- {
- options.OutputFormatters.Remove(formatter);
- }
- }
-
- // add new JsonOutputFormatter
+ // replace SystemTextJsonOutputFormatter having jsonSerializerOptions
+ options.OutputFormatters.RemoveType<SystemTextJsonOutputFormatter>();
options.OutputFormatters.Add(new SystemTextJsonOutputFormatter(jsonSerializerOptions));
});
}