swagger.yamlが標準でインポートできる
こちらの記事にもありますが、今(2016/08/08)ではaws-apigateway-importerを使わずにAWSCLIまたはAWSConsoleだけでAPIGatewayにswagger.yaml定義をインポートすることが出来ます。
AWSCLIの場合
cliの場合
$ aws apigateway import-rest-api --body file://swagger.yaml
Consoleの場合
「Invalid Swagger 2.0 input.」 の冷たい一言
しかし、たまにこの一言に悩まされるのです。
CLIの場合
An error occurred (BadRequestException) when calling the ImportRestApi operation: Invalid Swagger 2.0 input.
Consoleの場合
原因1 レスポンスを$ref
する
swagger.yaml
paths:
/hoge/fuga:
get:
responses:
200:
description: "fugaを取得できた場合"
schema:
$ref: "#/definitions/Fuga"
404:
$ref: "#/responses/NotFound"
responsesObjectの定義的には,
Type |
---|
Response Object or Reference Object |
となっているのですが、
swagger.yaml
404:
$ref: "#/responses/NotFound"
この記述があるとエラーとなりました。