You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
I'm pulling my hair out on this one. I have a POST endpoint and have the spec setup like so:
module.exports.create = {
'spec': {
description : "Create a new Stock",
path : "/stocks",
method: "POST",
summary : "Create a new Stock",
notes : "Create a new Stock",
type : "Stock",
nickname : "postStock",
produces : ["application/json"],
parameters : [
paramTypes.form("quantity", "how many are there?", "integer")
]
},
'action': function(req, res) {
console.log("**1");
console.log(req.body.quantity);
console.log(req.files);
console.log("**2");
}
};
When swagger-ui makes that post, all is dandy. I see quantity with a value and files as undefined. However, when i add the following param to the parameters collection:
{
"name": "image",
"description": "The file to upload.",
"paramType": "body",
"required": true,
"allowMultiple": false,
"dataType": "file"
}
both req.body.quantity and req.files are undefined.
I've explored a number of options for fixing this. Using type instead of dataType, File instead of file, and form instead of body, and nothing seems to work. I've also chased down the idea that my version of swagger-ui is different than what is included with this module, and still have the same issue.
Is this possibly related to the formData data type that I see the current Pet Store demo using?
Can anyone point me in the right direction on this one? Just seeing a working example with source would be awesome. As is, I don't think it's possible to upload a file, let alone a file along with other params.
The text was updated successfully, but these errors were encountered:
It appears my previous comment actually has a lot of worth. For me in particular the issue came down to correctly having multer required, but never setting the dest folder via:
app.use(multer({ dest: './uploads/'}));
Once that was set, req.files has data, and so do my other params.
In summary, I'm using express 4.12.2, and in order to get file uploads to work at all, let alone in swagger-ui, the multer module is needed, and a dest folder needs to be set.
I hope this issue being documented and the fix helps someone else!
I'm pulling my hair out on this one. I have a POST endpoint and have the spec setup like so:
When swagger-ui makes that post, all is dandy. I see quantity with a value and files as undefined. However, when i add the following param to the parameters collection:
both req.body.quantity and req.files are undefined.
I've explored a number of options for fixing this. Using
type
instead ofdataType
,File
instead offile
, andform
instead ofbody
, and nothing seems to work. I've also chased down the idea that my version of swagger-ui is different than what is included with this module, and still have the same issue.Is this possibly related to the
formData
data type that I see the current Pet Store demo using?Can anyone point me in the right direction on this one? Just seeing a working example with source would be awesome. As is, I don't think it's possible to upload a file, let alone a file along with other params.
The text was updated successfully, but these errors were encountered: