Swagger POST with json body

前端 未结 1 488
野趣味
野趣味 2021-01-12 13:54

I am trying to write static .json file of server response using swagger. I\'m stuck with post body and do not know how to describe it. It looks pretty much similar to Groove

1条回答
  •  萌比男神i
    2021-01-12 14:29

    without knowing a ton about how this API operates (such as, is "songID" the only parameter type?, I'm guessing you'd want something like this in your models section:

    "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"
            }
          }
        }
      }
    }
    

    And the operation would take the type "FavoriteSong" as a body type:

    "parameters": [
      {
        "name": "body",
        "description": "object to add",
        "required": true,
        "type": "FavoriteSong",
        "paramType": "body"
      }
    ]
    

    0 讨论(0)
提交回复
热议问题