我目前正在使用 Swagger 来定义具有许多端点的 API,并且这些端点中的每一个都对“x-amazon-apigateway-integration”键具有相同的定义。我想在文档的某处定义它,并在整个过程中重复使用该定义。
要么我不明白应该如何定义定义,我没有将它放在正确的位置或两者的混合。我尝试在“定义”中定义这个定义,并作为它自己的密钥下的一些别名。定义(删除了关键信息)是:
x-amazon-apigateway-integration:
responses:
default:
statusCode: '200'
passthroughBehavior: when_no_match
httpMethod: POST
uri: >-
arn:aws:apigateway:<region>:lambda:path/2015-03-31/functions/<lambda arn>/invocations
credentials: '<role arn>'
type: aws
requestTemplates: "application/json": "<object definition>"
Run Code Online (Sandbox Code Playgroud)
我尝试将其定义为它自己的密钥下的别名(不是定义,而是相同的基本范围):
amazon:
Amazon: &Amazon
- responses:
default:
statusCode: '200'
- passthroughBehavior: when_no_match
- httpMethod: POST
- uri: >-
arn:aws:apigateway:<region>:lambda:path/2015-03-31/functions/<lambda arn>/invocations
- credentials: '<role arn>'
- type: aws
- requestTemplates:
"application/json": "<object definition>"
Run Code Online (Sandbox Code Playgroud)
要使用,我有以下内容:
x-amazon-apigateway-integration:
*Amazon
Run Code Online (Sandbox Code Playgroud)
API Gateway 导入时收到的错误是“无法解析 API 定义,因为路径 / 中的集成格式错误”
我还尝试在“定义”下定义它,并使用“参考”来访问它:
definitions:
Amazon:
type: object
x-amazon-apigateway-integration:
responses:
default:
statusCode: '200'
passthroughBehavior: …Run Code Online (Sandbox Code Playgroud)