Add AlwaysShowIsError option
khoren-mansuryan opened this issue · 8 comments
when response is ruccess isError property is always hiding by attribute [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
Please make an opportunity to change it by options
Hi @khoren-mansuryan ,
Thank you for the suggestion. It was my intent to hide the IsError
property on successful requests because it gives no value. Would you be able to give a scenario of why do you think it's usesful to have this property?
Hi @proudmonkey
Thank you for reply. If we dont send isError : true to front-end then we have to firstly chek does response have isError key and then chek if isError true or false. This feature can reduce this check
Instead of isError
attribute, you can use the HTTP StatusCode
to validate if the request is successful. For example StatusCode 200.
for some applications Status Code different than 200 can be ok but need to check isError
I will add on option to enable that. I still don't understand the reason for it's usage when you can just check against the 200 StatusCode to indicate a successful request. The 200 status code is pretty much standard.
I completely agree with you but there are cases where it is needed, although not many
P.S i have created PR for this
I haven't noticed your PR. But I already integrated this option. Just download the newest version 4.3.1
Usage:
app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions
{
ShowIsErrorFlagForSuccessfulResponse = true
});
Let me know your findings. Thanks for your feedback! :)
@proudmonkey
I did it almost same way :)
Thank you !