public class OrderTagsDocumentFilter : IDocumentFilter
    {
        public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
        {
            swaggerDoc.Tags = swaggerDoc.Tags
                 .OrderByDescending(x => x.Name).ToList();
        }
    }
services.AddSwaggerGen(c =>
                {
           c.OrderActionsBy(x =>
                    {
                        return $"{x.ActionDescriptor.RouteValues["controller"]}_{x.HttpMethod}";
                    });
                   c.DocumentFilter<OrderTagsDocumentFilter>();
                });

 

posted on 2022-11-07 17:01  不知勿言  阅读(370)  评论(0编辑  收藏  举报