@@ -3,17 +3,17 @@ package {{packageName}}
33
44{ {#operations} }
55import (
6- "context"
7- "io/ioutil"
8- "net/http"
9- "net/url"
6+ _context "context"
7+ _ioutil "io/ioutil"
8+ _nethttp "net/http"
9+ _neturl "net/url"
1010{ {#imports} } "{ {import} }"
1111{ {/imports} }
1212)
1313
1414// Linger please
1515var (
16- _ context .Context
16+ _ _context .Context
1717)
1818
1919type { {classname} }Service service
@@ -24,7 +24,7 @@ type {{classname}}Service service
2424{ {#notes} }
2525{ {notes} }
2626{ {/notes} }
27- * @param ctx context .Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
27+ * @param ctx _context .Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
2828{ {#allParams} }
2929{ {#required} }
3030 * @param { {paramName} }{ {#description} } { {{.} }}{ {/description} }
@@ -63,9 +63,9 @@ type {{{nickname}}}Opts struct {
6363}
6464
6565{ {/hasOptionalParams} }
66- func (a *{ {{classname} }}Service) { {{nickname} }}(ctx context .Context{ {#hasParams} }, { {/hasParams} }{ {#allParams} }{ {#required} }{ {paramName} } { {{dataType} }}{ {#hasMore} }, { {/hasMore} }{ {/required} }{ {/allParams} }{ {#hasOptionalParams} }localVarOptionals *{ {{nickname} }}Opts{ {/hasOptionalParams} }) ({ {#returnType} }{ {{returnType} }}, { {/returnType} }*http .Response, error) {
66+ func (a *{ {{classname} }}Service) { {{nickname} }}(ctx _context .Context{ {#hasParams} }, { {/hasParams} }{ {#allParams} }{ {#required} }{ {paramName} } { {{dataType} }}{ {#hasMore} }, { {/hasMore} }{ {/required} }{ {/allParams} }{ {#hasOptionalParams} }localVarOptionals *{ {{nickname} }}Opts{ {/hasOptionalParams} }) ({ {#returnType} }{ {{returnType} }}, { {/returnType} }*_nethttp .Response, error) {
6767 var (
68- localVarHttpMethod = http .Method{{httpMethod} }
68+ localVarHttpMethod = _nethttp .Method{{httpMethod} }
6969 localVarPostBody interface{ }
7070 localVarFormFileName string
7171 localVarFileName string
@@ -77,11 +77,11 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
7777
7878 // create path and map variables
7979 localVarPath := a.client.cfg.BasePath + "{ {{path} }}"{ {#pathParams} }
80- localVarPath = strings.Replace(localVarPath, "{ " +" {{baseName} }"+"}", url .QueryEscape(fmt.Sprintf("%v", { {paramName} })), -1){ {/pathParams} }
80+ localVarPath = strings.Replace(localVarPath, "{ " +" {{baseName} }"+"}", _neturl .QueryEscape(fmt.Sprintf("%v", { {paramName} })), -1){ {/pathParams} }
8181
8282 localVarHeaderParams := make(map[string]string)
83- localVarQueryParams := url .Values{ }
84- localVarFormParams := url .Values{ }
83+ localVarQueryParams := _neturl .Values{ }
84+ localVarFormParams := _neturl .Values{ }
8585 { {#allParams} }
8686 { {#required} }
8787 { {#minItems} }
@@ -132,11 +132,37 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
132132 { {#hasQueryParams} }
133133 { {#queryParams} }
134134 { {#required} }
135+ { {#isCollectionFormatMulti} }
136+ t:={ {paramName} }
137+ if reflect.TypeOf(t).Kind() == reflect.Slice {
138+ s := reflect.ValueOf(t)
139+ for i := 0; i < s.Len(); i++ {
140+ localVarQueryParams.Add(" {{baseName}}" , parameterToString(s.Index(i), " {{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}" ))
141+ }
142+ } else {
143+ localVarQueryParams.Add(" {{baseName}}" , parameterToString(t, " {{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}" ))
144+ }
145+ { {/isCollectionFormatMulti} }
146+ { {^isCollectionFormatMulti} }
135147 localVarQueryParams.Add("{ {baseName} }", parameterToString({ {paramName} }, "{ {#collectionFormat} }{ {collectionFormat} }{ {/collectionFormat} }"))
148+ { {/isCollectionFormatMulti} }
136149 { {/required} }
137150 { {^required} }
138151 if localVarOptionals != nil && localVarOptionals.{ {vendorExtensions.x-exportParamName} }.IsSet() {
152+ {{#isCollectionFormatMulti} }
153+ t:=localVarOptionals.{ {vendorExtensions.x-exportParamName} }.Value()
154+ if reflect.TypeOf(t).Kind() == reflect.Slice {
155+ s := reflect.ValueOf(t)
156+ for i := 0; i < s.Len(); i++ {
157+ localVarQueryParams.Add(" {{baseName}}" , parameterToString(s.Index(i), " {{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}" ))
158+ }
159+ } else {
160+ localVarQueryParams.Add(" {{baseName}}" , parameterToString(t, " {{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}" ))
161+ }
162+ { {/isCollectionFormatMulti} }
163+ { {^isCollectionFormatMulti} }
139164 localVarQueryParams.Add("{ {baseName} }", parameterToString(localVarOptionals.{ {vendorExtensions.x-exportParamName} }.Value(), "{ {#collectionFormat} }{ {collectionFormat} }{ {/collectionFormat} }"))
165+ { {/isCollectionFormatMulti} }
140166 }
141167 { {/required} }
142168 { {/queryParams} }
@@ -192,7 +218,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
192218 }
193219{ {/required} }
194220 if localVarFile != nil {
195- fbs, _ := ioutil .ReadAll(localVarFile)
221+ fbs, _ := _ioutil .ReadAll(localVarFile)
196222 localVarFileBytes = fbs
197223 localVarFileName = localVarFile.Name()
198224 localVarFile.Close()
@@ -277,7 +303,7 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
277303 return {{#returnType} }localVarReturnValue, { {/returnType} }localVarHttpResponse, err
278304 }
279305
280- localVarBody, err := ioutil .ReadAll(localVarHttpResponse.Body)
306+ localVarBody, err := _ioutil .ReadAll(localVarHttpResponse.Body)
281307 localVarHttpResponse.Body.Close()
282308 if err != nil {
283309 return {{#returnType} }localVarReturnValue, { {/returnType} }localVarHttpResponse, err
0 commit comments