Swagger-Autogen and Multer: Multiform data
See original GitHub issueHi Davi,
I have an endpoint used for file uploading. I’m using express for the router and multer as a middleware for the upload task.
My upload endpoint should receive two files. Multer inserts the files in req. files. How can I set up swagger to recognize it?
Here is what I am trying to do.
const controller = (req, res) => {
// #swagger.tags = ['Reconcile']
// #swagger.summary = 'Your summary here'
// #swagger.description = 'My description'
// #swagger.consumes = ['multipart/form-data']
// #swagger.produces = ['application/json']
/* #swagger.parameters['file_A'] = {
in: 'files',
type: 'file',
required: 'true',
description: 'File data',
} */
/* #swagger.parameters['file_B'] = {
in: 'files',
type: 'file',
required: 'true',
description: 'File data',
} */
const files = req.files;
console.log(files);
}
Thanks, Paulo
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
using swagger (v3; yaml) multiparty form-data and node.js ...
parser(req) seems fails when using swagger api. The reason seems to be because the data is located in a different location within the...
Read more >swagger-autogen - npm
This module performs the automatic construction of the Swagger documentation. The module can identify the endpoints and automatically ...
Read more >Multipart form data file upload runs into size limit issue #338
I have this file upload api (multipart/form-data) and I run into a http 413 when I upload a 3.2 mb ... Swagger-node uses...
Read more >File Upload - Swagger
Swagger 2.0 supports file uploads sent with Content-Type: multipart/form-data . That is, your API server must consume multipart/form-data for this operation:.
Read more >Complete News/Blog API using NodeJS (Express), MongoDB ...
Data modeling and schema construction using Mongoose; Categories, stories, videos and comments CRUD and authorized or protected routes; Swagger ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks Davi!
It works! I will close the issue.
Thanks for the code, @PauloFavero. Trying here…
in route.js file:
here, it work fine! The req.files received the 2 files. Try it and let me know if doesn’t work.