2017-07-14 75 views
0

到目前为止,我能够做的招摇验证如果参数从“中的”:“身体”或者如果预期输入处于JSON格式。 但是,我找不到如何验证一个简单的字符串输入为formData招摇:如何验证FORMDATA

下面是我昂首阔步脚本(JSON格式)

v1swag = { 
    "cancels_post": { 
     "tags": ["/api/v1"], 
     "parameters": [ 
      { 
       "name": "token", 
       "in": "formData", 
       "type": "string", 
       "required": True, 
       "description": "Cancels the provided token.", 
      } 
     ], 
     "responses": { 
      "200": { 
       "description": "Success!", 
      } 
     } 
    } 
} 

我删除了模式,因为它似乎只为“在” 工作: “身体”

我已经一直在寻找网络,但似乎无法找到光明。 虽然我仍然会搜索...任何提示将不胜感激。

非常感谢您提前。

回答

0

此处需要使用不同的源媒体类型。指定“消费”成员以包含媒体类型application/x-www-form-urlencoded

v1swag = { 
    "cancels_post": { 
     "tags": ["/api/v1"], 
     "consumes": [ 
      "application/x-www-form-urlencoded" 
     ], 
     "parameters": [ 
      { 
       "name": "token", 
       "in": "formData", 
       "type": "string", 
       "required": True, 
       "description": "Cancels the provided token.", 
      } 
     ], 
     "responses": { 
      "200": { 
       "description": "Success!", 
      } 
     } 
    } 
}