雪花

五、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>();

效果:

 

posted @ 2019-12-25 12:38  十色  阅读(2238)  评论(0编辑  收藏  举报