五、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