我正在測試我的備份過程的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