You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to request a small feature that would allow Mule APIs to return more verbose and helpful responses to API consumers.
I would like to request that APIKit exceptions would contain metadata about why validation failed. Currently, there is a simple error message, which works fine as an API response, however that's about as far as developers can take it. To give you an example, here's the exception message thrown by APIKit when query parameter validation fails:
org.mule.module.apikit.api.exception.InvalidQueryParameterException: Invalid value '2020-08-011' for query parameter flightDate. [2020-08-011] is not a valid date. Expected [yyyy-MM-dd]
As a result, we can wrap this message in a nice JSON response coupled with an HTTP 400 response code:
{
"message": "Invalid value '2020-08-011' for query parameter flightDate. [2020-08-011] is not a valid date. Expected [yyyy-MM-dd]"
}
My request here is to expand this to something like this:
{
"message": "Invalid value '2020-08-011' for query parameter flightDate. [2020-08-011] is not a valid date. Expected [yyyy-MM-dd]",
"field": "flightDate",
"errorValue": "2020-08-011"
}
I guess this can be achieved by passing in the erroneous parameters and metadata when constructing the InvalidQueryParameterException (or any other APIKit validation exceptions).
A workaround to this would be to define regular expressions around APIKit error messages but that's an extremely brittle solution since error messages might change (as they did in APIKit 3.8 --> APIKit 3.9)
Thanks,
Justin
The text was updated successfully, but these errors were encountered:
justinsaliba
changed the title
More description exception responses
Exception Metadata
Jul 10, 2020
Hi,
I'd like to request a small feature that would allow Mule APIs to return more verbose and helpful responses to API consumers.
I would like to request that APIKit exceptions would contain metadata about why validation failed. Currently, there is a simple error message, which works fine as an API response, however that's about as far as developers can take it. To give you an example, here's the exception message thrown by APIKit when query parameter validation fails:
As a result, we can wrap this message in a nice JSON response coupled with an HTTP 400 response code:
My request here is to expand this to something like this:
I guess this can be achieved by passing in the erroneous parameters and metadata when constructing the
InvalidQueryParameterException
(or any other APIKit validation exceptions).A workaround to this would be to define regular expressions around APIKit error messages but that's an extremely brittle solution since error messages might change (as they did in APIKit 3.8 --> APIKit 3.9)
Thanks,
Justin
The text was updated successfully, but these errors were encountered: