Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use detailed error message when enable API GW request body validation #1207

Open
honglu opened this issue Oct 16, 2019 · 3 comments
Open

Use detailed error message when enable API GW request body validation #1207

honglu opened this issue Oct 16, 2019 · 3 comments

Comments

@honglu
Copy link
Contributor

honglu commented Oct 16, 2019

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.

@praneetap
Copy link
Contributor

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

@alext234
Copy link

+1 for this feature

@karthikvadla
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants