Guys, do we have a "request body" validation avail...
# help
m
Guys, do we have a "request body" validation available in
sst.Api
? I am trying to find
apigateway.Model
and
apigateway.RequestValidator
, for my POST-APIs.
d
iirc, that stuff is only available for API Gateway's REST api, not their newer HTTP api https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html
stupid naming convention but essentially "REST Api" is v1, and "HTTP Api" is v2
m
Thanks, @Dennis Dang, Is there a way I can add a body validation to my rest APIs created with sst.Api. (like extending functionality through CDK constructs?)
f
Just to clarify, you’d need to use
sst.Api
creates HTTP APIs. You can use
sst.ApiGatewayV1Api
to create a REST API and configure request validation.
m
Thanks, @Frank. switching to
ApiGatewayV1Api
local testing and everything that SST offers still hold good right?
f
Yup! Are you sure u want to switch over to using REST APIs? lol
I might be biased, but I find HTTP Apis are much easier to work with.
m
🙄, I wanted to have validations checked before reaching lambda code. (I overheard someone saying "why should we pay (execution time) if user's make an invalid request?"), 😂 Going to go through that difference again.
f
That’s true. But note that HTTP API is cheaper, and has better performance.
And yeah,
sst start
works for both constructs.
m
Yep, agreed. I guess I will use HTTP and check out middy.