Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.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
Api 招摇过市错误|数据与来自';其中之一';_Api_Swagger - Fatal编程技术网

Api 招摇过市错误|数据与来自';其中之一';

Api 招摇过市错误|数据与来自';其中之一';,api,swagger,Api,Swagger,我正在使用Swagger规范设计一个API。毫无理由,我正面临一个我无法解决的错误 数据与“oneOf”中的任何架构不匹配 检查时,我发现了一个更具描述性的错误: 对象\u缺少\u必需\u属性 缺少必需的属性:$ref 重新阅读,我发现没有必要在参数“部分”中添加$ref属性,因此我感到困惑和困惑 错误在第34行。 { "swagger": "2.0", "info": { "title": "##

我正在使用Swagger规范设计一个API。毫无理由,我正面临一个我无法解决的错误

数据与“oneOf”中的任何架构不匹配

检查时,我发现了一个更具描述性的错误:

对象\u缺少\u必需\u属性

缺少必需的属性:$ref

重新阅读,我发现没有必要在
参数
“部分”中添加
$ref
属性,因此我感到困惑和困惑

错误在第34行。

{
"swagger": "2.0",
"info": {
    "title": "###",
    "version": "0.1.0"
},
"host": "api.###",
"basePath": "/",
"schemes": [
    "https"
],
"produces": [
    "application/json"
],
"paths": {
    "/social-networks": {
        "get": {
            "summary": "Retrieves all social networks.",
            "description": "Retrieves all social networks supported by ### along with the constraints of each one.",
            "responses": {
                "200": {
                    "description": "",
                    "examples": {
                        "application/json": {}
                    }
                }
            }
        }
    },
    "/social-networks/{name}": {
        "get": {
            "summary": "Retrieves a social network.",
            "description": "Retrieves the social network whose name matches with the specified path parameter.",
            "parameters": [
                {
                    "name": "name",
                    "in": "path",
                    "description": "The name of the social network.",
                    "required": "true",
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                    "description": ""
                }
            }
        }
    }
}

我做错了什么?

路径参数所需的
值应该是
true
。你的是字符串
“true”

您的JSON也无效,最后缺少一个
}
。以下是您在YAML中大摇大摆的固定版本:

---
  swagger: "2.0"
  info: 
    title: "###"
    version: "0.1.0"
  host: "api.###"
  basePath: "/"
  schemes: 
    - "https"
  produces: 
    - "application/json"
  paths: 
    /social-networks: 
      get: 
        summary: "Retrieves all social networks."
        description: "Retrieves all social networks supported by ### along with the constraints of each one."
        responses: 
          200: 
            description: ""
            examples: 
              application/json: {}
    /social-networks/{name}: 
      get: 
        summary: "Retrieves a social network."
        description: "Retrieves the social network whose name matches with the specified path parameter."
        parameters: 
          - 
            name: "name"
            in: "path"
            description: "The name of the social network."
            required: true
            type: "string"
        responses: 
          200: 
            description: ""

@第34行就是
参数部分。非常感谢!正如您所说,错误是“引用的
true
值”。