Skip to content

Commit 3058cb7

Browse files
committed
Fix nits from code review.
* Use go template consistently. * Clean up braces and whitespace in templates. * Rename template files. h/t @lgfa29
1 parent 0de1b68 commit 3058cb7

15 files changed

Lines changed: 76 additions & 102 deletions

internal/generate/paths.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,27 +315,27 @@ func writeTpl(f *os.File, config methodTemplate) error {
315315
var err error
316316

317317
if config.IsListAll {
318-
t, err = template.ParseFiles("./templates/listall_method.tpl", "./templates/description.tpl")
318+
t, err = template.ParseFiles("./templates/listall_method.go.tpl", "./templates/description.go.tpl")
319319
if err != nil {
320320
return err
321321
}
322322
} else if config.ResponseType == "" && config.HasBody {
323-
t, err = template.ParseFiles("./templates/no_resptype_body_method.tpl", "./templates/description.tpl")
323+
t, err = template.ParseFiles("./templates/no_resptype_body_method.go.tpl", "./templates/description.go.tpl")
324324
if err != nil {
325325
return err
326326
}
327327
} else if config.ResponseType == "" {
328-
t, err = template.ParseFiles("./templates/no_resptype_method.tpl", "./templates/description.tpl")
328+
t, err = template.ParseFiles("./templates/no_resptype_method.go.tpl", "./templates/description.go.tpl")
329329
if err != nil {
330330
return err
331331
}
332332
} else if config.HasBody {
333-
t, err = template.ParseFiles("./templates/resptype_body_method.tpl", "./templates/description.tpl")
333+
t, err = template.ParseFiles("./templates/resptype_body_method.go.tpl", "./templates/description.go.tpl")
334334
if err != nil {
335335
return err
336336
}
337337
} else {
338-
t, err = template.ParseFiles("./templates/resptype_method.tpl", "./templates/description.tpl")
338+
t, err = template.ParseFiles("./templates/resptype_method.go.tpl", "./templates/description.go.tpl")
339339
if err != nil {
340340
return err
341341
}
File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{splitDocString .Description}}
2+
{{.ValueType}} {{.Name}} {{.Value}}
3+
File renamed without changes.

internal/generate/templates/no_resptype_body_method.tpl renamed to internal/generate/templates/no_resptype_body_method.go.tpl

File renamed without changes.
File renamed without changes.

internal/generate/templates/resptype_body_method.tpl renamed to internal/generate/templates/resptype_body_method.go.tpl

File renamed without changes.
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{splitDocString .Description}}
2+
{{- if .Fields}}
3+
type {{.Name}} {{.Type}} {
4+
{{- range .Fields}}
5+
{{- if .Description}}
6+
{{splitDocString .Description}}
7+
{{- end}}
8+
{{.Name}} {{.Type}} {{.SerializationInfo}}
9+
{{- end}}
10+
}
11+
12+
{{else}}
13+
type {{.Name}} {{.Type}}
14+
{{end -}}

internal/generate/templates/type.tpl

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)