Skip to content

Commit 856d281

Browse files
authored
Fix uppercase method input/return arguments in server code too (#23)
Follow up for #22. This change matches the TypeScript generator: https://github.com/webrpc/gen-typescript/blob/master/types.go.tmpl#L51-L63 Given the following schema: service ExampleService - GetUser(UserID: uint64) => (USER: User) The golang generator wrongly generated "userID" and "uSER" arguments over JSON.
1 parent 895ed7b commit 856d281

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

server.go.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (s *{{$serviceName}}) serve{{ .Name | firstLetterToUpper }}JSON(ctx context
7272
{{- if .Inputs|len}}
7373
reqContent := struct {
7474
{{- range $i, $input := .Inputs}}
75-
Arg{{$i}} {{template "type" dict "Type" $input.Type "Optional" $input.Optional "TypeMap" $typeMap "TypePrefix" $typePrefix}} `json:"{{firstLetterToLower $input.Name}}"`
75+
Arg{{$i}} {{template "type" dict "Type" $input.Type "Optional" $input.Optional "TypeMap" $typeMap "TypePrefix" $typePrefix}} `json:"{{$input.Name}}"`
7676
{{- end}}
7777
}{}
7878

@@ -109,7 +109,7 @@ func (s *{{$serviceName}}) serve{{ .Name | firstLetterToUpper }}JSON(ctx context
109109
{{- if .Outputs | len}}
110110
respContent := struct {
111111
{{- range $i, $output := .Outputs}}
112-
Ret{{$i}} {{template "type" dict "Type" $output.Type "Optional" $output.Optional "TypeMap" $typeMap "TypePrefix" $typePrefix}} `json:"{{firstLetterToLower $output.Name}}"`
112+
Ret{{$i}} {{template "type" dict "Type" $output.Type "Optional" $output.Optional "TypeMap" $typeMap "TypePrefix" $typePrefix}} `json:"{{$output.Name}}"`
113113
{{- end}}
114114
}{ {{- range $i, $_ := .Outputs}}{{if gt $i 0}}, {{end}}ret{{$i}}{{end}}}
115115
{{- end}}

0 commit comments

Comments
 (0)