Swagger 路径过滤 -PreSerializeFilters


Swagger 默认显示所有api, 如果要做路径过滤,可以这样做.

            //过滤,只显示部分api
            app.UseSwagger(c=> {
                c.PreSerializeFilters.Add((swaggerDoc, httpReq) => {
                    IDictionary<string, PathItem> paths = new Dictionary<string, PathItem>();
                    foreach (var path in swaggerDoc.Paths)
                    {
                        if(path.Key.StartsWith("/v1/api"))
                            paths.Add(path.Key, path.Value);
                    }
                    swaggerDoc.Paths = paths;
                });
            });

 https://stackoverflow.com/questions/45327119/how-to-set-base-path-property-in-swagger-for-net-core-web-api

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM