I am thrilled to announce that AutoWrapper crossed the 100,000 downloads mark on NuGet today with 344 stars on Github! Woot! 🎉
This is a huge milestone for the project and I'm still trying to digest the fact that it made this far. Big thank you to everyone who used the package and to everyone who has contributed to the project.
What AutoWrapper Is?
If AutoWrapper isn't familiar to you, here's a quick overview about the project.
AutoWrapper is a simple, yet customizable global HTTP exception handler and response wrapper for ASP.NET Core APIs. It uses a middleware to intercept incoming HTTP requests and automatically wraps the responses for you by providing a consistent format for both successful and error responses. The goal is to let you focus on your business code specific requirements and let AutoWrapper automatically handle the HTTP responses. This can save you some time when building RESTful APIs while enforcing standard formats for your HTTP responses.
How To Use It?
- Download and install the latest AutoWrapper.Core from NuGet or via CLI:
PM> Install-Package AutoWrapper.Core -Version 4.3.0
2. Declare the following namespace within Startup.cs
3. Register the middleware below within the
Configure() method of
Startup.cs "before" the
Simple as that!
The following are the key features for version 4.x as of this time of writing:
- ModelState validation error handling (support both Data Annotation and FluentValidation).
- A configurable API exception.
- A consistent response format for Result and Errors.
- A detailed
- A detailed
- A configurable HTTP
- Add support for
- Add Logging support for Request, Response and Exceptions.
- A configurable middleware options to configure the wrapper. See Options section from the documentation.
- Enable property name mappings for the default
- Add support for implementing your own user-defined
Errorschema / object.
- Add support for
- Add support for ignoring action methods that don't need to be wrapped using
V3.xenable backwards compatibility support for
netcoreapp2.2.NET Core frameworks.
For more information, visit the official repository at Github here.
The most recent version of AutoWrapper is
4.4.0 and currently it supports both
I'm currently on the process of migrating the project to .NET 5. This means that the next version will traget the
.net5.0 framework. Hopefully, I can get the RC version out before end of February so you can test it before rolling out an official release.
The goals are:
- Remove Json.NET depedency (
Newtonsoft.json) and leverage
System.Text.Json. Doing this transition may affect some of the existing features such as
Null Reference Loophandling and property mappings.
- Refactor/revamp code implementation. This is to simplify the code and validation handling.
ApiProblemDetailsExceptionas the default exception format.
- Change the usage to use
ApiErrormodels shape and probably the naming as well. This means that removing unused properties and replacing them with useful metadata such as
- Make the
ApiResponsemodel extensible so you can easily extend and add custom properties if needed.
- Address current issues and feature suggestions. Please keep your feedback coming! 😃
- Provide more test cases in the test project.
- Provide separate documentation with details on how to use each options.
That's just some of them. For sure there will be more. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star or be my sponsor to show your support on this project! 😃
P.S: I enabled the subscription form on this blog. Feel free to subscribe and get my latest article posts delivered right to your inbox! Thank you!