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