forked from loafle/openapi-generator-original
added debug setter and getter in Go configuration
This commit is contained in:
parent
a2002d9148
commit
e555b3ad34
@ -56,7 +56,7 @@ func (c *ApiClient) CallApi(path string, method string,
|
|||||||
|
|
||||||
//set debug flag
|
//set debug flag
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
resty.SetDebug(configuration.Debug)
|
resty.SetDebug(configuration.GetDebug())
|
||||||
|
|
||||||
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ type Configuration struct {
|
|||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"`
|
ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"`
|
||||||
ApiKey map[string] string `json:"apiKey,omitempty"`
|
ApiKey map[string] string `json:"apiKey,omitempty"`
|
||||||
Debug bool `json:"debug,omitempty"`
|
debug bool `json:"debug,omitempty"`
|
||||||
DebugFile string `json:"debugFile,omitempty"`
|
DebugFile string `json:"debugFile,omitempty"`
|
||||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||||
Timeout int `json:"timeout,omitempty"`
|
Timeout int `json:"timeout,omitempty"`
|
||||||
@ -26,7 +26,7 @@ func NewConfiguration() *Configuration {
|
|||||||
return &Configuration{
|
return &Configuration{
|
||||||
BasePath: "{{basePath}}",
|
BasePath: "{{basePath}}",
|
||||||
UserName: "",
|
UserName: "",
|
||||||
Debug: false,
|
debug: false,
|
||||||
DefaultHeader: make(map[string]string),
|
DefaultHeader: make(map[string]string),
|
||||||
ApiKey: make(map[string]string),
|
ApiKey: make(map[string]string),
|
||||||
ApiKeyPrefix: make(map[string]string),
|
ApiKeyPrefix: make(map[string]string),
|
||||||
@ -48,4 +48,12 @@ func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return c.ApiKey[apiKeyIdentifier]
|
return c.ApiKey[apiKeyIdentifier]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) SetDebug(enable bool){
|
||||||
|
c.debug = enable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) GetDebug() bool {
|
||||||
|
return c.debug
|
||||||
}
|
}
|
@ -56,7 +56,7 @@ func (c *ApiClient) CallApi(path string, method string,
|
|||||||
|
|
||||||
//set debug flag
|
//set debug flag
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
resty.SetDebug(configuration.Debug)
|
resty.SetDebug(configuration.GetDebug())
|
||||||
|
|
||||||
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ func prepareRequest(postBody interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(fileBytes) > 0 && fileName != "" {
|
if len(fileBytes) > 0 && fileName != "" {
|
||||||
_, fileNm := filepath.Split(fileName)
|
_, fileNm := filepath.Split(fileName)
|
||||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||||
}
|
}
|
||||||
return request
|
return request
|
||||||
|
@ -9,7 +9,7 @@ type Configuration struct {
|
|||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"`
|
ApiKeyPrefix map[string] string `json:"apiKeyPrefix,omitempty"`
|
||||||
ApiKey map[string] string `json:"apiKey,omitempty"`
|
ApiKey map[string] string `json:"apiKey,omitempty"`
|
||||||
Debug bool `json:"debug,omitempty"`
|
debug bool `json:"debug,omitempty"`
|
||||||
DebugFile string `json:"debugFile,omitempty"`
|
DebugFile string `json:"debugFile,omitempty"`
|
||||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||||
Timeout int `json:"timeout,omitempty"`
|
Timeout int `json:"timeout,omitempty"`
|
||||||
@ -26,7 +26,7 @@ func NewConfiguration() *Configuration {
|
|||||||
return &Configuration{
|
return &Configuration{
|
||||||
BasePath: "http://petstore.swagger.io/v2",
|
BasePath: "http://petstore.swagger.io/v2",
|
||||||
UserName: "",
|
UserName: "",
|
||||||
Debug: false,
|
debug: false,
|
||||||
DefaultHeader: make(map[string]string),
|
DefaultHeader: make(map[string]string),
|
||||||
ApiKey: make(map[string]string),
|
ApiKey: make(map[string]string),
|
||||||
ApiKeyPrefix: make(map[string]string),
|
ApiKeyPrefix: make(map[string]string),
|
||||||
@ -48,4 +48,12 @@ func (c *Configuration) GetApiKeyWithPrefix(apiKeyIdentifier string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return c.ApiKey[apiKeyIdentifier]
|
return c.ApiKey[apiKeyIdentifier]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) SetDebug(enable bool){
|
||||||
|
c.debug = enable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) GetDebug() bool {
|
||||||
|
return c.debug
|
||||||
}
|
}
|
@ -25,4 +25,6 @@ func main() {
|
|||||||
resp, err, apiResponse := s.GetPetById(12830)
|
resp, err, apiResponse := s.GetPetById(12830)
|
||||||
fmt.Println("GetPetById: ", resp, err, apiResponse)
|
fmt.Println("GetPetById: ", resp, err, apiResponse)
|
||||||
|
|
||||||
|
err2, apiResponse2 := s.DeletePet(12830, "")
|
||||||
|
fmt.Println("DeletePet: ", err2, apiResponse2)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user