添加AspNet.OData nuget后,名为'abc'的Swagger(Swashbuckle)路由已经在路由收集异常中

时间:2018-06-22 18:13:51

标签: odata swagger swashbuckle

我在生产中已有一个现有的webapi,它正在使用swashbuckle并呈现大摇大摆的UI。我现在正在使用Odata客户端从我的webapi代码与odata服务进行通信,并且一旦添加Microsoft.AspNet.OData“ version =” 5.9.0 nuget程序包,则Swagger.Config中的.EnableSwagger一直有效引发错误。

如果我删除了odata nuget,那么一切都会恢复正常。 是因为存在任何冲突的dll,还是swashbuckle与AspNet.OData之间的路由解析逻辑? webapi使用url版本格式,该格式使用.AddVersionedApiExplorer(o => o.GroupNameFormat =“'v'VVV”);

StackTrace:

{"A route named 'abc' is already in the route collection. 
  Route names must be unique.
  Parameter name: name"}

at System.Web.Routing.RouteCollection.Add(String name, RouteBase item)
at System.Web.Http.Routing.AttributeRoutingMapper.AddGenerationHooksForSubRoutes(HttpRouteCollection routeTable, IEnumerable`1 entries)
at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<MapAttributeRoutes>b__0(HttpConfiguration config)
at System.Web.Http.HttpConfiguration.ApplyControllerSettings(HttpControllerSettings settings, HttpConfiguration configuration)
at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
at System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType)
at Microsoft.Web.Http.Description.VersionedApiExplorer.FlattenApiVersions()
at Microsoft.Web.Http.Description.VersionedApiExplorer.InitializeApiDescriptions()
at System.Lazy'1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy'1.get_Value()

0 个答案:

没有答案