diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 5bebf932851..8b7c3d7252a 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -134,6 +134,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "configuration.go")); + supportingFiles.add(new SupportingFile("api_client.mustache", packageName, "api_client.go")); } @Override diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 233afa8ad89..f08ba380ec0 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -86,11 +86,29 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{ } _sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{vendorExtensions.x-exportParamName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} }) {{/hasQueryParams}} - // accept header - accepts := []string { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + {{#consumes}} + "{{mediaType}}", + {{/consumes}} + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + {{#produces}} + "{{mediaType}}", + {{/produces}} + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } {{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" _sling = _sling.Set("{{baseName}}", {{paramName}}) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache new file mode 100644 index 00000000000..06470ba06d6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -0,0 +1,41 @@ +package {{packageName}} + +import ( + "strings" +) + +type ApiClient struct { + +} + +func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { + if (len(contentTypes) == 0){ + return "" + } + if contains(contentTypes,"application/json") { + return "application/json" + } + + return contentTypes[0] // use the first content type specified in 'consumes' +} + +func (c *ApiClient) SelectHeaderAccept(accepts []string) string { + if (len(accepts) == 0){ + return "" + } + + if contains(accepts,"application/json"){ + return "application/json" + } + + return strings.Join(accepts,",") +} + +func contains(source []string, containvalue string) bool { + for _, a := range source { + if strings.ToLower(a) == strings.ToLower(containvalue) { + return true + } + } + return false +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index 301f46d8fd4..154ceb9ffc6 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -19,6 +19,7 @@ type Configuration struct { AccessToken string `json:"accessToken,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` + ApiClient ApiClient `json:"apiClient,omitempty"` } func NewConfiguration() *Configuration { diff --git a/samples/client/petstore/go/swagger/api_client.go b/samples/client/petstore/go/swagger/api_client.go new file mode 100644 index 00000000000..9806ccdf38d --- /dev/null +++ b/samples/client/petstore/go/swagger/api_client.go @@ -0,0 +1,41 @@ +package swagger + +import ( + "strings" +) + +type ApiClient struct { + +} + +func (c *ApiClient) SelectHeaderContentType(contentTypes []string) string { + if (len(contentTypes) == 0){ + return "" + } + if contains(contentTypes,"application/json") { + return "application/json" + } + + return contentTypes[0] // use the first content type specified in 'consumes' +} + +func (c *ApiClient) SelectHeaderAccept(accepts []string) string { + if (len(accepts) == 0){ + return "" + } + + if contains(accepts,"application/json"){ + return "application/json" + } + + return strings.Join(accepts,",") +} + +func contains(source []string, containvalue string) bool { + for _, a := range source { + if strings.ToLower(a) == strings.ToLower(containvalue) { + return true + } + } + return false +} \ No newline at end of file diff --git a/samples/client/petstore/go/swagger/configuration.go b/samples/client/petstore/go/swagger/configuration.go index b231bd8aa48..e8a00bccaf5 100644 --- a/samples/client/petstore/go/swagger/configuration.go +++ b/samples/client/petstore/go/swagger/configuration.go @@ -19,6 +19,7 @@ type Configuration struct { AccessToken string `json:"accessToken,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` + ApiClient ApiClient `json:"apiClient,omitempty"` } func NewConfiguration() *Configuration { diff --git a/samples/client/petstore/go/swagger/pet_api.go b/samples/client/petstore/go/swagger/pet_api.go index 2b73357eb06..cdaed35ce12 100644 --- a/samples/client/petstore/go/swagger/pet_api.go +++ b/samples/client/petstore/go/swagger/pet_api.go @@ -56,11 +56,27 @@ func (a PetApi) AddPet (body Pet) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/json", + "application/xml", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params @@ -129,11 +145,25 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // header params "api_key" _sling = _sling.Set("api_key", apiKey) @@ -204,11 +234,25 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { Status []string `url:"status,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{ Status: status }) - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -277,11 +321,25 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { Tags []string `url:"tags,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{ Tags: tags }) - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -346,11 +404,25 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -415,11 +487,27 @@ func (a PetApi) UpdatePet (body Pet) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/json", + "application/xml", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params @@ -489,11 +577,26 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "application/x-www-form-urlencoded", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } type FormParams struct { @@ -566,11 +669,25 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + "multipart/form-data", + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } type FormParams struct { diff --git a/samples/client/petstore/go/swagger/store_api.go b/samples/client/petstore/go/swagger/store_api.go index 9f420ea6d7a..3fe6f3f8f2b 100644 --- a/samples/client/petstore/go/swagger/store_api.go +++ b/samples/client/petstore/go/swagger/store_api.go @@ -50,11 +50,25 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -117,11 +131,24 @@ func (a StoreApi) GetInventory () (map[string]int32, error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -181,11 +208,25 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -244,11 +285,25 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params diff --git a/samples/client/petstore/go/swagger/user_api.go b/samples/client/petstore/go/swagger/user_api.go index 655e8b46fe9..ca95f8042fc 100644 --- a/samples/client/petstore/go/swagger/user_api.go +++ b/samples/client/petstore/go/swagger/user_api.go @@ -49,11 +49,25 @@ func (a UserApi) CreateUser (body User) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params @@ -114,11 +128,25 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params @@ -179,11 +207,25 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params @@ -245,11 +287,25 @@ func (a UserApi) DeleteUser (username string) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -309,11 +365,25 @@ func (a UserApi) GetUserByName (username string) (User, error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -378,11 +448,25 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { Password string `url:"password,omitempty"` } _sling = _sling.QueryStruct(&QueryParams{ Username: username,Password: password }) - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -440,11 +524,25 @@ func (a UserApi) LogoutUser () (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } @@ -505,11 +603,25 @@ func (a UserApi) UpdateUser (username string, body User) (error) { _sling = _sling.Set(key, a.Configuration.DefaultHeader[key]) } - // accept header - accepts := []string { "application/xml", "application/json" } - for key := range accepts { - _sling = _sling.Set("Accept", accepts[key]) - break // only use the first Accept + + // to determine the Content-Type header + localVarHttpContentTypes := []string { + } + //set Content-Type header + localVarHttpContentType := a.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + _sling = _sling.Set("Content-Type", localVarHttpContentType) + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string { + "application/xml", + "application/json", + } + //set Accept header + localVarHttpHeaderAccept := a.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + _sling = _sling.Set("Accept", localVarHttpHeaderAccept) } // body params