【发布时间】:2019-01-16 05:38:16
【问题描述】:
我有一个 API 网关端点 (/item/{itemId}),其中包含路径参数“itemId”。这是我用来在 API 网关中创建端点的 swagger 定义。
{
"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 定义时,导出的定义缺少“参数”对象,使其成为不完整的 swagger 文件。当我遇到同样的问题时
- 尝试从 UI 导出,如https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html 所示
- 使用了来自 javascript aws-sdk https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#getExport-property 的 getExport API 调用
这是导出的样子:
{
"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"
}
}
}
}
}
}
【问题讨论】:
标签: amazon-web-services export postman aws-api-gateway swagger-2.0