【发布时间】:2021-11-11 04:19:29
【问题描述】:
我想在表单数据中传递一个数组,如下所示:
但我在 NodeJS 控制台中将整个数组作为字符串获取,如下所示:
{
targetUniversity: "['613e3ecfefa725074cb17968', '613e3ecfefa725074cb17969']",
targetBusinessType: "['freelancer','sw dev']",
}
swagger 文件看起来像这样,
"/announce": {
"post": {
"tags": ["Announcement"],
"description": "Make an announcement",
"parameters": [
{
"name": "targetUniversity",
"in": "formData",
"type": "array",
"description": "University ID in array []- from DD"
},
{
"name": "targetBusinessType",
"in": "formData",
"type": "array",
"description": "Business type (string - name) in array []"
}
],
"produces": ["application/json"],
"responses": {
"201": {
"description": "announced successfully"
}
}
}
}
我只想要数组本身,而不是字符串格式的数组。
【问题讨论】:
-
澄清一下 - 请求正文需要作为表单数据(即
application/x-www-form-urlencoded或multipart/form-data)还是作为 JSON 发送? -
应该只是表单数据
标签: node.js swagger swagger-ui swagger-2.0