为什么我的招摇PUT或POST不会?

时间:2015-02-09 22:37:20

标签: swagger swagger-ui

我使用的是Swagger 2.0,我的定义是:

{
  "/users/{UserId}": {
    "get": {
      "summary": "Get a specific user by id",
      "description": "",
      "parameters": [{
        "name": "UserId",
        "in": "path",
        "description": "Id of the User.",
        "required": true,
        "type": "string"
      }],
      "tags": [
        "Users"
      ],
      "responses": {
        "200": {
          "description": "An specific user",
          "schema": {
            "$ref": "#/definitions/User"
          }
        }
      }
    },
    "put": {
      "summary": "Update a User",
      "description": "",
      "consumes": "application/x-www-form-urlencoded",
      "parameters": [{
        "name": "UserId",
        "in": "path",
        "description": "Id of the user.",
        "required": true,
        "type": "string"
      }, {
        "name": "name",
        "in": "formData",
        "description": "Name of the user",
        "required": false,
        "type": "string"
      }, {
        "name": "username",
        "in": "formData",
        "description": "Username of the user. Must be unique and cannot have spaces.",
        "required": false,
        "type": "string"
      }, {
        "name": "email",
        "in": "formData",
        "description": "Email of the user. Must be unique.",
        "required": false,
        "type": "string"
      }, {
        "name": "entities",
        "in": "formData",
        "description": "Entities that the user is associated with.",
        "required": false,
        "type": "array",
        "items": {
          "name": "entity_id",
          "type": "string"
        }
      }],
      "tags": [
        "Users"
      ],
      "responses": {
        "200": {
          "description": "successful operation",
          "schema": {
            "$ref": "#/definitions/User"
          }
        }
      }
    }
  }
}

但是在我的招摇UI中,我正在尝试按照用户界面输入一些数据: enter image description here

但是当它执行请求时,它不会在正文中发送任何内容。我做错了什么?

1 个答案:

答案 0 :(得分:2)

这是其中一个alpha版本(https://github.com/swagger-api/swagger-ui/issues/838)的问题。 M1版本(目前为主版本)解决了这个问题。