From 202f9438ca00ff545a07370ca028fdc90a24c24e Mon Sep 17 00:00:00 2001 From: "Daniel G. Taylor" Date: Fri, 13 Oct 2023 09:05:58 -0700 Subject: [PATCH] fix: set explode=false for query params --- huma.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/huma.go b/huma.go index d4952c8b..884a0390 100644 --- a/huma.go +++ b/huma.go @@ -97,6 +97,7 @@ 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 @@ -104,6 +105,10 @@ func findParams(registry Registry, op *Operation, t reflect.Type) *findResult[*p } 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 @@ -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,