繁体   English   中英

AWS Mysfits - 无效的 HTTP 端点 API 网关推送

[英]AWS Mysfits - Invalid HTTP Endpoint API Gateway Push

在 AWS Mythical Mysfits 教程的模块 4 中,在使用所有替换内容更新 swagger 文档后,我无法推送 API 更改。 我已经按照本节的说明进行了三遍。

参考: https : //aws.amazon.com/getting-started/projects/build-modern-app-fargate-lambda-dynamodb-python/module-four/

我正在通过 Cloud9 运行以下命令:

aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body file://~/environment/aws-modern-application-workshop/module-4/aws-cli/api-swagger.json --fail-on-warnings

使用 api-swagger-json:

{
    "swagger": 2.0,
    "info": {
        "title": "MysfitsApi"
    },
    "securityDefinitions": {
        "MysfitsUserPoolAuthorizer": {
            "type": "apiKey",
            "name": "Authorization",
            "in": "header",
            "x-amazon-apigateway-authtype": "cognito_user_pools",
            "x-amazon-apigateway-authorizer": {
                "type": "COGNITO_USER_POOLS",
                "providerARNs": [
                    "arn:aws:cognito-idp:us-east-2:730082756200:userpool/us-east-2_jFYjOTZRU"
                ]
            }
        }
    },
    "paths": {
        "/": {
            "get": {
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "connectionType": "VPC_LINK",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    },
                    "connectionId": "wg0305",
                    "httpMethod": "GET",
                    "type": "HTTP_PROXY",
                    "uri": "mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com"
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits": {
            "get": {
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "GET",
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits/{mysfitId}": {
            "get": {
                "parameters": [{
                    "name": "mysfitId",
                    "in": "path",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "x-amazon-apigateway-integration": {
                    "requestParameters": {
                        "integration.request.path.mysfitId": "method.request.path.mysfitId"
                    },
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "GET",
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits/{mysfitId}",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits/{mysfitId}/adopt": {
            "post": {
                "parameters": [{
                    "name": "mysfitId",
                    "in": "path",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "security": [{
                    "MysfitsUserPoolAuthorizer": [

                    ]
                }],
                "x-amazon-apigateway-integration": {
                    "requestParameters": {
                        "integration.request.path.mysfitId": "method.request.path.mysfitId"
                    },
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "POST",
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits/{mysfitId}/adopt",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "/mysfits/{mysfitId}/like": {
            "post": {
                "parameters": [{
                    "name": "mysfitId",
                    "in": "path",
                    "required": true,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                },
                "security": [{
                    "MysfitsUserPoolAuthorizer": [

                    ]
                }],
                "x-amazon-apigateway-integration": {
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    },
                    "requestParameters": {
                        "integration.request.path.mysfitId": "method.request.path.mysfitId"
                    },
                    "connectionType": "VPC_LINK",
                    "connectionId": "wg0305",
                    "httpMethod": "POST",
                    "security": [{
                        "MysfitsUserPoolAuthorizer": [

                        ]
                    }],
                    "type": "HTTP_PROXY",
                    "uri": "http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com/mysfits/{mysfitId}/like",
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            }
                        }
                    }
                }
            },
            "options": {
                "summary": "CORS support",
                "description": "Enable CORS by returning correct headers\n",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "CORS"
                ],
                "x-amazon-apigateway-integration": {
                    "type": "mock",
                    "requestTemplates": {
                        "application/json": "{\n  \"statusCode\" : 200\n}\n"
                    },
                    "responses": {
                        "default": {
                            "statusCode": "200",
                            "responseParameters": {
                                "method.response.header.Access-Control-Allow-Headers": "'Content-Type,X-Amz-Date,Authorization,X-Api-Key'",
                                "method.response.header.Access-Control-Allow-Methods": "'*'",
                                "method.response.header.Access-Control-Allow-Origin": "'*'"
                            },
                            "responseTemplates": {
                                "application/json": "{}\n"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Default response for CORS method",
                        "headers": {
                            "Access-Control-Allow-Headers": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Methods": {
                                "type": "string"
                            },
                            "Access-Control-Allow-Origin": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}

我收到错误:

An error occurred (BadRequestException) when calling the ImportRestApi operation: Errors found during import:
        Unable to put integration on 'GET' for resource at path '/': Invalid HTTP endpoint specified for URI

我哪里错了? 哪个 URI 无效? 如何添加更多错误捕获以查看遇到此异常的行和异常消息?

因为您的 swagger 文件格式错误。 它在验证时给出错误“重复的映射键”。 我认为您已经两次定义了“响应”。

我遇到过同样的问题。 很简单,'/' 中的 URI 应该是http://mysfits-nlb-52741b4979bb0b50.elb.us-east-2.amazonaws.com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM