forked from loafle/openapi-generator-original
added ParameterToString method to handle string array issue
This commit is contained in:
parent
af19a70f72
commit
2fcda964ad
@ -92,7 +92,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
|
|||||||
|
|
||||||
{{#hasQueryParams}}
|
{{#hasQueryParams}}
|
||||||
{{#queryParams}}
|
{{#queryParams}}
|
||||||
queryParams["{{vendorExtensions.x-exportParamName}}"] = strings.Join({{paramName}}, ",")
|
queryParams["{{vendorExtensions.x-exportParamName}}"] = a.Configuration.ApiClient.ParameterToString({{paramName}})
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
{{/hasQueryParams}}
|
{{/hasQueryParams}}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"github.com/go-resty/resty"
|
"github.com/go-resty/resty"
|
||||||
"errors"
|
"errors"
|
||||||
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApiClient struct {
|
type ApiClient struct {
|
||||||
@ -73,6 +74,14 @@ func (c *ApiClient) CallApi(path string, method string,
|
|||||||
return nil, errors.New("Invalid method " + method)
|
return nil, errors.New("Invalid method " + method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ApiClient) ParameterToString (obj interface{}) string {
|
||||||
|
if reflect.TypeOf(obj).Len() > 0 {
|
||||||
|
return strings.Join(obj.([]string), ",")
|
||||||
|
} else{
|
||||||
|
return obj.(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func prepareRequest(postBody interface{},
|
func prepareRequest(postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"github.com/go-resty/resty"
|
"github.com/go-resty/resty"
|
||||||
"errors"
|
"errors"
|
||||||
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApiClient struct {
|
type ApiClient struct {
|
||||||
@ -73,6 +74,14 @@ func (c *ApiClient) CallApi(path string, method string,
|
|||||||
return nil, errors.New("Invalid method " + method)
|
return nil, errors.New("Invalid method " + method)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ApiClient) ParameterToString (obj interface{}) string {
|
||||||
|
if reflect.TypeOf(obj).Len() > 0 {
|
||||||
|
return strings.Join(obj.([]string), ",")
|
||||||
|
} else{
|
||||||
|
return obj.(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func prepareRequest(postBody interface{},
|
func prepareRequest(postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
|
@ -207,7 +207,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) {
|
|||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
queryParams["Status"] = strings.Join(status, ",")
|
queryParams["Status"] = a.Configuration.ApiClient.ParameterToString(status)
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string {
|
||||||
@ -277,7 +277,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) {
|
|||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
queryParams["Tags"] = strings.Join(tags, ",")
|
queryParams["Tags"] = a.Configuration.ApiClient.ParameterToString(tags)
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string {
|
||||||
@ -585,7 +585,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
formParams["AdditionalMetadata"] = additionalMetadata
|
formParams["AdditionalMetadata"] = additionalMetadata
|
||||||
formParams["File"] = file
|
formParams["File"] = file.Name()
|
||||||
|
|
||||||
var successPayload = new(ApiResponse)
|
var successPayload = new(ApiResponse)
|
||||||
|
|
||||||
|
@ -380,8 +380,8 @@ func (a UserApi) LoginUser (username string, password string) (string, error) {
|
|||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
queryParams["Username"] = strings.Join(username, ",")
|
queryParams["Username"] = a.Configuration.ApiClient.ParameterToString(username)
|
||||||
queryParams["Password"] = strings.Join(password, ",")
|
queryParams["Password"] = a.Configuration.ApiClient.ParameterToString(password)
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user