diff --git a/src/OpenApi/src/Extensions/OpenApiServiceCollectionExtensions.cs b/src/OpenApi/src/Extensions/OpenApiServiceCollectionExtensions.cs index aef8d1794616..a5baa31a3c3c 100644 --- a/src/OpenApi/src/Extensions/OpenApiServiceCollectionExtensions.cs +++ b/src/OpenApi/src/Extensions/OpenApiServiceCollectionExtensions.cs @@ -1,6 +1,7 @@ // 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.Builder; using Microsoft.AspNetCore.Http.Json; using Microsoft.AspNetCore.OpenApi; using Microsoft.Extensions.ApiDescriptions; @@ -19,6 +20,14 @@ public static class OpenApiServiceCollectionExtensions /// /// The to register services onto. /// The name of the OpenAPI document associated with registered services. + /// + /// This method is commonly used to add OpenAPI services to the + /// of a , as shown in the following example: + /// + /// var builder = WebApplication.CreateBuilder(args); + /// builder.Services.AddOpenApi("MyWebApi"); + /// + /// public static IServiceCollection AddOpenApi(this IServiceCollection services, string documentName) { ArgumentNullException.ThrowIfNull(services); @@ -32,6 +41,17 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, st /// The to register services onto. /// The name of the OpenAPI document associated with registered services. /// A delegate used to configure the target . + /// + /// This method is commonly used to add OpenAPI services to the + /// of a , as shown in the following example: + /// + /// var builder = WebApplication.CreateBuilder(args); + /// builder.Services.AddOpenApi("MyWebApi", options => { + /// // Add a custom schema transformer for decimal types + /// options.AddSchemaTransformer(DecimalTransformer.TransformAsync); + /// }); + /// + /// public static IServiceCollection AddOpenApi(this IServiceCollection services, string documentName, Action configureOptions) { ArgumentNullException.ThrowIfNull(services); @@ -51,6 +71,17 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, st /// /// The to register services onto. /// A delegate used to configure the target . + /// + /// This method is commonly used to add OpenAPI services to the + /// of a , as shown in the following example: + /// + /// var builder = WebApplication.CreateBuilder(args); + /// builder.Services.AddOpenApi(options => { + /// // Add a custom schema transformer for decimal types + /// options.AddSchemaTransformer(DecimalTransformer.TransformAsync); + /// }); + /// + /// public static IServiceCollection AddOpenApi(this IServiceCollection services, Action configureOptions) => services.AddOpenApi(OpenApiConstants.DefaultDocumentName, configureOptions); @@ -58,6 +89,14 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, Ac /// Adds OpenAPI services related to the default document to the specified . /// /// The to register services onto. + /// + /// This method is commonly used to add OpenAPI services to the + /// of a , as shown in the following example: + /// + /// var builder = WebApplication.CreateBuilder(args); + /// builder.Services.AddOpenApi(); + /// + /// public static IServiceCollection AddOpenApi(this IServiceCollection services) => services.AddOpenApi(OpenApiConstants.DefaultDocumentName); diff --git a/src/OpenApi/src/Microsoft.AspNetCore.OpenApi.csproj b/src/OpenApi/src/Microsoft.AspNetCore.OpenApi.csproj index 65688d2eb269..a0ef68ed3021 100644 --- a/src/OpenApi/src/Microsoft.AspNetCore.OpenApi.csproj +++ b/src/OpenApi/src/Microsoft.AspNetCore.OpenApi.csproj @@ -20,6 +20,7 @@ +