Skip to content

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

@MakarandNsd

Description

@MakarandNsd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions