https://serverless-stack.com/ logo
#help
Title
# help
d

Dan Van Brunt

05/06/2022, 5:43 PM
Is there a way to do Request Validation with httpApi? If not the way that RestApi does it, is there a better way to handle validation with httpApi?
a

Adam Fanello

05/06/2022, 5:45 PM
I think the answer is no. Request validation within API Gateway is one of the things that the higher price and latency of REST API buys you. Even before HTTP APIs though, I preferred to do validation within my Lambda (assuming that's your API target). It's just simpler.
s

Seth Geoghegan

05/06/2022, 5:48 PM
request validation within Lambda does seem to be the preferred pattern (and probably required if you're using HTTP APIs that currently lacks this feature). I could imagine API GWs native request validation is more useful when you're not integrating with Lambda directly (e.g. going straight to DynamoDB, SQS, etc)
d

Dan Van Brunt

05/06/2022, 6:23 PM
Anyone know of a good go-to JS field validation lib?
m

Matt Morgan

05/06/2022, 6:42 PM
I do request validation in RestAPI and I think it’s a great feature. I can’t use HttpAPI anyway because it lacks xray and waf support.
a

Adam Fanello

05/06/2022, 6:47 PM
REST API has some great features, for sure. Just don't use (use HTTP APIs) it if you aren't taking advantage of those features.
l

Lukasz K

05/06/2022, 6:53 PM
@Dan Van Brunt I use
ow
for specific fields in the request but have seen a sst example for using whole schema validation with
Middy
[Edit] Here's the link: https://serverless-stack.com/examples/how-to-use-middy-to-validate-your-serverless-api-requests.html
5 Views