joukevandermaas / saule

JSON API library for ASP.Net Web API 2.
https://joukevandermaas.github.io/saule
MIT License
76 stars 37 forks source link

Added logic to still return HttpErrors if there are more than one and if endpoint\controller doesn't have specified ReturnsResource #203

Closed sergey-litvinov-work closed 6 years ago

sergey-litvinov-work commented 6 years ago

Hi Jouke,

Looks like i had an issue last time when i added logic to support case when more than one HttpError is returned. If controller\action doesn't have ReturnResource then for just one HttpError it will work fine and will return that error. But for the list of httpErrors it will try to use ReturnResource. It works fine as deeper it still will use ErrorSerializer, but there is one case that doesn't work.

We have base controller that has some custom attributes, and all controllers inherit it. So base one doesn't have any ReturnResource attributes. But we have some some generic handling there and we can return more than one HttpError there and without that change it just throws an error that ReturnResource is missing

I added logic to check for both HttpError and IEnumerable and also added unit test to cover that scenario.

Thanks