五、ASP.NET Core 在 Swagger UI 中顯示Controller描述


一、控制器描述

創建一個過濾器類 AuthTagDescriptions,內容如下:

using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ZanLveCore
{
    public class AuthTagDescriptions : IDocumentFilter
    {
        public void Apply(SwaggerDocument swaggerDoc, DocumentFilterContext context)
        {
            swaggerDoc.Tags = new List<Tag>
            {
                new Tag{ Name="Common",Description="授權中心接口"},
            };
        }
    }

}

更改Swagger配置文件

 options.DocumentFilter<AuthTagDescriptions>();

效果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM