Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.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-无效的JSON错误_Json_Swagger_Swagger Ui - Fatal编程技术网

Swagger-无效的JSON错误

Swagger-无效的JSON错误,json,swagger,swagger-ui,Json,Swagger,Swagger Ui,我只是从招摇过市的用户界面开始,我试图了解它是如何工作的。 到目前为止,我已经(手动)输入了一些JSON,结果如下: { "swagger": "2.0", "info": { "version": "1.0.0", "title": "PhakeApps API", "contact": { "name": "PhakeApps API team", "url": "http://p

我只是从招摇过市的用户界面开始,我试图了解它是如何工作的。 到目前为止,我已经(手动)输入了一些JSON,结果如下:

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "PhakeApps API",
        "contact": {
            "name": "PhakeApps API team",
            "url": "http://phakeapps.com/"
        },
        "license": {
            "name": "Creative Commons 4.0 International",
            "url": "http://creativecommons.org/licenses/by/4.0/"
        }
    },
    "host": "api.phakeapps.com",
    "basePath": "/v1",
    "schemes": [
        "http"
    ],
    "produces": [
        "application/json"
    ],
    "consumes": [
        "application/json"
    ],
    "paths": {
        "/places/search": {
            "post": {
                "tags": [
                    "Places"
                ],
                "description": "Search for (a) place(s) <br /><br /> <b>id</b> - The ID of the request. <br /> <b>api_key</b> - API Key for the platform the request is sent. <i>Currently, not required.</i> <br /> <b>Params</b> - Required. <i>See model & model schema.</i>",
                "operationId": "PlacesSearch",
                "produces": [
                    "application/json"
                ],
                "consumes": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "request",
                        "in": "body",
                        "paramType": "body",
                        "description": "Object containing the <u>id</u>, <u>api_key</u> and certain <u>params</u>.",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/Search"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success",
                        "schema": {
                            "$ref": "#/definitions/PlacesResult"
                        }
                    },
                    "403": {
                        "description": "Validation error or Server Failure",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "PlacesResult": {
            "required": [
                "data",
                "id",
                "code"
            ],
            "properties": {
                "data": {
                    "$ref": "#/definitions/Places"
                },
                "id": {
                    "type": "integer",
                    "format": "int32"
                },
                "code": {
                    "type": "integer",
                    "format": "int32"
                }
            }
        },
        "Places": {
            "required": [
                "places"
            ],
            "properties": {
                "places": {
                    "$ref": "#/definitions/Place"
                }
            }
        },
        "City": {
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "Neighbourhood": {
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "Cuisine": {
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
        "Place": {
            "required": [
                "id",
                "name",
                "city",
                "neighbourhood",
                "address",
                "cuisine",
                "price",
                "photos_cnt",
                "lat",
                "lng",
                "is_fav"
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "city": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/City"
                    }
                },
                "neighbourhood": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Neighbourhood"
                    }
                },
                "address": {
                    "type": "string"
                },
                "cuisine": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Cuisine"
                    }
                },
                "price": {
                    "type": "integer",
                    "format": "int32"
                },
                "photos_cnt": {
                    "type": "integer",
                    "format": "int32"
                },
                "lat": {
                    "type": "double"
                },
                "lng": {
                    "type": "double"
                },
                "is_fav": {
                    "type": "boolean"
                }
            }
        },
        "Search": {
            "required": [
                "id",
                "api_key",
                "params"
            ],
            "properties": {
                "id": {
                    "type": "integer",
                    "format": "int64"
                },
                "api_key": {
                    "type": "string"
                },
                "params": {
                    "$ref": "#/definitions/SearchParams"
                }
            }
        },
        "SearchParams": {
            "required": [
                "user_id",
                "city_id",
                "people",
                "dt",
                "locale"
            ],
            "properties": {
                "user_id": {
                    "type": "string",
                    "default": "956dda4c21c72e48f5f17a7cd783a0f7"
                },
                "city_id": {
                    "type": "string",
                    "default": "4ec4b3e6098c9d23c925b0c2451eb06a"
                },
                "people": {
                    "type": "integer",
                    "format": "int32",
                    "minimum": 1,
                    "default": 2
                },
                "dt": {
                    "type": "integer",
                    "format": "int32",
                    "default": "1427742000"
                },
                "locale": {
                    "type": "string",
                    "default": "bg"
                },
                "place_id": {
                    "type": "string",
                    "default": "0"
                },
                "neighborhood_id": {
                    "type": "string",
                    "default": "0"
                },
                "cuisine_id": {
                    "type": "string",
                    "default": "0"
                },
                "kids_place": {
                    "type": "boolean",
                    "default": false
                },
                "price": {
                    "type": "integer",
                    "format": "int64",
                    "default": 1
                },
                "outdoors": {
                    "type": "boolean",
                    "default": false
                }
            }
        },
        "Error": {
            "required": [
                "code",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "format": "int32"
                },
                "data": {
                    "type": "array",
                    "items": {
                        "type": "array"
                    }
                }
            }
        }
    }
}
请注意,它的工作原理与预期一致(到目前为止)。它正确显示数据(模型和模型结构)。发出请求并检索响应。然而验证器说它是无效的。(黄色徽章上写着“无效”,而不是红色徽章上写着“错误”)


我遗漏了什么?

您的规范确实无效。在
位置
定义中,您使用
的“类型”:“double”
来描述
lat
(以及
lng
)属性的类型,但此类类型不存在

如果要描述“double”大小的数值,应按以下方式更改定义:

            "lng": {
                "type": "number",
                "format": "double"
            }

无论您在哪里使用
double
类型,都要这样做,这样应该可以解决这个问题。

谢谢您的提示。但是错误仍然是一样的。我刚刚测试了它,错误已经改变了。规范还存在其他问题,但此解决方案修复了该错误。另外一个错误是,您在操作的参数中使用了
paramType
,这不是有效的属性。删除它,你的规范就应该得到验证。我竟然犯了同样的错误。谢谢
            "lng": {
                "type": "number",
                "format": "double"
            }