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

formData required validation #26

Open
fabricio-godoi opened this issue Jan 15, 2020 · 2 comments
Open

formData required validation #26

fabricio-godoi opened this issue Jan 15, 2020 · 2 comments

Comments

@fabricio-godoi
Copy link

fabricio-godoi commented Jan 15, 2020

Greetings everyone,
I'm having problem when validation formData file upload with multer and swaggerRoutes.
swagger.yml

parameters:
- in: "formData"
        type: "file"
        required: true
        name: "document"

The swaggerRoutes method returns this when validating the "required: true":
"message": "formData requires property \"document\""

If I set required as false, the swaggerRotues continues without any problem.

Anyone have any ideas how to solve this?

@russell-matt
Copy link

russell-matt commented Feb 25, 2020

@fabricio-godoi Were you sending through an accept header on your requests? I recently found in my own projects that the form data parsing fails if an accept header that is not "multipart/form-data" or "application/x-www-form-urlencoded" is sent on the request.

It's specifically coming from this line.

It seems like the accept header is incorrectly being used to determine whether the request will have form data or not; instead of the content-type header.

It will work as intended if no accept header is sent, or if an accept header like "*/*", "application/*" or "multipart/*" is used. However doing that as a work around seems ill advised.

@fabricio-godoi
Copy link
Author

@russell-matt I was not providing the accept header, just the "content-type": "multipart/form-data".
For now, I set the field as not required since I could not configure it properly, but I`ll keep in mind that workaround in future releases.

But the problem is with the swagger web interface that does not set up the accept header, so this workaround will not resolve all my problems 😞

I hope that is fixed in the feature releases. Thank you for your response 😄

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

No branches or pull requests

2 participants