aws / aws/serverless-application-model
Use detailed error message when enable API GW request body validation
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Description
**Description:**
When using API GW's request validation [feature](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html) 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.
Contributor guide
Assessment
This issue has not been assessed yet.