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
Query string does not honor required/not required #5034
Comments
I think this is related to the fact that there's no way right now to enable the request validator for body/query params right? |
Also seeing this behaviour
|
If you set params as required via serverless syntax you then can just also activate the validator for parameters like so
|
@akleiber thank you 🙏 |
I'm struggling with this too. What's "ApiGatewayMethodNameOfYourApiLookItUpInYourTemplate" you're referring to, @akleiber? cc @Rigellute maybe you can answer too |
Oookay I got it! |
Here is the working template: In serverless.yml add this
|
Don't suppose you could be a bit more specific for people like me please. This is what I got from your description:
|
@shadowdogg iirc you just need to add this at the bottom of your
(note how I used ApiGatewayMethodListGet since your handlest it's called |
@Pitasi Yeah, still doesn't work for me The CloudFormation template is invalid: Template format error: [/Resources/ApiGatewayMethodListGet] Every Resources object must contain a Type member. |
For those of you failing to see this, like I also did. This is what you need to do in plain english. Turn ApiGatewayMethodNameOfYourApiLookItUpInYourTemplate to APIGatewayMethod<1><2> In my case, it was APIGatewayDealsGet The thing I was looking at was my handler name in serverless
Alternatively, if this does not work, check the s3 bucket, mine was called xxxxxxx-ap-serverlessdeploymentbuck-1epdp60eqveqr and go to serverless > yyyyyyyyyyy > aaaa > And look for the name of your method in there, example mine was:
|
Is there any update on this? I am facing the same issue. |
I literally gave a full explaination right above your comment |
@akleiber what type should be used for that resource? I'm reffering to
|
This did not solve my issue unfortunately :( I've deployed this successfully and referenced the ApiGatewayMethod..., but my lambda is still being hit even if a required query string parameter is being omitted. |
Thanks this worked. Quick question though, does this method work for path parameters? Also, if I have a nested route, how would that work? So if my route is admin/someRoute, what would the ApiGatewayMethod look like? I tried ApiGatewayMethodAdminSomerouteGet and it didn't work? |
This doesn't work for path parameters. To get the APIGatewayMethod name for your nested route, you can look in the |
This is a Bug Report
Description
I created a query string parameter set to
true
, which marks it as required. However, nothing happens when it's not passed.I expect to see an error when the parameter is missing.
See below for
serverless.yml
.None. Expected to see an error when query string parameter is missing.
I want my request to have a certain query string parameter. I saw the following here:
However, when marking a query string as
true
does not seem to make it required. When using the following code (clean start fromserverless create --template aws-nodejs-typescript
), all requests pass to thehello
path, even if the query string is not set.serverless.yml
:Similar or dependent issues:
Additional Data
The text was updated successfully, but these errors were encountered: