OpenApiDocumentTransformerContext.DescriptionGroups Property

Definition

Gets the API description groups for the application.

public System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroup> DescriptionGroups { get; init; }
member this.DescriptionGroups : System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroup> with get, set
Public Property DescriptionGroups As IReadOnlyList(Of ApiDescriptionGroup)

Property Value

Examples

// Filter to only the API descriptions included in this document
var options = context.ApplicationServices
    .GetRequiredService<IOptionsMonitor<OpenApiOptions>>()
    .Get(context.DocumentName);
var descriptions = context.DescriptionGroups
    .SelectMany(g => g.Items)
    .Where(options.ShouldInclude);
foreach (var description in descriptions)
{
    Console.WriteLine($"{description.HttpMethod} {description.RelativePath}");
}

Remarks

Each ApiDescriptionGroup contains a collection of ApiDescription items that describe API endpoints. These descriptions provide metadata about each endpoint such as the HTTP method, relative path, supported request/response formats, and parameters.

This property contains all API descriptions from the application, not only the endpoints included in the current document. To determine which descriptions correspond to endpoints in this document, use ShouldInclude to filter the descriptions.

Applies to