1,在 以下 代码添加到 .csproj
文件中;
<PropertyGroup> <GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup>
2,在Program.cs文件的。builder.Services.AddSwaggerGen中添加
// using System.Reflection; var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
3,效果
4,docs link
https://learn.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-6.0&tabs=visual-studio
标签:元素,xmlFilename,注释,添加,UI,Swagger From: https://www.cnblogs.com/wenshan/p/16938045.html