proudmonkey / AutoWrapper

A simple, yet customizable global exception handler and Http response wrapper for ASP.NET Core APIs.
MIT License
679 stars 82 forks source link

Need the wrapper to ignore $metadata endpoint when used in an API project containing OData endpoints. #80

Closed ronaldwalcott closed 3 years ago

ronaldwalcott commented 3 years ago

Good day

I have been using the wrapper as below

app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions { IgnoreWrapForOkRequests = true, });

but after implementing OData for some of my APIs I get the below message when calling the $metadata endpoint

This page contains the following errors: error on line 1 at column 1: Document is empty

Screenshot 2020-10-14 201200

commenting out the code allows the XML metadata to display

Screenshot 2020-10-14 201409

Is there a way to ignore this endpoint and still use the wrapper on other endpoints?

Thanks

proudmonkey commented 3 years ago

Hi,

If you can group all your API endpoints that uses AutoWrapper, then you can try setting the WrapWhenApiPathStartsWith and it should ignore the rest of the endpoint.

https://github.com/proudmonkey/AutoWrapper#wrapwhenapipathstartswith