C
C#6mo ago
Anton

ASP.NET Core same structure for all responses

I need a package that could wrap any response I return from the controller into a standard structure. Kind of like this project https://github.com/proudmonkey/AutoWrapper The problem with that project is that it doesn't modify the responses that Swagger sees. I know I can take a shortcut by just returning the wrapped type from all endpoints, but that's just not plausible. I want it to work by default for everything. So things I need in particular: - Exception middleware that responds in json, with the same settings as configured for the response formatter. I don't really care about non-json, but ideally that should work too. - Handle model binding errors, responding in the same standard format. - The ability to handle custom exceptions, the ability for them to map to the model serialized. - I want it to distinguish 400 from 500 automatically. - The most important thing, I need it to affect swagger. The client should get the wrapped responses in swagger. If possible, the errors should be listed too. - Has to be non-invasive, in the sense that it has to be handled at a central place, rather than duplicated for each handler. I've tried doing some of this manually, but it's way more work than I anticipated.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server