diff --git a/src/Http/Http.Extensions/src/HttpJsonServiceExtensions.cs b/src/Http/Http.Extensions/src/HttpJsonServiceExtensions.cs new file mode 100644 index 000000000000..75ceafdb0ac7 --- /dev/null +++ b/src/Http/Http.Extensions/src/HttpJsonServiceExtensions.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Http.Json; + +namespace Microsoft.Extensions.DependencyInjection; + +/// +/// Extension methods to configure JSON serialization behavior. +/// +public static class RouteHandlerJsonServiceExtensions +{ + /// + /// Configures options used for reading and writing JSON by route handlers. + /// + /// + /// The options configured here will only affect JSON returned and processed + /// from route handlers, not controllers, when using + /// and . + /// + /// The to configure options on. + /// The to configure the + /// . + /// The modified . + public static IServiceCollection ConfigureRouteHandlerJsonOptions(this IServiceCollection services, Action configureOptions) + { + services.Configure(configureOptions); + return services; + } +} diff --git a/src/Http/Http.Extensions/src/PublicAPI.Unshipped.txt b/src/Http/Http.Extensions/src/PublicAPI.Unshipped.txt index 7dc5c58110bf..1030d0f0793e 100644 --- a/src/Http/Http.Extensions/src/PublicAPI.Unshipped.txt +++ b/src/Http/Http.Extensions/src/PublicAPI.Unshipped.txt @@ -1 +1,3 @@ #nullable enable +Microsoft.Extensions.DependencyInjection.RouteHandlerJsonServiceExtensions +static Microsoft.Extensions.DependencyInjection.RouteHandlerJsonServiceExtensions.ConfigureRouteHandlerJsonOptions(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action! configureOptions) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!