amazon-web-services - API Gateway 是否会自动验证输入模型?

标签 amazon-web-services aws-api-gateway

我使用以下端点在 AWS API 网关中创建了简单的 API:

POST /v1/users

在方法执行/方法请求中,我添加了请求模型:

enter image description here

此模型架构如下所示:

enter image description here

但是,当我使用 json body { "foo": "bar" } 向该端点发出请求时它没有拒绝它并且我的 lambda 函数被执行......

那么,如果不用于验证请求,为什么还有定义 JSON 模式的选项?

最佳答案

只是想自己解决这个问题,我看到你几个小时前才问过这个问题!

到目前为止,我找到的唯一引用资料在这里:

http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings.html

For non-GET method types, expand Request Models, and for Content Type and Model name, type the content type and choose the name of a model that will transform caller-supplied data into the expected format.



所以看起来它更像是转换而不是验证 - 但它实际上是如何工作的并不是特别清楚。

更新

我刚刚注意到这个 HackerNews 主题:

https://news.ycombinator.com/item?id=9880683

一位 AWS 工程师在那里做出了回应,并说:

Models are not required for validation. They are simply used to generate the objects in the client SDKs.

关于amazon-web-services - API Gateway 是否会自动验证输入模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32270382/

相关文章:

amazon-web-services - 适用于iOS的Amazon Web Services移动中心SNS推送

amazon-web-services - 使用 SSL 在 AWS 上托管多个应用程序的最佳方法

python - 图片上传: iPhone Client - Django - S3

python - 如何让客户端上传直接到S3而不是通过Django代理

amazon-web-services - AWS API Gateway MTLS 客户端身份验证

amazon-web-services - 如何配置 AWS 网络负载均衡器以使用 Terraform 路由 HTTPS 流量?

amazon-web-services - 找出谁调用了 AWS lambda 函数

python - 如何在AWS API网关中返回非默认回复而不引发异常?

amazon-web-services - 使用 AmazonLambdaClient 时,Localstack 无法在 us-east-1 以外的任何区域内找到 lambda 函数

amazon-web-services - API 网关自定义授权方 - 获取源 IP 地址