@@ -34,6 +34,8 @@ func NewSimple{{ .Prefix }}Initiator(opts ...{{ .Prefix }}InitiatorOption) (*Sim
3434{{- $opid := .GoOperationID }}
3535{{- $hasParams := .HasParams }}
3636{{- $paramsTypeName := .ParamsTypeName }}
37+ {{- $prefix := $ .Prefix }}
38+ {{- $prefixLower := $ .PrefixLower }}
3739
3840{{- /* Determine if this operation is "simple" - single success content type, single JSON success response */ }}
3941{{- $simpleOp := isSimpleOperation . }}
@@ -43,19 +45,19 @@ func NewSimple{{ .Prefix }}Initiator(opts ...{{ .Prefix }}InitiatorOption) (*Sim
4345{{- $successType := goTypeForContent $successContent }}
4446{{- $errorResponse := errorResponseForOperation . }}
4547
46- // {{ $opid }} sends a {{ .Method }} {{ $ .PrefixLower }} request and returns the parsed response.
48+ // {{ $opid }} sends a {{ .Method }} {{ $prefixLower }} request and returns the parsed response.
4749{{ if .Summary }}// {{ .Summary }}{{ end }}
4850{{- if $errorResponse }}
4951{{- $errorContent := index $errorResponse .Contents 0 }}
5052{{- $errorType := goTypeForContent $errorContent }}
51- // On success, returns the response body. On HTTP error, returns *{{ $ .Prefix }}HttpError[{{ $errorType }}].
52- func (p *Simple{{ $ .Prefix }}Initiator) {{ $opid }}(ctx context.Context , targetURL string{{ if $hasParams }}, params *{{ $paramsTypeName }}{{ end }}{{ if .HasBody }}, body {{ (index .Bodies 0).GoTypeName }}{{ end }}, reqEditors ...RequestEditorFn ) ({{ $successType }}, error) {
53+ // On success, returns the response body. On HTTP error, returns *{{ $prefix }}HttpError[{{ $errorType }}].
54+ func (p *Simple{{ $prefix }}Initiator) {{ $opid }}(ctx context.Context , targetURL string{{ if $hasParams }}, params *{{ $paramsTypeName }}{{ end }}{{ if .HasBody }}, body {{ (index .Bodies 0).GoTypeName }}{{ end }}, reqEditors ...RequestEditorFn ) ({{ $successType }}, error) {
5355 var result {{ $successType }}
5456{{- if .HasBody }}
5557{{- $defaultBody := index .Bodies 0 }}
56- resp, err := p. {{ $ .Prefix }}Initiator. {{ $opid }}{{ $defaultBody .FuncSuffix }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, body, reqEditors... )
58+ resp, err := p. {{ $prefix }}Initiator. {{ $opid }}{{ $defaultBody .FuncSuffix }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, body, reqEditors... )
5759{{- else }}
58- resp, err := p. {{ $ .Prefix }}Initiator. {{ $opid }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, reqEditors... )
60+ resp, err := p. {{ $prefix }}Initiator. {{ $opid }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, reqEditors... )
5961{{- end }}
6062 if err != nil {
6163 return result, err
@@ -77,21 +79,21 @@ func (p *Simple{{ $.Prefix }}Initiator) {{ $opid }}(ctx context.Context, targetU
7779 // Parse error response
7880 var errBody {{ $errorType }}
7981 _ = json.Unmarshal (rawBody, &errBody) // Best effort parse
80- return result, &{{ $ .Prefix }}HttpError[{{ $errorType }}]{
82+ return result, &{{ $prefix }}HttpError[{{ $errorType }}]{
8183 StatusCode: resp.StatusCode ,
8284 Body: errBody,
8385 RawBody: rawBody,
8486 }
8587}
8688{{- else }}
87- // On success, returns the response body. On HTTP error, returns *{{ $ .Prefix }}HttpError[struct{}].
88- func (p *Simple{{ $ .Prefix }}Initiator) {{ $opid }}(ctx context.Context , targetURL string{{ if $hasParams }}, params *{{ $paramsTypeName }}{{ end }}{{ if .HasBody }}, body {{ (index .Bodies 0).GoTypeName }}{{ end }}, reqEditors ...RequestEditorFn ) ({{ $successType }}, error) {
89+ // On success, returns the response body. On HTTP error, returns *{{ $prefix }}HttpError[struct{}].
90+ func (p *Simple{{ $prefix }}Initiator) {{ $opid }}(ctx context.Context , targetURL string{{ if $hasParams }}, params *{{ $paramsTypeName }}{{ end }}{{ if .HasBody }}, body {{ (index .Bodies 0).GoTypeName }}{{ end }}, reqEditors ...RequestEditorFn ) ({{ $successType }}, error) {
8991 var result {{ $successType }}
9092{{- if .HasBody }}
9193{{- $defaultBody := index .Bodies 0 }}
92- resp, err := p. {{ $ .Prefix }}Initiator. {{ $opid }}{{ $defaultBody .FuncSuffix }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, body, reqEditors... )
94+ resp, err := p. {{ $prefix }}Initiator. {{ $opid }}{{ $defaultBody .FuncSuffix }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, body, reqEditors... )
9395{{- else }}
94- resp, err := p. {{ $ .Prefix }}Initiator. {{ $opid }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, reqEditors... )
96+ resp, err := p. {{ $prefix }}Initiator. {{ $opid }}(ctx, targetURL{{ if $hasParams }}, params{{ end }}, reqEditors... )
9597{{- end }}
9698 if err != nil {
9799 return result, err
@@ -111,7 +113,7 @@ func (p *Simple{{ $.Prefix }}Initiator) {{ $opid }}(ctx context.Context, targetU
111113 }
112114
113115 // No typed error response defined
114- return result, &{{ $ .Prefix }}HttpError[struct{}]{
116+ return result, &{{ $prefix }}HttpError[struct{}]{
115117 StatusCode: resp.StatusCode ,
116118 RawBody: rawBody,
117119 }
0 commit comments