【以下的问题经过翻译处理】 当在要导入的Swagger文件中包含basePath属性时,似乎在使用AWS CLI导入时该属性会被忽略,即使添加了参数来添加它。
根据CLI帮助手册,应该是可能的:
'''
--parameters (map)
A key-value map of context-specific query string parameters specifying
the behavior of different API importing operations. The following shows
operation-specific parameters and their supported values.
To handle imported basePath, set parameters as basePath=ignore,
basePath=prepend or basePath=split.
'''
要处理导入的basePath,请将参数设置为basePath=ignore、basePath=prepend或basePath=split。”
以下是我的CLI输出:
'''
$ aws --version
aws-cli/1.16.85 Python/2.7.15rc1 Linux/4.15.0-43-generic botocore/1.12.75
$ aws apigateway import-rest-api --parameters basePath=prepend --body 'file:///tmp/swagger.yaml'
{
"apiKeySource": "HEADER",
"version": "2",
"name": "PetStore",
"createdDate": 1547020100,
"endpointConfiguration": {
"types": [
"EDGE"
]
},
"id": "yy3s9trtfa"
}
'''
这是Swagger输入:
'''
swagger: "2.0"
info:
version: "2"
title: PetStore
schemes:
- https
basePath: /api
paths:
/:
get:
consumes:
- application/json
produces:
- text/html
responses:
'200':
headers:
Content-Type:
type: string
x-amazon-apigateway-integration:
responses:
default:
statusCode: '200'
responseParameters:
method.response.header.Content-Type: '''text/html'''
responseTemplates:
text/html: <html><body>Welcome to your Pet Store API</body></html>
passthroughBehavior: when_no_match
requestTemplates:
application/json: '{"statusCode": 200}'
type: mock
'''