aws / aws/serverless-application-model

Use detailed error message when enable API GW request body validation

Open
#1,207 3 comments 1 reaction 0 assignees View on GitHub
maintainer/need-followup type/feature
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.