Skip to content

Commit

Permalink
fix: set explode=false for query params
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgtaylor committed Oct 13, 2023
1 parent c81c4ba commit 202f943
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions huma.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,18 @@ func findParams(registry Registry, op *Operation, t reflect.Type) *findResult[*p

name := ""
required := false
var explode *bool
if p := f.Tag.Get("path"); p != "" {
pfi.Loc = "path"
name = p
required = true
} else if q := f.Tag.Get("query"); q != "" {
pfi.Loc = "query"
name = q
// If `in` is `query` then `explode` defaults to true. Parsing is *much*
// easier if we use comma-separated values, so we disable explode.
nope := false
explode = &nope
} else if h := f.Tag.Get("header"); h != "" {
pfi.Loc = "header"
name = h
Expand All @@ -129,6 +134,7 @@ func findParams(registry Registry, op *Operation, t reflect.Type) *findResult[*p
op.Parameters = append(op.Parameters, &Param{
Name: name,
In: pfi.Loc,
Explode: explode,
Required: required,
Schema: pfi.Schema,
Example: example,
Expand Down

0 comments on commit 202f943

Please sign in to comment.