首页 > 其他分享 >Swagger UI 显示元素注释内部

Swagger UI 显示元素注释内部

时间:2022-11-30 12:24:11浏览次数:43  
标签:元素 xmlFilename 注释 添加 UI Swagger

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

相关文章