7

我正在尝试使用 swagger 编写服务器响应的静态 .json 文件。我被帖子正文卡住了,不知道如何描述它。它看起来与 Grooveshark api 非常相似,你有一个页面和不同的 post 参数。

所以,给定grooveshark的例子(http://developers.grooveshark.com/docs/public_api/v3/

接受查询的页面:

http://api.grooveshark.com/ws3.php?sig=cd3ccc949251e0ece014d620bbf306e7

帖子正文:

{
  'method': 'addUserFavoriteSong',
  'parameters': {'songID': 0},
  'header': {
    'wsKey': 'key',
    'sessionID': 'sessionID'
  }
}

我该如何用招摇来形容呢?

4

1 回答 1

8

在不知道这个 API 是如何运行的情况下(例如,“songID”是唯一的参数类型吗?我猜你会在你的模型部分想要这样的东西:

"models": {
  "FavoriteSong": {
    "id": "FavoriteSong",
    "properties": {
      "parameters": {
        "type": "Parameter"
      },
      "header": {
        "type": "Header"
      }
    }
  },
  "Parameter": {
    "id": "Parameter",
      "properties": {
        "songID": {
          "type": "integer",
          "format": "int32"
        }
      }
    }  
  "Header": {
    "id": "Header",
      "properties": {
        "wsKey": {
          "type": "string"
        },
        "sessionID": {
          "type": "string"
        }
      }
    }
  }
}

并且该操作会将“FavoriteSong”类型作为主体类型:

"parameters": [
  {
    "name": "body",
    "description": "object to add",
    "required": true,
    "type": "FavoriteSong",
    "paramType": "body"
  }
]
于 2013-11-11T17:03:25.807 回答