Today, Microsoft has announced the release of .NET Core 3.0. As promised in my previous post, I will roll-out a new version of AutoWrapper.Core after .NET Core 3.x is out.
Today, AutoWrapper version 1.0.0
is now officially released with some added option configurations to it. You can see the repo here: https://github.com/proudmonkey/AutoWrapper
In previous versions, a few folks find a couple of properties from the response redundant. With this release, I have decided to exclude the API Version
and StatusCode
from the response. This means that the response is now going to look like this:
Success
{
"message": "Request successful.",
"isError": false,
"result": [
{
"date": "2019-09-16T23:37:51.5544349-05:00",
"temperatureC": 21,
"temperatureF": 69,
"summary": "Mild"
},
{
"date": "2019-09-17T23:37:51.554466-05:00",
"temperatureC": 28,
"temperatureF": 82,
"summary": "Cool"
},
{
"date": "2019-09-18T23:37:51.554467-05:00",
"temperatureC": 21,
"temperatureF": 69,
"summary": "Sweltering"
},
{
"date": "2019-09-19T23:37:51.5544676-05:00",
"temperatureC": 53,
"temperatureF": 127,
"summary": "Chilly"
},
{
"date": "2019-09-20T23:37:51.5544681-05:00",
"temperatureC": 22,
"temperatureF": 71,
"summary": "Bracing"
}
]
}
Error
{
"isError": true,
"responseException": {
"exceptionMessage": "Unhandled Exception occured. Unable to process the request.",
"details": null,
"referenceErrorCode": null,
"referenceDocumentLink": null,
"validationErrors": null
}
}
Options
The following properties are the options
that you can set:
ApiVersion
ShowApiVersion
ShowStatusCode
IsDebug
ShowApiVersion
if you want to show the API
version in the response, then you can do:
app.UseApiResponseAndExceptionWrapper(
new AutoWrapperOptions
{
ShowApiVersion = true
});
The default API
version format is set to "1.0.0.0
"
ApiVersion
If you wish to specify a different version format, then you can do:
app.UseApiResponseAndExceptionWrapper(
new AutoWrapperOptions
{
ShowApiVersion = true,
ApiVersion = "2.0"
});
ShowStatusCode
if you want to show the StatusCode
in the response, then you can do:
app.UseApiResponseAndExceptionWrapper(
new AutoWrapperOptions
{
ShowStatusCode = true
});
IsDebug
By default, AutoWrapper
suppresses stack trace information. If you want to see the actual details of the error from the response during the development stage, then simply set the AutoWrapperOptions
IsDebug
to true
:
app.UseApiResponseAndExceptionWrapper(
new AutoWrapperOptions
{ IsDebug = true
});
That's it! Try it yourself and let me know what you think.
Big thanks to those folks who gave their honest feedback and comments ( You know who you are ;) ). I truly appreciate it.