언어

OpenApiDocumentTransformerContext.DescriptionGroups 속성

정의

애플리케이션에 대한 API 설명 그룹을 가져옵니다.

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)

속성 값

예제

// 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}");
}

설명

각각 ApiDescriptionGroup 에는 API 엔드포인트를 설명하는 항목 컬렉션 ApiDescription 이 포함되어 있습니다. 이러한 설명은 HTTP 메서드, 상대 경로, 지원되는 요청/응답 형식 및 매개 변수와 같은 각 엔드포인트에 대한 메타데이터를 제공합니다.

이 속성에는 현재 문서에 포함된 엔드포인트뿐만 아니라 애플리케이션의 모든 API 설명이 포함됩니다. 이 문서의 ShouldInclude 엔드포인트에 해당하는 설명을 확인하려면 설명을 필터링합니다.

적용 대상