Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastify integration fails when using fastify-multipart #193

Open
Outc4sted opened this issue May 18, 2023 · 0 comments
Open

Fastify integration fails when using fastify-multipart #193

Outc4sted opened this issue May 18, 2023 · 0 comments

Comments

@Outc4sted
Copy link

Outc4sted commented May 18, 2023

I have a fastify project that is using fastify-multipart for a file upload endpoint. With fastify-multipart registered, all requests sent to my api, including endpoints that have nothing to do with files, will return an error from the openapi-validator:

🚀 ~ requestFilesExtractor.js
🚀 ~ req.file: [AsyncFunction: getMultipartFile]
🚀 ~ req.files: [AsyncGeneratorFunction: getMultipartFiles]
🚀 ~ app.setErrorHandler ~ error: TypeError: files.push is not a function
    at module.exports (C:\wrkspc\...\app\node_modules\openapi-validator-middleware\src\utils\requestFilesExtractor.js:7:19)

requestFilesExtractor.js file checks if req.file or req.files exists, and then proceeds to do other stuff. When fastify-multipart is registered, req.file and req.files are async functions and so they pass the check for existence, but then the proceeding logic bombs out when it tries handle them.

This has probably something to do with openapi-validator using express/multer under the hood but I'm not sure of a path forward except maybe having to install fastify-express along with express/multer and redoing my controller logic for handling files..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant