From e555b3ad34cc8e285c1c4713604e8255dd0eec2b Mon Sep 17 00:00:00 2001 From: Guo Huang Date: Wed, 20 Apr 2016 22:36:32 -0700 Subject: [PATCH] added debug setter and getter in Go configuration --- .../src/main/resources/go/api_client.mustache | 2 +- .../src/main/resources/go/configuration.mustache | 12 ++++++++++-- samples/client/petstore/go/go-petstore/api_client.go | 4 ++-- .../client/petstore/go/go-petstore/configuration.go | 12 ++++++++++-- samples/client/petstore/go/test.go | 2 ++ 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/go/api_client.mustache b/modules/swagger-codegen/src/main/resources/go/api_client.mustache index ce6de7017e0..9143f33b504 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -56,7 +56,7 @@ func (c *ApiClient) CallApi(path string, method string, //set debug flag configuration := NewConfiguration() - resty.SetDebug(configuration.Debug) + resty.SetDebug(configuration.GetDebug()) request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index 154ceb9ffc6..e5f05a63c12 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -9,7 +9,7 @@ type Configuration struct { Password string `json:"password,omitempty"` ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` ApiKey map[string] string `json:"apiKey,omitempty"` - Debug bool `json:"debug,omitempty"` + debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` Timeout int `json:"timeout,omitempty"` @@ -26,7 +26,7 @@ func NewConfiguration() *Configuration { return &Configuration{ BasePath: "{{basePath}}", UserName: "", - Debug: false, + debug: false, DefaultHeader: make(map[string]string), ApiKey: make(map[string]string), ApiKeyPrefix: make(map[string]string), @@ -48,4 +48,12 @@ func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { } return c.ApiKey[apiKeyIdentifier] +} + +func (c *Configuration) SetDebug(enable bool){ + c.debug = enable +} + +func (c *Configuration) GetDebug() bool { + return c.debug } \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 77ec4ef3994..33451139a97 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -56,7 +56,7 @@ func (c *ApiClient) CallApi(path string, method string, //set debug flag configuration := NewConfiguration() - resty.SetDebug(configuration.Debug) + resty.SetDebug(configuration.GetDebug()) request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) @@ -134,7 +134,7 @@ func prepareRequest(postBody interface{}, } if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) + _, fileNm := filepath.Split(fileName) request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) } return request diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index e8a00bccaf5..3fe94d36c26 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -9,7 +9,7 @@ type Configuration struct { Password string `json:"password,omitempty"` ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"` ApiKey map[string] string `json:"apiKey,omitempty"` - Debug bool `json:"debug,omitempty"` + debug bool `json:"debug,omitempty"` DebugFile string `json:"debugFile,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"` Timeout int `json:"timeout,omitempty"` @@ -26,7 +26,7 @@ func NewConfiguration() *Configuration { return &Configuration{ BasePath: "http://petstore.swagger.io/v2", UserName: "", - Debug: false, + debug: false, DefaultHeader: make(map[string]string), ApiKey: make(map[string]string), ApiKeyPrefix: make(map[string]string), @@ -48,4 +48,12 @@ func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string { } return c.ApiKey[apiKeyIdentifier] +} + +func (c *Configuration) SetDebug(enable bool){ + c.debug = enable +} + +func (c *Configuration) GetDebug() bool { + return c.debug } \ No newline at end of file diff --git a/samples/client/petstore/go/test.go b/samples/client/petstore/go/test.go index 2dcd385212e..6a50c9bbc8e 100644 --- a/samples/client/petstore/go/test.go +++ b/samples/client/petstore/go/test.go @@ -25,4 +25,6 @@ func main() { resp, err, apiResponse := s.GetPetById(12830) fmt.Println("GetPetById: ", resp, err, apiResponse) + err2, apiResponse2 := s.DeletePet(12830, "") + fmt.Println("DeletePet: ", err2, apiResponse2) }