AWS API 网关无法导入 Swagger 定义:不支持的模型类型 'MapProperty'

AWS API Gateway fails to import Swagger definition: Unsupported model type 'MapProperty'

我目前正在此屏幕上尝试导入我的应用程序的 swagger 定义,以便我可以创建一个 API 网关实例。

不幸的是,您可以看到我遇到了一些错误 - 尽管 swagger 似乎认为它完全没问题。

Your API was not imported due to errors in the Swagger file.
Unable to create model for 200 response to method 'GET /api/v1/courses': Validation Result: warnings : [], errors : [Invalid content type specified: */*]
Unsupported model type 'MapProperty' in 200 response to method 'GET /api/v1/courses/all'. Ignoring.

这是我的 swagger 定义:

{
    "swagger": "2.0",
    "info": {
        "description": "Api Documentation",
        "version": "1.0",
        "title": "Api Documentation",
        "termsOfService": "urn:tos",
        "contact": {},
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0"
        }
    },
    "host": "********.appspot.com",
    "basePath": "/",
    "tags": [{
        "name": "course-controller",
        "description": "Course Controller"
    }],
    "paths": {
        "/api/v1/courses": {
            "get": {
                "tags": ["course-controller"],
                "summary": "getCourses",
                "operationId": "getCoursesUsingGET",
                "produces": ["*/*"],
                "parameters": [{
                    "name": "code",
                    "in": "query",
                    "description": "code",
                    "required": false,
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Course"
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Not Found"
                    }
                },
                "deprecated": false
            }
        },
        "/api/v1/courses/all": {
            "get": {
                "tags": ["course-controller"],
                "summary": "getAllCourses",
                "operationId": "getAllCoursesUsingGET",
                "produces": ["*/*"],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "type": "object",
                            "additionalProperties": {
                                "type": "object"
                            }
                        }
                    },
                    "401": {
                        "description": "Unauthorized"
                    },
                    "403": {
                        "description": "Forbidden"
                    },
                    "404": {
                        "description": "Not Found"
                    }
                },
                "deprecated": false
            }
        }
    },
    "definitions": {
        "Course": {
            "type": "object",
            "properties": {
                "code": {
                    "type": "string"
                },
                "credits": {
                    "type": "integer",
                    "format": "int32"
                },
                "id": {
                    "type": "integer",
                    "format": "int32"
                },
                "lastUpdated": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "prerequisites": {
                    "type": "string"
                },
                "restrictions": {
                    "type": "string"
                },
                "seats": {
                    "$ref": "#/definitions/Seats"
                },
                "waitlist": {
                    "$ref": "#/definitions/Seats"
                }
            },
            "title": "Course"
        },
        "Seats": {
            "type": "object",
            "properties": {
                "actual": {
                    "type": "integer",
                    "format": "int32"
                },
                "capacity": {
                    "type": "integer",
                    "format": "int32"
                },
                "remaining": {
                    "type": "integer",
                    "format": "int32"
                }
            },
            "title": "Seats"
        }
    }
}

是否有任何理由可以让这个 swagger 定义破坏 API 网关?

AWS API 网关在其 OpenAPI 支持中有 some limitations。例如,它不支持模型中的 additionalProperties(此关键字用于 API 中 /api/v1/courses/all 端点的 200 响应模式)。

您可以单击“导入并忽略警告”按钮忽略这些错误并继续导入。