LoginSignup
1
2

More than 5 years have passed since last update.

APIGateway swagger.yamlをインポートすると「Invalid Swagger 2.0 input.」

Posted at

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の場合

スクリーンショット 2016-08-08 15.49.45.png

「Invalid Swagger 2.0 input.」 の冷たい一言

しかし、たまにこの一言に悩まされるのです。

CLIの場合

An error occurred (BadRequestException) when calling the ImportRestApi operation: Invalid Swagger 2.0 input.

Consoleの場合

スクリーンショット 2016-08-08 15.36.20.png

原因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"

この記述があるとエラーとなりました。

原因2 ... 何かあった気がするのですが忘れてしまったので後日書きます

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2