如何让swagger 2.0支持WebApi区域?

时间:2016-02-18 07:45:39

标签: asp.net swagger swagger-2.0 swashbuckle

我将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生成文档包含重复项目。commonactive具有相同的控制器+动作。就像这样:

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}

0 个答案:

没有答案