Swagger 为什么定义无法在此架构中显示?

Swagger 为什么定义无法在此架构中显示?,swagger,swagger-ui,Swagger,Swagger Ui,我正在尝试开发一个符合swagger规范的模式。见下文。参数和响应的定义(模型/模式)不会显示在swagger ui界面中,所以我的问题是为什么会这样。模式通过了swagger验证器 { "swagger": "2.0", "info": { "version": "1.0.0", "title": "example", "description": "provides various stuff", "termsOfService": "none",

我正在尝试开发一个符合swagger规范的模式。见下文。参数和响应的定义(模型/模式)不会显示在swagger ui界面中,所以我的问题是为什么会这样。模式通过了swagger验证器

{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "example",
    "description": "provides  various stuff",
    "termsOfService": "none",
    "contact": {
      "name": "admin",
      "url": "http://www.example.co.uk",
      "email": "hostmaster@example.com"
    },
    "license": {
      "name": "All Rights Reserved.",
      "url": "http://example.com"
    }
  },
  "host": "ofexample.co.uk",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "paths": {
    "/list": {
      "post": {
        "parameters": [
          {
            "name": "no_name",
            "in": "body",
            "required": false,
            "schema": {
              "$ref": "#definitions/APIName"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "schema": {
              "$ref": "#definitions/Versions"
            }
          }
        }
      }
    },
    "/ver/setdefault": {
      "post": {
        "parameters": [
          {
            "name": "no_name",
            "in": "body",
            "required": false,
            "schema": {
              "$ref": "#definitions/App"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "schema": {
              "$ref": "#definitions/App"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "APIName": {
      "type": "string"
    },
    "App": {
      "properties": {
        "name": {
          "type": "object",
          "$ref": "#/definitions/APIName",
          "description": "\n The name"
        },
        "id": {
          "type": "string",
          "description": "important field"
        },
        "version": {
          "type": "string"
        }
      }
    },
    "Versions": {
      "type": "string",
      "additionalProperties": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    }
  }
}

规范本身几乎是正确的,唯一不正确的部分是
$ref
。例如,在
#
定义/APIName
之间需要有一个
/

      {
        "name": "no_name",
        "in": "body",
        "required": false,
        "schema": {
          "$ref": "#/definitions/APIName"
        }
      }
注意:由于错误,UI不会显示任何引用的原语。为参数内联定义它将正确地显示它,但对于响应它不会

另一个注意事项是,虽然现在还没有很好的定义,但是如果没有
消费
/
产生
,那么将使用的mime类型是
应用程序/json
。如果要使用文本,可能需要将其设置为
text/plain
以传递字符串