我将swagger-ui(版本2.0)整合到我的Asp.Net WebApi 4.0项目中。这是我的路由配置:
config.Routes.MapHttpRoute(
name: "Common_Get",
routeTemplate: "common/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional, action = "Get" },
constraints: new { httpMethod = new HttpMethodConstraint("GET") }
);
config.Routes.MapHttpRoute(
name: "Active_Get",
routeTemplate: "active/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional, action = "Get" },
constraints: new { httpMethod = new HttpMethodConstraint("GET") }
);
swagger-ui生成文档包含重复项目。common
和active
具有相同的控制器+动作。就像这样:
get /common/Advert/GetAdvertise/{id}
get /active/Advert/GetAdvertise/{id}
get /common/award/GetAward/{id}
get /active/award/GetAward/{id}
如何避免此问题或启用swagger支持区域(无论名称)。我可以指定每个控制器的区域。正确的结果可能是这样的:
get /common/Advert/GetAdvertise/{id}
get /active/Award/GetAward/{id}