Ⅰ. はじめに
タイトルの通り「.NET 6 Minimal APIでSwaggerのsummaryとdescriptionを設定する方法」です。
Ⅱ. 手順
1. 必要なパッケージをインストールする
dotnet add package Swashbuckle.AspNetCore.Annotations
2. サンプルプログラムを書く
Program.cs
using Swashbuckle.AspNetCore.Annotations; builder.Services.AddSwaggerGen(x => { x.EnableAnnotations(); }); // app.MapGet("/hi", [SwaggerOperation(Summary = "あああああああ", Description = "いいいいいい")] () => "Hi"); app.MapGet("/hi", () => "Hi").WithMetadata(new SwaggerOperationAttribute("あああああああ", "いいいいいい"));
実行結果