issue#2534, added _sling.Set in the go api

This commit is contained in:
Guo Huang 2016-04-11 10:37:50 -07:00
parent 963df24eee
commit ae3c628875
4 changed files with 105 additions and 0 deletions

View File

@ -50,6 +50,11 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
{{#hasQueryParams}} type QueryParams struct { {{#hasQueryParams}} type QueryParams struct {
{{#queryParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"` {{#queryParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
{{/queryParams}} {{/queryParams}}

View File

@ -45,6 +45,11 @@ func (a PetApi) AddPet (body Pet) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -107,6 +112,11 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -167,6 +177,11 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
type QueryParams struct { type QueryParams struct {
status []string `url:"status,omitempty"` status []string `url:"status,omitempty"`
} }
@ -229,6 +244,11 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
type QueryParams struct { type QueryParams struct {
tags []string `url:"tags,omitempty"` tags []string `url:"tags,omitempty"`
} }
@ -292,6 +312,11 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -350,6 +375,11 @@ func (a PetApi) UpdatePet (body Pet) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -413,6 +443,11 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (err
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -479,6 +514,11 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/json" } accepts := []string { "application/json" }
for key := range accepts { for key := range accepts {

View File

@ -45,6 +45,11 @@ func (a StoreApi) DeleteOrder (orderId string) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -102,6 +107,11 @@ func (a StoreApi) GetInventory () (map[string]int32, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/json" } accepts := []string { "application/json" }
for key := range accepts { for key := range accepts {
@ -161,6 +171,11 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -219,6 +234,11 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {

View File

@ -44,6 +44,11 @@ func (a UserApi) CreateUser (body User) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -104,6 +109,11 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -164,6 +174,11 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -225,6 +240,11 @@ func (a UserApi) DeleteUser (username string) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -284,6 +304,11 @@ func (a UserApi) GetUserByName (username string) (User, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -343,6 +368,11 @@ func (a UserApi) LoginUser (username string, password string) (string, error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
type QueryParams struct { type QueryParams struct {
username string `url:"username,omitempty"` username string `url:"username,omitempty"`
password string `url:"password,omitempty"` password string `url:"password,omitempty"`
@ -405,6 +435,11 @@ func (a UserApi) LogoutUser () (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {
@ -465,6 +500,11 @@ func (a UserApi) UpdateUser (username string, body User) (error) {
_sling = _sling.Path(path) _sling = _sling.Path(path)
// add default headers if any
for key := range a.Configuration.DefaultHeader {
_sling = _sling.Set(key, a.Configuration.DefaultHeader[key])
}
// accept header // accept header
accepts := []string { "application/xml", "application/json" } accepts := []string { "application/xml", "application/json" }
for key := range accepts { for key := range accepts {