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.
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.
runtime/middleware/parameter.go
Lines 206 to 213 in 3f9800f
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.