2017-07-14 99 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!", 
      } 
     } 
    } 
}