examples icon indicating copy to clipboard operation
examples copied to clipboard

Request Parameters aren't checked by API Gateway

Open patrickwerz opened this issue 4 years ago • 2 comments

Hi guys,

I tried to use the following syntax to enforce parameter check by the api gateway to not check it in the code:

https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#request-schema-validators

image

Api gateway doesn't return a 400 if the path parameter isn't provided.

When I manually adjust the request validator like in the screenshot it works.

image

Is there any way to set the feature with sls or cf? The manually process is not production ready for me. Thanks in advance, Patrick

patrickwerz avatar Jun 11 '20 17:06 patrickwerz

I am facing the exact same problem.

ericxinzhang avatar Sep 04 '20 08:09 ericxinzhang

You can use this CF ressource as a workaround: RequestValidator: Type: AWS::ApiGateway::RequestValidator Properties: Name: 'custom-req-param-validator' RestApiId: !Ref ApiGatewayRestApi ValidateRequestParameters: true ValidateRequestBody: true

And then reference it in you function event: ..... events: - http: path: v1/foo method: get private: true reqValidatorName: 'RequestValidator'

patrickwerz avatar Sep 04 '20 11:09 patrickwerz