11// Licensed to the .NET Foundation under one or more agreements. 
22// The .NET Foundation licenses this file to you under the MIT license. 
33
4+ using  Microsoft . AspNetCore . Builder ; 
45using  Microsoft . AspNetCore . Http . Json ; 
56using  Microsoft . AspNetCore . OpenApi ; 
67using  Microsoft . Extensions . ApiDescriptions ; 
@@ -19,6 +20,14 @@ public static class OpenApiServiceCollectionExtensions
1920    /// </summary> 
2021    /// <param name="services">The <see cref="IServiceCollection"/> to register services onto.</param> 
2122    /// <param name="documentName">The name of the OpenAPI document associated with registered services.</param> 
23+     /// <example> 
24+     /// This method is commonly used to add OpenAPI services to the <see cref="WebApplicationBuilder.Services"/> 
25+     /// of a <see cref="WebApplicationBuilder"/>, as shown in the following example: 
26+     /// <code> 
27+     /// var builder = WebApplication.CreateBuilder(args); 
28+     /// builder.Services.AddOpenApi("MyWebApi"); 
29+     /// </code> 
30+     /// </example> 
2231    public  static   IServiceCollection  AddOpenApi ( this  IServiceCollection  services ,  string  documentName ) 
2332    { 
2433        ArgumentNullException . ThrowIfNull ( services ) ; 
@@ -32,6 +41,17 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, st
3241    /// <param name="services">The <see cref="IServiceCollection"/> to register services onto.</param> 
3342    /// <param name="documentName">The name of the OpenAPI document associated with registered services.</param> 
3443    /// <param name="configureOptions">A delegate used to configure the target <see cref="OpenApiOptions"/>.</param> 
44+     /// <example> 
45+     /// This method is commonly used to add OpenAPI services to the <see cref="WebApplicationBuilder.Services"/> 
46+     /// of a <see cref="WebApplicationBuilder"/>, as shown in the following example: 
47+     /// <code> 
48+     /// var builder = WebApplication.CreateBuilder(args); 
49+     /// builder.Services.AddOpenApi("MyWebApi", options => { 
50+     ///     // Add a custom schema transformer for decimal types 
51+     ///     options.AddSchemaTransformer(DecimalTransformer.TransformAsync); 
52+     /// }); 
53+     /// </code> 
54+     /// </example> 
3555    public  static   IServiceCollection  AddOpenApi ( this  IServiceCollection  services ,  string  documentName ,  Action < OpenApiOptions >  configureOptions ) 
3656    { 
3757        ArgumentNullException . ThrowIfNull ( services ) ; 
@@ -51,13 +71,32 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, st
5171    /// </summary> 
5272    /// <param name="services">The <see cref="IServiceCollection"/> to register services onto.</param> 
5373    /// <param name="configureOptions">A delegate used to configure the target <see cref="OpenApiOptions"/>.</param> 
74+     /// <example> 
75+     /// This method is commonly used to add OpenAPI services to the <see cref="WebApplicationBuilder.Services"/> 
76+     /// of a <see cref="WebApplicationBuilder"/>, as shown in the following example: 
77+     /// <code> 
78+     /// var builder = WebApplication.CreateBuilder(args); 
79+     /// builder.Services.AddOpenApi(options => { 
80+     ///     // Add a custom schema transformer for decimal types 
81+     ///     options.AddSchemaTransformer(DecimalTransformer.TransformAsync); 
82+     /// }); 
83+     /// </code> 
84+     /// </example> 
5485    public  static   IServiceCollection  AddOpenApi ( this  IServiceCollection  services ,  Action < OpenApiOptions >  configureOptions ) 
5586            =>  services . AddOpenApi ( OpenApiConstants . DefaultDocumentName ,  configureOptions ) ; 
5687
5788    /// <summary> 
5889    /// Adds OpenAPI services related to the default document to the specified <see cref="IServiceCollection"/>. 
5990    /// </summary> 
6091    /// <param name="services">The <see cref="IServiceCollection"/> to register services onto.</param> 
92+     /// <example> 
93+     /// This method is commonly used to add OpenAPI services to the <see cref="WebApplicationBuilder.Services"/> 
94+     /// of a <see cref="WebApplicationBuilder"/>, as shown in the following example: 
95+     /// <code> 
96+     /// var builder = WebApplication.CreateBuilder(args); 
97+     /// builder.Services.AddOpenApi(); 
98+     /// </code> 
99+     /// </example> 
61100    public  static   IServiceCollection  AddOpenApi ( this  IServiceCollection  services ) 
62101        =>  services . AddOpenApi ( OpenApiConstants . DefaultDocumentName ) ; 
63102
0 commit comments