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

Unable to set a parameter of type file as optional #246

Closed
MakarandNsd opened this issue Jun 13, 2022 · 3 comments
Closed

Unable to set a parameter of type file as optional #246

MakarandNsd opened this issue Jun 13, 2022 · 3 comments

Comments

@MakarandNsd
Copy link
Contributor

I am not sure if no one needed this before, but I have a use case where the file type parameter is optional, but the code below returns error before validating whether the field is required.

if p.parameter.Type == "file" {
file, header, ffErr := request.FormFile(p.parameter.Name)
if ffErr != nil {
return errors.NewParseError(p.Name, p.parameter.In, "", ffErr)
}
target.Set(reflect.ValueOf(runtime.File{Data: file, Header: header}))
return nil
}

I can throw in an additional if condition to check if the file is optional and return nil. Please let me know if that works.

@casualjim
Copy link
Member

yes please send a PR

MakarandNsd added a commit to MakarandNsd/runtime that referenced this issue Jun 14, 2022
@MakarandNsd
Copy link
Contributor Author

MakarandNsd commented Jun 15, 2022

@casualjim , can you please review the pr

MakarandNsd added a commit to MakarandNsd/runtime that referenced this issue Jun 27, 2022
MakarandNsd added a commit to MakarandNsd/runtime that referenced this issue Jun 27, 2022
Signed-off-by: Makarand <mnsd@divisionsinc.com>
@MakarandNsd
Copy link
Contributor Author

added test cases at #248
@casualjim

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