Skip to content

Commit

Permalink
Merge 9b48af5 into fc98106
Browse files Browse the repository at this point in the history
  • Loading branch information
argouber committed Oct 28, 2019
2 parents fc98106 + 9b48af5 commit 59af19c
Show file tree
Hide file tree
Showing 16 changed files with 3,100 additions and 4,956 deletions.
17 changes: 15 additions & 2 deletions codegen/method.go
Expand Up @@ -1262,6 +1262,17 @@ func (ms *MethodSpec) setWriteQueryParamStatements(
return nil
}

// makeUniqIdent appends an integer to the identifier name if there is duplication already
// The reason for this is to disambiguate a query param "deviceID" from "device_ID" - yes people did do that
func makeUniqIdent(identifier string, seen map[string]int) string {
count := seen[identifier]
seen[identifier] = count + 1
if count > 0 {
return identifier + strconv.Itoa(count)
}
return identifier
}

func (ms *MethodSpec) setParseQueryParamStatements(
funcSpec *compile.FunctionSpec, packageHelper *PackageHelper, hasNoBody bool,
) error {
Expand All @@ -1271,6 +1282,7 @@ func (ms *MethodSpec) setParseQueryParamStatements(

var finalError error
var stack = []string{}
seenIdents := map[string]int{}

visitor := func(
goPrefix string, thriftPrefix string, field *compile.FieldSpec,
Expand Down Expand Up @@ -1356,9 +1368,10 @@ func (ms *MethodSpec) setParseQueryParamStatements(

return false
}
identifierName := CamelCase(longQueryName) + "Query"
baseIdent := makeUniqIdent(CamelCase(longQueryName), seenIdents)
identifierName := baseIdent + "Query"
okIdentifierName := baseIdent + "Ok"

okIdentifierName := CamelCase(longQueryName) + "Ok"
if field.Required {
statements.appendf("%s := req.CheckQueryValue(%q)",
okIdentifierName, shortQueryParam,
Expand Down
271 changes: 124 additions & 147 deletions examples/example-gateway/build/clients/bar/bar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 59af19c

Please sign in to comment.