Skip to content

Commit

Permalink
fix Do method without parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 29, 2021
1 parent d3ed7be commit 75deb72
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/requestgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,16 @@ func ({{- .ReceiverName }} * {{- typeString .StructType -}}) Do(ctx context.Cont
{{ $requestMethod = "NewAuthenticatedRequest" }}
{{- end -}}
{{- if ne .ApiMethod "GET" }}
{{- if not .HasParameters }}
// no body params
var params interface{}
{{- else if and .HasParameters (ne .ApiMethod "GET") }}
params, err := {{ $recv }}.GetParameters()
if err != nil {
return nil, err
}
{{- else }}
// empty params for GET operation
// empty params for GET operation
var params interface{}
{{- end }}
Expand Down Expand Up @@ -566,6 +569,7 @@ func ({{- .ReceiverName }} * {{- typeString .StructType -}}) Do(ctx context.Cont
ApiAuthenticated bool
ResponseType, ResponseDataType types.Type
ResponseDataField string
HasParameters bool
HasQueryParameters bool
}{
StructType: g.structType,
Expand All @@ -577,6 +581,7 @@ func ({{- .ReceiverName }} * {{- typeString .StructType -}}) Do(ctx context.Cont
ResponseType: g.responseType,
ResponseDataType: g.responseDataType,
ResponseDataField: *responseDataField,
HasParameters: len(g.fields) > 0,
HasQueryParameters: len(g.queryFields) > 0,
})

Expand Down

0 comments on commit 75deb72

Please sign in to comment.