You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that with one of my controller, it requires that you have a parameter less Constructor. If one isn't present, an exception will be thrown when you try to load the swagger UI. Is this a specific requirement for using swashbuckle Odata?
500 : {
"Message": "An error has occurred.",
"ExceptionMessage": "An error occurred when trying to create a controller of type 'ProductsController'. Make sure that the controller has a parameterless public constructor.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n at Swashbuckle.OData.Descriptions.HttpRequestMessageExtensions.GetHttpActionDescriptor(HttpRequestMessage request)\r\n at Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.GetActionDescriptors(HttpMethod httpMethod, Operation potentialOperation, String potentialPathTemplate, ODataRoute oDataRoute, HttpConfiguration httpConfig)\r\n at Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.GetActionDescriptors(SwaggerRoute potentialSwaggerRoute, HttpConfiguration httpConfig)\r\n at Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.<>c__DisplayClass3_0.b__1(SwaggerRoute potentialSwaggerRoute)\r\n at System.Linq.Enumerable.d__12.MoveNext()\r\n at System.Linq.Enumerable.<SelectManyIterator>d__12.MoveNext()\r\n at System.Linq.Enumerable.d__12.MoveNext()\r\n at System.Linq.Enumerable.<DistinctIterator>d__11.MoveNext()\r\n at System.Collections.Generic.List1..ctor(IEnumerable1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at Swashbuckle.OData.CollectionExtentions.ToCollection[T](IEnumerable1 source)\r\n at Swashbuckle.OData.Descriptions.ODataApiExplorer.GetApiDescriptions()\r\n at System.Lazy1.CreateValue()\r\n at System.Lazy1.LazyInitValue()\r\n at System.Lazy1.get_Value()\r\n at Swashbuckle.OData.Descriptions.ODataApiExplorer.get_ApiDescriptions()\r\n at Swashbuckle.OData.ODataSwaggerProvider.GetApiDescriptionsFor(String apiVersion)\r\n at Swashbuckle.OData.ODataSwaggerProvider.GetSwagger(String rootUrl, String apiVersion)\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Cors.CorsMessageHandler.<>n__FabricatedMethod3(HttpRequestMessage , CancellationToken )\r\n at System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at System.Web.Http.HttpServer.d__0.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Type ProductsController' does not have a default constructor",
"ExceptionType": "System.ArgumentException",
"StackTrace": " at System.Linq.Expressions.Expression.New(Type type)\r\n at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"
}
} http://localhost:4448/swagger/docs/v1
Thanks,
D
The text was updated successfully, but these errors were encountered:
It seems that with one of my controller, it requires that you have a parameter less Constructor. If one isn't present, an exception will be thrown when you try to load the swagger UI. Is this a specific requirement for using swashbuckle Odata?
500 : {
"Message": "An error has occurred.",
"ExceptionMessage": "An error occurred when trying to create a controller of type 'ProductsController'. Make sure that the controller has a parameterless public constructor.",
"ExceptionType": "System.InvalidOperationException",
"StackTrace": " at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)\r\n at System.Web.Http.Controllers.HttpControllerDescriptor.CreateController(HttpRequestMessage request)\r\n at Swashbuckle.OData.Descriptions.HttpRequestMessageExtensions.GetHttpActionDescriptor(HttpRequestMessage request)\r\n at Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.GetActionDescriptors(HttpMethod httpMethod, Operation potentialOperation, String potentialPathTemplate, ODataRoute oDataRoute, HttpConfiguration httpConfig)\r\n at Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.GetActionDescriptors(SwaggerRoute potentialSwaggerRoute, HttpConfiguration httpConfig)\r\n at Swashbuckle.OData.Descriptions.SwaggerRouteStrategy.<>c__DisplayClass3_0.b__1(SwaggerRoute potentialSwaggerRoute)\r\n at System.Linq.Enumerable.d__1
2.MoveNext()\r\n at System.Linq.Enumerable.<SelectManyIterator>d__1
2.MoveNext()\r\n at System.Linq.Enumerable.d__12.MoveNext()\r\n at System.Linq.Enumerable.<DistinctIterator>d__1
1.MoveNext()\r\n at System.Collections.Generic.List1..ctor(IEnumerable
1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at Swashbuckle.OData.CollectionExtentions.ToCollection[T](IEnumerable
1 source)\r\n at Swashbuckle.OData.Descriptions.ODataApiExplorer.GetApiDescriptions()\r\n at System.Lazy1.CreateValue()\r\n at System.Lazy
1.LazyInitValue()\r\n at System.Lazy1.get_Value()\r\n at Swashbuckle.OData.Descriptions.ODataApiExplorer.get_ApiDescriptions()\r\n at Swashbuckle.OData.ODataSwaggerProvider.GetApiDescriptionsFor(String apiVersion)\r\n at Swashbuckle.OData.ODataSwaggerProvider.GetSwagger(String rootUrl, String apiVersion)\r\n at Swashbuckle.Application.SwaggerDocsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.HttpMessageInvoker.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)\r\n at System.Web.Http.Cors.CorsMessageHandler.<>n__FabricatedMethod3(HttpRequestMessage , CancellationToken )\r\n at System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()\r\n at System.Web.Http.HttpServer.d__0.MoveNext()","InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Type ProductsController' does not have a default constructor",
"ExceptionType": "System.ArgumentException",
"StackTrace": " at System.Linq.Expressions.Expression.New(Type type)\r\n at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)\r\n at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"
}
} http://localhost:4448/swagger/docs/v1
Thanks,
D
The text was updated successfully, but these errors were encountered: