我正在测试我的备份过程的API,在我的API Gateway
中。API网关未导入导出的定义
因此,我从我的AWS账户中的API Console
导出我的API,然后我进入API Gateway
并创建一个新的API - “从swagger导入”。
我粘贴导出的定义并创建,这会引发大量错误。
从我的阅读 - 这似乎是一个已知的问题/痛苦。
我怀疑错误的原因是因为我使用了自定义授权人;
"security" : [ {
"TestAuthorizer" : [ ]
}, {
"api_key" : [ ]
} ]
我在每种方法上都使用这个,因此我得到了很多错误。
奇怪的是我可以很好地克隆这个API,因此,我认为我可以采用导出的定义并重新导入而不会出现问题。
关于如何纠正这些错误的任何想法(最好在我的API网关中,以便我可以无任何问题导出/导入)。
使用这个授权我的GET方法中的一个例子是:提前
"/api/example" : {
"get" : {
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "Authorization",
"in" : "header",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "200 response",
"schema" : {
"$ref" : "#/definitions/exampleModel"
},
"headers" : {
"Access-Control-Allow-Origin" : {
"type" : "string"
}
}
}
},
"security" : [ {
"TestAuthorizer" : [ ]
}, {
"api_key" : [ ]
} ]
}
感谢
UPDATE
错误(S)导入定义时,我得到的我刚刚输出的是: Your API was not imported due to errors in the Swagger file. Unable to put method 'GET' on resource at path '/api/v1/MethodName': Invalid authorizer ID specified. Setting the authorization type to CUSTOM or COGNITO_USER_POOLS requires a valid authorizer.
我得到消息f或者我的API中的每个方法 - 所以有很多。
额外性,就在邮件的末尾,我得到这个: Additionally, these warnings were found: Unable to create authorizer from security definition: 'TestAuthorizer'. Extension x-amazon-apigateway-authorizer is required. Any methods with security: 'TestAuthorizer' will not be created. If this security definition is not a configured authorizer, remove the x-amazon-apigateway-authtype extension and it will be ignored.
我已经与忽略的错误,同样的结果尝试。
您好,我有我自己的API,有一个自定义的授权测试,它导出/导入成功,所以我认为这可能是别的。你能发布你在导入时看到的确切的错误信息吗?另外,你有没有尝试禁用导入时的“失败警告”选项? –
@LorenzodeLara感谢您的反馈,我已更新我的原始问题与所需的信息,让我知道如果你需要别的东西。 – Hexie