|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
| 3 | +using System.IO; |
| 4 | +using System.Reflection; |
3 | 5 | using System.Xml.XPath; |
4 | | -using Microsoft.OpenApi.Models; |
| 6 | +using Microsoft.AspNetCore.Authentication; |
5 | 7 | using Microsoft.AspNetCore.Mvc.ApiExplorer; |
| 8 | +using Microsoft.OpenApi.Models; |
6 | 9 | using Swashbuckle.AspNetCore.SwaggerGen; |
7 | | -using Microsoft.AspNetCore.Authentication; |
8 | 10 |
|
9 | 11 | namespace Microsoft.Extensions.DependencyInjection |
10 | 12 | { |
@@ -556,6 +558,26 @@ public static void IncludeXmlComments( |
556 | 558 | swaggerGenOptions.IncludeXmlComments(() => new XPathDocument(filePath), includeControllerXmlComments); |
557 | 559 | } |
558 | 560 |
|
| 561 | + /// <summary> |
| 562 | + /// Inject human-friendly descriptions for Operations, Parameters and Schemas based on XML comments |
| 563 | + /// from specific Assembly |
| 564 | + /// </summary> |
| 565 | + /// <param name="swaggerGenOptions"></param> |
| 566 | + /// <param name="assembly">Assembly that contains XML Comments</param> |
| 567 | + /// <param name="includeControllerXmlComments"> |
| 568 | + /// Flag to indicate if controller XML comments (i.e. summary) should be used to assign Tag descriptions. |
| 569 | + /// Don't set this flag if you're customizing the default tag for operations via TagActionsBy. |
| 570 | + /// </param> |
| 571 | + public static void IncludeXmlComments( |
| 572 | + this SwaggerGenOptions swaggerGenOptions, |
| 573 | + Assembly assembly, |
| 574 | + bool includeControllerXmlComments = false) |
| 575 | + { |
| 576 | + swaggerGenOptions.IncludeXmlComments( |
| 577 | + Path.Combine(AppContext.BaseDirectory, $"{assembly.GetName().Name}.xml"), |
| 578 | + includeControllerXmlComments); |
| 579 | + } |
| 580 | + |
559 | 581 | /// <summary> |
560 | 582 | /// Generate polymorphic schemas (i.e. "oneOf") based on discovered subtypes. |
561 | 583 | /// Deprecated: Use the \"UseOneOfForPolymorphism\" and \"UseAllOfForInheritance\" settings instead |
|
0 commit comments