From c7a906c8ac02fce7f0b6b59d21b91be893a68c66 Mon Sep 17 00:00:00 2001 From: Murad Biashimov Date: Fri, 13 Dec 2024 16:08:59 +0100 Subject: [PATCH] fix: do not stringify string query params --- generator/main.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/generator/main.go b/generator/main.go index ef5c388..3c4d287 100644 --- a/generator/main.go +++ b/generator/main.go @@ -662,12 +662,16 @@ func fmtQueryParam(funcName, queryParamType string, p *Parameter) (*jen.Statemen keyFuncName := funcName + p.Schema.CamelName keyVarName := jen.Id(p.Schema.lowerCamel()) - var value *jen.Statement format, ok := strFormatters[p.Schema.Type] if !ok { return nil, fmt.Errorf("query param with type %q is not supported", p.Schema.Type) } - value = jen.Qual("fmt", "Sprintf").Call(jen.Lit(format), keyVarName.Clone()) + + // Stringifies non-string values and enums + value := keyVarName.Clone() + if p.Schema.isEnum() || p.Schema.Type != SchemaTypeString { + value = jen.Qual("fmt", "Sprintf").Call(jen.Lit(format), keyVarName.Clone()) + } param := jen.Comment(fmt.Sprintf("%s %s", keyFuncName, fmtComment(p.Description))) param.Line()