I am thrilled to announce that AutoWrapper crossed the 100,000 downloads mark on NuGet today with 344 stars on Github! Woot! 🎉

Download Stats

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?

  1. 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

using AutoWrapper;

3. Register the middleware below within the Configure() method of Startup.cs "before" the UseRouting() middleware:


Simple as that!

Main Features

The following are the key features for version 4.x as of this time of writing:
Exception handling.

  • ModelState validation error handling (support both Data Annotation and FluentValidation).
  • A configurable API exception.
  • A consistent response format for Result and Errors.
  • A detailed Result response.
  • A detailed Error response.
  • A configurable HTTP StatusCodes and messages.
  • Add support for Swagger.
  • 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 ApiResponse properties.
  • Add support for implementing your own user-defined Response and Error schema / object.
  • Add support for ProblemDetails exception format.
  • Add support for ignoring action methods that don't need to be wrapped using [AutoWrapIgnore] filter attribute.
  • V3.x enable backwards compatibility support for netcoreapp2.1 and netcoreapp2.2 .NET Core frameworks.

For more information, visit the official repository at Github here.

Road Map

The most recent version of AutoWrapper is 4.4.0 and currently it supports  both netcoreapp3.0 and netcoreapp3.1 frameworks.

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 Loop handling and property mappings.
  • Refactor/revamp code implementation. This is to simplify the code and validation handling.
  • Set ApiProblemDetailsException as the default exception format.
  • Change the usage to use app.UseAutoWrapper() vs app.UseApiResponseAndExceptionWrapper();
  • Refator ApiResponse and ApiError models shape and probably the naming as well. This means that removing unused properties and replacing them with useful metadata such as RequesId.
  • Make the ApiResponse model 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!