为 swagger 指定的模型架构无效

dbs*_*hah 3 json swagger aws-api-gateway

我尝试在 AWS 上部署 API,但不允许在 JSON 文件中添加模型并显示错误:

它在不使用模型的情况下工作,所以也许它不会以这种方式使用模型,所以请建议我如何在 AWS 上的 API JSON 中使用模型!

错误是:

Your API was not imported due to errors in the Swagger file.
Unable to create model for 'LandingPageDTO': Invalid model specified: Validation Result: warnings : [], errors : [Invalid model schema specified]
Unable to put method 'POST' on resource at path '/userservice/la/program-summary': Invalid model name specified: null
Additionally, these warnings were found:
Reference to model 'LandingPageDTO' not found. Ignoring.
Run Code Online (Sandbox Code Playgroud)

我的招摇json是:

{
  "swagger" : "2.0",
  "info" : {
    "description" : "demo",
    "version" : "v0.1",
    "title" : "demo"
  },
  "host": "localhost:7000",
  "basePath": "/",
  "paths" : {
    "/userservice/la/program-summary" : {
      "post" : {
        "tags" : [ "user-controller" ],
        "summary" : "getLALandingPage",
        "operationId" : "getLALandingPageUsingPOST",
        "consumes" : [ "application/json" ],
        "produces" : [ "application/json" ],
        "parameters" : [ {
          "in" : "body",
          "name" : "landingPage",
          "description" : "landingPage",
          "required" : true,
          "schema" : {
            "$ref" : "#/definitions/LandingPageDTO"
          }
        } ],
        "responses" : {
          "200" : {
            "description" : "OK",
            "schema" : {
              "type" : "object",
              "properties" : { }
            }
          },
          "201" : {
            "description" : "Created"
          },
          "401" : {
            "description" : "Unauthorized"
          },
          "403" : {
            "description" : "Forbidden"
          },
          "404" : {
            "description" : "Not Found"
          }
        }
      }
    }
  },
  "definitions" : {
  "LandingPageDTO" : {
      "type" : "object",
      "properties" : {
        "filter" : {
          "type" : "object",
          "additionalProperties" : {
            "type" : "string"
          }
        },
        "page" : {
          "type" : "integer",
          "format" : "int32"
        },
        "searchTerm" : {
          "type" : "string"
        },
        "size" : {
          "type" : "integer",
          "format" : "int32"
        },
        "sortDirection" : {
          "type" : "string",
          "enum" : [ "ASC", "DESC" ]
        },
        "sortProperty" : {
          "type" : "string"
        },
        "uid" : {
          "type" : "string"
        }
      },
      "example" : {
        "filter" : {
          "key" : "filter"
        },
        "uid" : "uid",
        "sortDirection" : "ASC",
        "searchTerm" : "searchTerm",
        "size" : 6,
        "sortProperty" : "sortProperty",
        "page" : 0
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议如何在AWS上的swagger json api中导入模型。

Hel*_*len 5

根据AWS API Gateway - 已知问题

  • API Gateway 支持大部分 Swagger 规范,但有以下例外:
    • additionalProperties模型中不支持该字段。
    • example不支持该标签。
    • 不支持int32orint64类型的数字。
    • ...

所以看起来您的模型与 API Gateway 不完全兼容。尝试从模型中删除additionalProperties,format: int32example看看是否有帮助。