gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 11:40:55 26 4
gpt4 key购买 nike

我使用以下端点在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com