swagger:如何验证 formData
swagger: how to validate formData
到目前为止,如果参数来自 "in": "body" 或者如果预期的输入在 json格式。
但是,我找不到如何验证作为 formData.
输入的简单 string
下面是我的 swagger 脚本(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!",
}
}
}
}
我删除了 schema,因为它似乎只适用于 "in":"body"
我一直在网上搜索,但似乎找不到灯。
虽然我仍然会搜索......任何提示将不胜感激。
非常感谢您。
此处必须使用不同的源媒体类型。指定 "consumes" 成员以包含 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!",
}
}
}
}
到目前为止,如果参数来自 "in": "body" 或者如果预期的输入在 json格式。 但是,我找不到如何验证作为 formData.
输入的简单 string下面是我的 swagger 脚本(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!",
}
}
}
}
我删除了 schema,因为它似乎只适用于 "in":"body"
我一直在网上搜索,但似乎找不到灯。 虽然我仍然会搜索......任何提示将不胜感激。
非常感谢您。
此处必须使用不同的源媒体类型。指定 "consumes" 成员以包含 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!",
}
}
}
}