forked from loafle/openapi-generator-original
updated api_client.go to use the new SetMultiValueQueryParams method
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
"net/url"
|
||||
{{#imports}}"{{import}}"
|
||||
{{/imports}}
|
||||
)
|
||||
@@ -50,7 +51,7 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
|
||||
}{{/required}}{{/allParams}}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
queryParams := url.Values{}
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
@@ -82,14 +83,14 @@ func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{
|
||||
var collectionFormat = "{{#collectionFormat}}{{collectionFormat}}{{/collectionFormat}}"
|
||||
if collectionFormat == "multi" {
|
||||
for _, value := range {{paramName}} {
|
||||
queryParams["{{paramName}}"] = value
|
||||
queryParams.Add("{{paramName}}", value)
|
||||
}
|
||||
} else {
|
||||
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
|
||||
queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}))
|
||||
}
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
|
||||
queryParams.Add("{{paramName}}", a.Configuration.APIClient.ParameterToString({{paramName}}))
|
||||
{{/isListContainer}}
|
||||
{{/queryParams}}{{/hasQueryParams}}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"net/url"
|
||||
"github.com/go-resty/resty"
|
||||
)
|
||||
|
||||
@@ -47,7 +47,7 @@ func contains(source []string, containvalue string) bool {
|
||||
func (c *APIClient) CallAPI(path string, method string,
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) (*resty.Response, error) {
|
||||
@@ -89,7 +89,7 @@ func (c *APIClient) ParameterToString(obj interface{}) string {
|
||||
|
||||
func prepareRequest(postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) *resty.Request {
|
||||
@@ -104,7 +104,7 @@ func prepareRequest(postBody interface{},
|
||||
|
||||
// add query parameter, if any
|
||||
if len(queryParams) > 0 {
|
||||
request.SetQueryParams(queryParams)
|
||||
request.SetMultiValueQueryParams(queryParams)
|
||||
}
|
||||
|
||||
// add form parameter, if any
|
||||
|
||||
Reference in New Issue
Block a user