Closed JohanKarnell closed 4 years ago
I have the same issue.
I see 4 of these in the Debug console:
Exception thrown: 'System.Web.Http.HttpResponseException' in System.Web.OData.dll
My setup is exactly like yours (OData + Swashbuckle + Swashbuckle.OData). Everything seems to work fine, but thrown exceptions don't exactly make you feel great...
It's definitely tied to Swashbuckle.OData somehow. If I remove the line setting it as the custom Swagger provider, issue goes away.
Hi,
I have an OData Web API with Entity Framework on which I want to add swagger.
Short description of my Web API: OData Web API using Entity Framework to retrieve data from a db. The Web API has a custom DelegatingHandler executed before the controllers that I use to log the request/response to a third party application.
The issue I am facing: Visual Studio 2015 diagnostic events shows that a lot of errors are thrown and handled in System.Web.OData.dll and System.Web.Http.dll during debugging when the operations are loaded after browsing to http://localhost:port/swagger. But the operations are loaded successfully in the web browser and trying them out works as well.
Error message 1 logged in Visual Studio Diagnostics log during debugging: Exception thrown: 'System.Web.Http.HttpResponseException' in System.Web.OData.dll Error message 2 logged in Visual Studio Diagnostics log during debugging: Exception thrown: 'System.Web.Http.HttpResponseException' in System.Web.Http.dll
Followed these steps when adding swagger to my Web API:
Installed Swashbuckle nuget package (5.6.0)
Installed Swashbuckle.OData nuget package (3.4.0)
Added this to .EnableSwagger in order to include NavigationProperties c.CustomProvider(defaultProvider => new ODataSwaggerProvider(defaultProvider, c, GlobalConfiguration.Configuration).Configure(odataConfig => { odataConfig.EnableSwaggerRequestCaching(); odataConfig.IncludeNavigationProperties(); }));
Started debugging Web API in Visual Studio 2015 Update 3
Web API loads successfully and then I browse to "/swagger"![bild](https://user-images.githubusercontent.com/3234605/31932244-1ca25300-b8a6-11e7-8ab7-067b00cc6023.png)
Swagger starts loading the operations but suddently a lot of exceptions with the errors mentioned earlier is shown in the diagnostics event log![bild](https://user-images.githubusercontent.com/3234605/31932272-2d8aa762-b8a6-11e7-9bec-cfc51dad9886.png)
Swagger UI loads the operations successfully and then it's possible to look at all the operations and try them out![bild](https://user-images.githubusercontent.com/3234605/31932507-c143eea0-b8a6-11e7-8b60-d22c9145a65b.png)
Everything seems to work but I cannot understand why the errors are thrown
Question: Any ideas what the errors showing in the Visual Studio Diagnostic events are and why they occur?
I have not been able to get a more detailed error description than the ones described above. I understand that this is probably not an issue with Swashbuckle since I haven't been able to find anyone else with similar issues but I couldn't think of a better place to ask my Question.