Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么swagger验证器在这里失败_Swagger - Fatal编程技术网

为什么swagger验证器在这里失败

为什么swagger验证器在这里失败,swagger,Swagger,我似乎不明白为什么大摇大摆的验证失败了 奇怪的是,如果我添加多条路径,验证只会抱怨最后一条路径。然后,如果我去掉最后一个,它就会开始抱怨上面的那个 在大摇大摆的编辑器中工作时,一切似乎都得到了验证 该文件如下: { "swagger":"2.0", "info":{ "version":"0.0.1", "title":"Bla API" }, "schemes":[ "https" ], "produces":[

我似乎不明白为什么大摇大摆的验证失败了

奇怪的是,如果我添加多条路径,验证只会抱怨最后一条路径。然后,如果我去掉最后一个,它就会开始抱怨上面的那个

在大摇大摆的编辑器中工作时,一切似乎都得到了验证

该文件如下:

{
   "swagger":"2.0",
   "info":{
      "version":"0.0.1",
      "title":"Bla API"
   },
   "schemes":[
      "https"
   ],
   "produces":[
      "application/json"
   ],
   "host":"rest.bla.com",
   "basePath":"/api/v2/fleet",
   "paths":{
      "/{organisation_id}/access_groups":{
         "get":{
            "tags":[
               "Access Group"
            ],
            "summary":"Get access groups\n",
            "description":"Gets a list of 'access_group' objects based on the provided search criteria\n",
            "parameters":[
               {
                  "in":"path",
                  "name":"organisation_id",
                  "required":"true",
                  "type":"string"
               },
               {
                  "name":"term",
                  "in":"query",
                  "required":"false",
                  "type":"string"
               },
               {
                  "name":"take",
                  "in":"query",
                  "required":"true",
                  "type":"integer",
                  "format":"int32"
               },
               {
                  "name":"skip",
                  "in":"query",
                  "type":"integer",
                  "format":"int32",
                  "required":"true"
               },
               {
                  "name":"order",
                  "in":"query",
                  "type":"string"
               }
            ],
            "responses":{
               "403":{
                  "description":"Permission Denied",
                  "schema":{
                     "$ref":"#/definitions/error"
                  }
               },
               "200":{
                  "description":"OK",
                  "schema":{
                     "type":"object",
                     "properties":{
                        "data":{
                           "type":"array",
                           "items":{
                              "$ref":"#/definitions/access-group-response"
                           }
                        },
                        "pagination":{
                           "$ref":"#/definitions/pagination"
                        }
                     }
                  }
               }
            }
         }
      }
   },
   "definitions":{
      "access-group":{
         "description":"an object which provides the ability to grant access to specific assets\n",
         "properties":{
            "name":{
               "type":"string"
            }
         }
      },
      "access-group-response":{
         "properties":{
            "data":{
               "$ref":"#/definitions/access-group"
            },
            "links":{
               "type":"array",
               "items":{
                  "$ref":"#/definitions/link"
               }
            }
         }
      },
      "error":{
         "type":"array",
         "items":{
            "type":"object",
            "properties":{
               "type":{
                  "type":"string"
               },
               "code":{
                  "type":"string"
               },
               "message":{
                  "type":"string"
               },
               "key":{
                  "type":"string"
               }
            }
         }
      },
      "link":{
         "properties":{
            "href":{
               "type":"string"
            },
            "rel":{
               "type":"string"
            }
         }
      },
      "pagination":{
         "properties":{
            "page":{
               "type":"number",
               "format":"int32"
            },
            "total":{
               "type":"number",
               "format":"int32"
            }
         }
      }
   }
}
{
   "schemaValidationMessages":[
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/0"
         }
      },
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/1"
         }
      },
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/2"
         }
      },
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/3"
         }
      }
   ]
}
而验证错误如下所示:

{
   "swagger":"2.0",
   "info":{
      "version":"0.0.1",
      "title":"Bla API"
   },
   "schemes":[
      "https"
   ],
   "produces":[
      "application/json"
   ],
   "host":"rest.bla.com",
   "basePath":"/api/v2/fleet",
   "paths":{
      "/{organisation_id}/access_groups":{
         "get":{
            "tags":[
               "Access Group"
            ],
            "summary":"Get access groups\n",
            "description":"Gets a list of 'access_group' objects based on the provided search criteria\n",
            "parameters":[
               {
                  "in":"path",
                  "name":"organisation_id",
                  "required":"true",
                  "type":"string"
               },
               {
                  "name":"term",
                  "in":"query",
                  "required":"false",
                  "type":"string"
               },
               {
                  "name":"take",
                  "in":"query",
                  "required":"true",
                  "type":"integer",
                  "format":"int32"
               },
               {
                  "name":"skip",
                  "in":"query",
                  "type":"integer",
                  "format":"int32",
                  "required":"true"
               },
               {
                  "name":"order",
                  "in":"query",
                  "type":"string"
               }
            ],
            "responses":{
               "403":{
                  "description":"Permission Denied",
                  "schema":{
                     "$ref":"#/definitions/error"
                  }
               },
               "200":{
                  "description":"OK",
                  "schema":{
                     "type":"object",
                     "properties":{
                        "data":{
                           "type":"array",
                           "items":{
                              "$ref":"#/definitions/access-group-response"
                           }
                        },
                        "pagination":{
                           "$ref":"#/definitions/pagination"
                        }
                     }
                  }
               }
            }
         }
      }
   },
   "definitions":{
      "access-group":{
         "description":"an object which provides the ability to grant access to specific assets\n",
         "properties":{
            "name":{
               "type":"string"
            }
         }
      },
      "access-group-response":{
         "properties":{
            "data":{
               "$ref":"#/definitions/access-group"
            },
            "links":{
               "type":"array",
               "items":{
                  "$ref":"#/definitions/link"
               }
            }
         }
      },
      "error":{
         "type":"array",
         "items":{
            "type":"object",
            "properties":{
               "type":{
                  "type":"string"
               },
               "code":{
                  "type":"string"
               },
               "message":{
                  "type":"string"
               },
               "key":{
                  "type":"string"
               }
            }
         }
      },
      "link":{
         "properties":{
            "href":{
               "type":"string"
            },
            "rel":{
               "type":"string"
            }
         }
      },
      "pagination":{
         "properties":{
            "page":{
               "type":"number",
               "format":"int32"
            },
            "total":{
               "type":"number",
               "format":"int32"
            }
         }
      }
   }
}
{
   "schemaValidationMessages":[
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/0"
         }
      },
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/1"
         }
      },
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/2"
         }
      },
      {
         "level":"error",
         "domain":"validation",
         "keyword":"oneOf",
         "message":"instance failed to match exactly one schema (matched 0 out of 2)",
         "schema":{
            "loadingURI":"http://swagger.io/v2/schema.json#",
            "pointer":"/definitions/parametersList/items"
         },
         "instance":{
            "pointer":"/paths/~1{organisation_id}~1access_groups/get/parameters/3"
         }
      }
   ]
}

parameters
对象的
required
属性应该是布尔类型,而不是字符串

如果将所有
“必需的”:“true”
s替换为
“必需的”:true
“必需的”:“false”
s替换为
“必需的”:false
您的示例验证ok