Skip to content

Commit

Permalink
fix: do not stringify string query params
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Dec 13, 2024
1 parent 8ba8ca8 commit c7a906c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c7a906c

Please sign in to comment.