Invalid model schema specified for swagger

≡放荡痞女 提交于 2021-02-09 10:57:08

问题


I tried to deploy API on AWS but it not allowed to add a model in the JSON file and shows error :

It working without the use of model so maybe it not take model this way so please suggest me how to use a model in API JSON on AWS!

Error is :

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.

And my swagger json is :

{
  "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
      }
    }
  }
}

Can any one suggest how to import model in swagger json api on AWS.


回答1:


According to AWS API Gateway - Known Issues:

  • API Gateway supports most of the Swagger specification, with the following exceptions:
    • The additionalProperties field is not supported in Models.
    • The example tag is not supported.
    • Numbers of the int32 or int64 type is not supported.
    • ...

So it looks that your model is not fully compatible with API Gateway. Try removing additionalProperties, format: int32 and example from the model and see if it helps.



来源:https://stackoverflow.com/questions/50985362/invalid-model-schema-specified-for-swagger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!