我有一个API网关端点(/ item / {itemId}),其中包含路径参数“ itemId”。这是我用来在API网关中创建终结点的草率定义。
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "sample-postman-import"
},
"host": "example.com",
"basePath": "/api",
"schemes": ["https"],
"paths": {
"/item/{itemId}": {
"get": {
"produces": [
"application/json"
],
"parameters": [
{
"name": "itemId",
"in": "path",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
部署API后,当我将其导出为swagger定义时,导出的定义缺少'parameters'对象,从而使其成为不完整的swagger文件。当我
时,我也遇到过同样的问题这是导出的样子:
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "sample-postman-import_old"
},
"host": "example.com",
"basePath": "/api",
"schemes": ["https"],
"paths": {
"/item/{itemId}": {
"get": {
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 response"
}
}
}
}
}
}
答案 0 :(得分:0)
使用Terraform创建API网关时,我遇到了同样的问题。在AWS UI上显示了参数,但是当我使用aws apigateway get-method
命令通过AWS CLI请求方法信息时,未提供参数。因此,请确保已根据需要设置了“ requestParameters”,否则请通过CLI或Terraform进行设置。