当我为 iOS 导出 API 时,如何为 POST 端点添加请求模型,以便它出现在 API 网关中?我可以在 AWS 中手动添加请求模型,但由于这是通过服务器部署的,所以我不需要它。我看到有一个 responseModels 用于定义端点,但我看不到 requestModels?
我的 s-functions.json 有这个
"endpoints": [
{
"path": "blog/graphql",
"method": "POST",
"type": "AWS",
"authorizationType": "AWS_IAM",
"authorizerFunction": false,
"apiKeyRequired": false,
"requestParameters": {},
"requestTemplates": {
"application/json": "{\"query\" : $input.json(\"$\")}"
},
"responses": {
"400": {
"statusCode": "400"
},
"default": {
"statusCode": "200",
"responseParameters": {},
"responseModels": {},
"responseTemplates": {},
"application/json": ""
}
}
}
]
然后,在 AWS APIGateway 中,我需要手动将请求模型添加为
{
"title": "Example Schema",
"type": "object",
"properties": {
"query": {
"type": "string"
}
},
"required": ["query"]
}
然后,当我为 iOS 导出 API 时,我确实获得了正确的方法来发送 graphQL 查询并且它可以工作。
但是,由于我想使用无服务器部署来部署它,我不能继续手动添加它。
而且我需要 API 端点调用通过 iOS 的 APIGateway SDK 才能使用 cognito 凭据,而不是手动执行 https。