Skip to content

Commit

Permalink
helpers: use JsonName as fallback in urlHasVarsFromMessage
Browse files Browse the repository at this point in the history
The JsonName value could be used as fallback when checking
whether field is used as url parameter.
  • Loading branch information
mgenov committed Jan 4, 2021
1 parent f4bcee5 commit c67c233
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,13 @@ func urlHasVarsFromMessage(path string, d *ggdescriptor.Message) bool {
if strings.Contains(path, fmt.Sprintf("{%s}", *field.Name)) {
return true
}
// JSON name field is checked as fallback. The value set by the protocol compiler.
// If the user has set a "json_name" option on a field, that option's value
// will be used in this check. By default value in this property will be field name in
// camelCase format.
if strings.Contains(path, fmt.Sprintf("{%s}", *field.JsonName)) {
return true
}
}
}

Expand Down

0 comments on commit c67c233

Please sign in to comment.