【发布时间】:2019-04-15 03:01:53
【问题描述】:
我正在尝试使用这样的 Cloudformation 模板创建 API 网关:
Resources:
InvoiceApi:
Type: AWS::ApiGateway::RestApi
Properties:
Description: an Api for our Invoicegen App
Name: !Ref ApiName
ApiKeySourceType: !Ref ApiKeySourceType
BinaryMediaTypes:
- !Ref binaryMediaType1
- !Ref binaryMediaType2
BodyS3Location:
Bucket:
Fn::ImportValue: !Sub ${EnvironmentName}-SwaggerApiBucket-Name
Key: swaggertest.yaml
ETag: !Ref ETag
EndpointConfiguration:
Types:
- REGIONAL
FailOnWarnings: true
MinimumCompressionSize: !Ref minimumCompressionSize
S3 Bucket 上的 Swagger-yaml 文件如下所示:
swagger: '2.0'
info:
version: '2016-08-17T18:08:34Z'
title: InvoicegenAPI
basePath: "/LATEST"
schemes:
- https
paths:
/greeting:
get:
summary: Get Greeting
parameters:
- name: name
in: query
required: false
type: string
produces:
- application/json
responses:
'200':
description: 200 response
x-amazon-apigateway-integration:
requestTemplates:
application/json: '{"name": "$input.params(''name'')"}'
uri:
Fn::Join:
- ''
- - 'arn:aws:apigateway:'
- Ref: AWS::Region
- ":lambda:path/2015-03-31/functions/"
- Fn::GetAtt:
- InvoiceLambda
- Arn
- "/invocations"
responses:
default:
statusCode: '200'
httpMethod: POST
type: aws
不幸的是,它会抛出这样的错误:
Unable to parse API definition because of a malformed integration at path /greeting. (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 2cf08a97-e66f-11e8-afee-fb6b03568b64)
我仔细检查了 Swagger 文件,所有缩进看起来都很好。我错过了什么?
已经有一个线程在处理这个问题,但还没有产生任何解决方案。
Passing ARN reference from CloudFormation to Swagger
提前谢谢
一个
【问题讨论】:
-
summary、parameters、Fn::Join和type: aws的缩进关闭。将您的 YAML 粘贴到 editor.swagger.io 以查看错误。 -
不,这不是问题,它与 AWS 集成有关。
标签: swagger amazon-cloudformation