From 316c2cb136e02ae325572f987f469fe2ac8cbfd0 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Thu, 7 Apr 2016 22:16:31 -0700 Subject: [PATCH 1/2] added Configuration struct for GO --- .../codegen/languages/GoClientCodegen.java | 1 + .../src/main/resources/go/api.mustache | 12 ++++++--- .../main/resources/go/configuration.mustache | 25 +++++++++++++++++++ .../petstore/go/swagger/Configuration.go | 25 +++++++++++++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/go/configuration.mustache create mode 100644 samples/client/petstore/go/swagger/Configuration.go 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 007b3a8f36b8..234bda9adb78 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 @@ -131,6 +131,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); 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")); } @Override diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 49b7f92693e3..d1cf877cd439 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -12,18 +12,22 @@ import ( ) type {{classname}} struct { - basePath string + Configuration Configuration } func New{{classname}}() *{{classname}}{ + configuration := NewConfiguration() return &{{classname}} { - basePath: "{{basePath}}", + Configuration: *configuration, } } func New{{classname}}WithBasePath(basePath string) *{{classname}}{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &{{classname}} { - basePath: basePath, + Configuration: *configuration, } } @@ -37,7 +41,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ //func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - _sling := sling.New().{{httpMethod}}(a.basePath) + _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) // create path and map variables path := "{{basePathWithoutHost}}{{path}}" diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache new file mode 100644 index 000000000000..bf3a8f92bed0 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -0,0 +1,25 @@ +package {{packageName}} + +import ( + +) + +type Configuration struct { + UserName string `json:"userName,omitempty"` + ApiKey string `json:"apiKey,omitempty"` + Debug bool `json:"debug,omitempty"` + DebugFile string `json:"debugFile,omitempty"` + OAuthToken string `json:"oAuthToken,omitempty"` + Timeout int `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` +} + +func NewConfiguration() *Configuration { + return &Configuration{ + BasePath: "{{basePath}}", + UserName: "", + Debug: 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 new file mode 100644 index 000000000000..7535db5e67f6 --- /dev/null +++ b/samples/client/petstore/go/swagger/Configuration.go @@ -0,0 +1,25 @@ +package swagger + +import ( + +) + +type Configuration struct { + UserName string `json:"userName,omitempty"` + ApiKey string `json:"apiKey,omitempty"` + Debug bool `json:"debug,omitempty"` + DebugFile string `json:"debugFile,omitempty"` + OAuthToken string `json:"oAuthToken,omitempty"` + Timeout int `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` +} + +func NewConfiguration() *Configuration { + return &Configuration{ + BasePath: "http://petstore.swagger.io/v2", + UserName: "", + Debug: false, + } +} \ No newline at end of file From 9cae125b2c1d472a9c1e46fc86a1420deb71db53 Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Thu, 7 Apr 2016 22:27:33 -0700 Subject: [PATCH 2/2] updated sample files --- samples/client/petstore/go/swagger/PetApi.go | 57 ++++++++++++++--- .../client/petstore/go/swagger/StoreApi.go | 32 ++++++++-- samples/client/petstore/go/swagger/UserApi.go | 62 +++++++++++++++---- 3 files changed, 124 insertions(+), 27 deletions(-) diff --git a/samples/client/petstore/go/swagger/PetApi.go b/samples/client/petstore/go/swagger/PetApi.go index c02195687294..80853fbb2a09 100644 --- a/samples/client/petstore/go/swagger/PetApi.go +++ b/samples/client/petstore/go/swagger/PetApi.go @@ -1,29 +1,36 @@ package swagger + import ( "strings" "fmt" "encoding/json" "errors" "github.com/dghubble/sling" + ) type PetApi struct { - basePath string + Configuration Configuration } func NewPetApi() *PetApi{ + configuration := NewConfiguration() return &PetApi { - basePath: "http://petstore.swagger.io/v2", + Configuration: *configuration, } } func NewPetApiWithBasePath(basePath string) *PetApi{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &PetApi { - basePath: basePath, + Configuration: *configuration, } } + /** * Add a new pet to the store * @@ -33,13 +40,15 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ //func (a PetApi) AddPet (body Pet) (error) { func (a PetApi) AddPet (body Pet) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/pets" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -47,6 +56,7 @@ func (a PetApi) AddPet (body Pet) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -84,6 +94,7 @@ func (a PetApi) AddPet (body Pet) (error) { return err } + /** * Deletes a pet * @@ -94,14 +105,16 @@ func (a PetApi) AddPet (body Pet) (error) { //func (a PetApi) DeletePet (apiKey string, petId int64) (error) { func (a PetApi) DeletePet (apiKey string, petId int64) (error) { - _sling := sling.New().Delete(a.basePath) + _sling := sling.New().Delete(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -114,6 +127,7 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -146,6 +160,7 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) { return err } + /** * Finds Pets by status * Multiple status values can be provided with comma seperated strings @@ -155,11 +170,12 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) { //func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/findByStatus" + _sling = _sling.Path(path) type QueryParams struct { @@ -167,6 +183,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { } _sling = _sling.QueryStruct(&QueryParams{ status: status }) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -175,6 +192,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { } + var successPayload = new([]Pet) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -209,6 +227,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { return *successPayload, err } + /** * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. @@ -218,11 +237,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { //func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/findByTags" + _sling = _sling.Path(path) type QueryParams struct { @@ -230,6 +250,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { } _sling = _sling.QueryStruct(&QueryParams{ tags: tags }) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -238,6 +259,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { } + var successPayload = new([]Pet) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -272,6 +294,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { return *successPayload, err } + /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -281,14 +304,16 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { //func (a PetApi) GetPetById (petId int64) (Pet, error) { func (a PetApi) GetPetById (petId int64) (Pet, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -297,6 +322,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { } + var successPayload = new(Pet) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -331,6 +357,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { return *successPayload, err } + /** * Update an existing pet * @@ -340,13 +367,15 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { //func (a PetApi) UpdatePet (body Pet) (error) { func (a PetApi) UpdatePet (body Pet) (error) { - _sling := sling.New().Put(a.basePath) + _sling := sling.New().Put(a.Configuration.BasePath) // create path and map variables path := "/v2/pets" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -354,6 +383,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -391,6 +421,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { return err } + /** * Updates a pet in the store with form data * @@ -402,14 +433,16 @@ func (a PetApi) UpdatePet (body Pet) (error) { //func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) { func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -420,11 +453,13 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er type FormParams struct { name string `url:"name,omitempty"` status string `url:"status,omitempty"` + } _sling = _sling.BodyForm(&FormParams{ name: name,status: status }) + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -457,3 +492,5 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er return err } + + diff --git a/samples/client/petstore/go/swagger/StoreApi.go b/samples/client/petstore/go/swagger/StoreApi.go index cdc56b3baae3..05a3b3ae89cc 100644 --- a/samples/client/petstore/go/swagger/StoreApi.go +++ b/samples/client/petstore/go/swagger/StoreApi.go @@ -1,29 +1,36 @@ package swagger + import ( "strings" "fmt" "encoding/json" "errors" "github.com/dghubble/sling" + ) type StoreApi struct { - basePath string + Configuration Configuration } func NewStoreApi() *StoreApi{ + configuration := NewConfiguration() return &StoreApi { - basePath: "http://petstore.swagger.io/v2", + Configuration: *configuration, } } func NewStoreApiWithBasePath(basePath string) *StoreApi{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &StoreApi { - basePath: basePath, + Configuration: *configuration, } } + /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -33,14 +40,16 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ //func (a StoreApi) DeleteOrder (orderId string) (error) { func (a StoreApi) DeleteOrder (orderId string) (error) { - _sling := sling.New().Delete(a.basePath) + _sling := sling.New().Delete(a.Configuration.BasePath) // create path and map variables path := "/v2/stores/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -51,6 +60,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -83,6 +93,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { return err } + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -92,14 +103,16 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { //func (a StoreApi) GetOrderById (orderId string) (Order, error) { func (a StoreApi) GetOrderById (orderId string) (Order, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/stores/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -108,6 +121,7 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) { } + var successPayload = new(Order) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -142,6 +156,7 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) { return *successPayload, err } + /** * Place an order for a pet * @@ -151,13 +166,15 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) { //func (a StoreApi) PlaceOrder (body Order) (Order, error) { func (a StoreApi) PlaceOrder (body Order) (Order, error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/stores/order" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -165,6 +182,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -202,3 +220,5 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { return *successPayload, err } + + diff --git a/samples/client/petstore/go/swagger/UserApi.go b/samples/client/petstore/go/swagger/UserApi.go index e90e72abaff7..25bed9edbe01 100644 --- a/samples/client/petstore/go/swagger/UserApi.go +++ b/samples/client/petstore/go/swagger/UserApi.go @@ -1,29 +1,36 @@ package swagger + import ( "strings" "fmt" "encoding/json" "errors" "github.com/dghubble/sling" + ) type UserApi struct { - basePath string + Configuration Configuration } func NewUserApi() *UserApi{ + configuration := NewConfiguration() return &UserApi { - basePath: "http://petstore.swagger.io/v2", + Configuration: *configuration, } } func NewUserApiWithBasePath(basePath string) *UserApi{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &UserApi { - basePath: basePath, + Configuration: *configuration, } } + /** * Create user * This can only be done by the logged in user. @@ -33,13 +40,15 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ //func (a UserApi) CreateUser (body User) (error) { func (a UserApi) CreateUser (body User) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/users" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -47,6 +56,7 @@ func (a UserApi) CreateUser (body User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -84,6 +94,7 @@ func (a UserApi) CreateUser (body User) (error) { return err } + /** * Creates list of users with given input array * @@ -93,13 +104,15 @@ func (a UserApi) CreateUser (body User) (error) { //func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/users/createWithArray" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -107,6 +120,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -144,6 +158,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { return err } + /** * Creates list of users with given input array * @@ -153,13 +168,15 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { //func (a UserApi) CreateUsersWithListInput (body []User) (error) { func (a UserApi) CreateUsersWithListInput (body []User) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/users/createWithList" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -167,6 +184,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -204,6 +222,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { return err } + /** * Delete user * This can only be done by the logged in user. @@ -213,14 +232,16 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { //func (a UserApi) DeleteUser (username string) (error) { func (a UserApi) DeleteUser (username string) (error) { - _sling := sling.New().Delete(a.basePath) + _sling := sling.New().Delete(a.Configuration.BasePath) // create path and map variables path := "/v2/users/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -231,6 +252,7 @@ func (a UserApi) DeleteUser (username string) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -263,6 +285,7 @@ func (a UserApi) DeleteUser (username string) (error) { return err } + /** * Get user by user name * @@ -272,14 +295,16 @@ func (a UserApi) DeleteUser (username string) (error) { //func (a UserApi) GetUserByName (username string) (User, error) { func (a UserApi) GetUserByName (username string) (User, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/users/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -288,6 +313,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { } + var successPayload = new(User) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -322,6 +348,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { return *successPayload, err } + /** * Logs user into the system * @@ -332,11 +359,12 @@ func (a UserApi) GetUserByName (username string) (User, error) { //func (a UserApi) LoginUser (username string, password string) (string, error) { func (a UserApi) LoginUser (username string, password string) (string, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/users/login" + _sling = _sling.Path(path) type QueryParams struct { @@ -345,6 +373,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { } _sling = _sling.QueryStruct(&QueryParams{ username: username,password: password }) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -353,6 +382,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { } + var successPayload = new(string) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -387,6 +417,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { return *successPayload, err } + /** * Logs out current logged in user session * @@ -395,13 +426,15 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { //func (a UserApi) LogoutUser () (error) { func (a UserApi) LogoutUser () (error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/users/logout" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -412,6 +445,7 @@ func (a UserApi) LogoutUser () (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -444,6 +478,7 @@ func (a UserApi) LogoutUser () (error) { return err } + /** * Updated user * This can only be done by the logged in user. @@ -454,14 +489,16 @@ func (a UserApi) LogoutUser () (error) { //func (a UserApi) UpdateUser (username string, body User) (error) { func (a UserApi) UpdateUser (username string, body User) (error) { - _sling := sling.New().Put(a.basePath) + _sling := sling.New().Put(a.Configuration.BasePath) // create path and map variables path := "/v2/users/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -469,6 +506,7 @@ func (a UserApi) UpdateUser (username string, body User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -506,3 +544,5 @@ func (a UserApi) UpdateUser (username string, body User) (error) { return err } + +