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

效果:

原文地址:https://www.cnblogs.com/fger/p/12096033.html