Use detailed error message when enable API GW request body validation
Description:
When using API GW's request validation feature to validate request body, by default the error message is Invalid request body without any details on where it is invalid in request body. To get detailed error message, customers have to set the following in their swagger:
x-amazon-apigateway-gateway-responses:
# Provide more detailed error message for bad request body errors. See doc: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-gateway-responses.html
BAD_REQUEST_BODY:
responseTemplates:
application/json: '{"message": "$context.error.validationErrorString"}'
It would be nice if SAM can add this to swagger automatically if request body validation is enabled.
Thanks for creating the issue, Lu! We don't support adding request-validators in SAM today, but this is on our roadmap. Once that support is added it totally makes sense to add gateway responses for BAD_REQUEST_BODY. It's being tracked in #931
+1 for this feature
+1