为我的api端点创建一个Swagger文档。我有一个在终端
中工作的curl命令curl -X POST -b "http://localhost:3000/v0/users/4/avatar" -H "accept: application/json" -H "content-type: multipart/form-data" -F avatar=@wolf.b64
这返回的是来自rails的ActionDispatch::Http::UploadedFile
对象。
但是,我的swagger doc curl命令看起来像这样
curl -X POST "http://localhost:3000/v0/users/4/avatar" -H "accept: application/json" -H "content-type: multipart/form-data" -F avatar=wolf.b64
头像参数不以@
开头,这使得它只是一个字符串而不是一个文件。
我需要帮助弄清楚如何设置swagger,以便在文件名前面添加@。
这就是我的Swagger的样子。
"post": {
"tags": [
"user"
],
"description": "Update user",
"operationId": "updateUser",
"produces": [
"application/json"
],
"consumes": [
"multipart/form-data"
],
"parameters": [
{
"name": "userId",
"in": "path",
"description": "ID of the user that needs to be updated",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "avatar",
"in": "formData",
"description": "Base64 encoded image upload",
"required": true,
"type": "file"
}
],
"responses": {
"200": {
"description": "The user avatars was successfully updated"
},
"401": {
"description": "Unauthorized"
}
}
}
},