Closed oktay89 closed 4 years ago
Thank for the feedback!
Seems like this is an expected behavior for the current implementation because the return types are automatically serialized to JSON string for sanity check.
I have added a fix for this and should be available in the next release.
For the time being, you can use the ApiResponse
object as the return type to return the actual type:
[HttpGet("loadInt")]
public ApiResponse LoadInt(int i)
{
return new ApiResponse(13);
}
Will this bugfix fix also the double "double quotation marks" on a string function?
For Example:
[HttpGet("testString")] public string TestString() { return "test"; }
Returns:
{"Message":"Request successful.","hasError":false,"Data":"\"test\""}
In 3.0.0 I fix this issue by adding:
[Produces("text/plain")]
@oktay89 regular strings should work not unless if you manually serialize it to JSON
or set the output format to application/json
. For example:
[HttpGet("testString")]
public string TestString() { return JsonConvert.SerializeObject ("test"); }
Check your project/controller configuration and verify if you have this format specifier:
[Produces("application/json")]
I will include a fix for this as well so that the body will be validated to avoid re enconding the JSON value.
Just released a new version that comes with a fix for this issue. You can find it here: AutoWrapper Now Supports Problem Details For Your ASP.NET Core APIs
Thank you so much for all your suggestions on improving this middleware! :)
I am using AutoWrapper 3.0. This is the Api Function i call:
This is the configuration I made:
This is my custom response class:
I expect the Data attribute to be int, but it is string.