Skip to content

Broken BindFormParam calls #29

@renom

Description

@renom

My config is:

package: openapi
output: types.gen.go
generation:
  server: chi

Example of BindFormParam calls that's generated in wrappers:

err = BindFormParam("status", false, r.URL.Query(), &params.Status)
if err != nil {
	siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "status", Err: err})
	return
}

When trying to compile generated code I've got compilation errors:

api/openapi/types.gen.go:6082:32: cannot use false (untyped bool constant) as ParamLocation value in argument to BindFormParam
api/openapi/types.gen.go:6082:39: cannot use r.URL.Query() (value of map type url.Values) as string value in argument to BindFormParam

That's because the types of passed variables does not match the types of BindFormParam parameters:

func BindFormParam(paramName string, paramLocation ParamLocation, value string, dest any) error

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