diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 9b8998cf614..6ca3a39324f 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -2,149 +2,121 @@ package {{packageName}} {{#operations}} import ( - "strings" - "fmt" - "errors" -{{#imports}} "{{import}}" + "strings" + "fmt" + "errors" + {{#imports}}"{{import}}" {{/imports}} ) type {{classname}} struct { - Configuration Configuration + Configuration Configuration } -func New{{classname}}() *{{classname}}{ - configuration := NewConfiguration() - return &{{classname}} { - Configuration: *configuration, - } +func New{{classname}}() *{{classname}} { + configuration := NewConfiguration() + return &{{classname}}{ + Configuration: *configuration, + } } -func New{{classname}}WithBasePath(basePath string) *{{classname}}{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &{{classname}} { - Configuration: *configuration, - } -} +func New{{classname}}WithBasePath(basePath string) *{{classname}} { + configuration := NewConfiguration() + configuration.BasePath = basePath + return &{{classname}}{ + Configuration: *configuration, + } +} {{#operation}} + /** - * {{summary}} - * {{notes}} + * {{summary}}{{#notes}} + * {{notes}}{{/notes}} + * {{#allParams}} * @param {{paramName}} {{description}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ -func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) { +func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) { - var httpMethod = "{{httpMethod}}" - // create path and map variables - path := a.Configuration.BasePath + "{{path}}" -{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) -{{/pathParams}} + var httpMethod = "{{httpMethod}}" + // create path and map variables + path := a.Configuration.BasePath + "{{path}}"{{#pathParams}} + path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}} +{{#allParams}}{{#required}} + // verify the required parameter '{{paramName}}' is set + if &{{paramName}} == nil { + return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") + }{{/required}}{{/allParams}} - {{#allParams}} - {{#required}} - // verify the required parameter '{{paramName}}' is set - if &{{paramName}} == nil { - return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") - } - {{/required}} - {{/allParams}} + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte +{{#authMethods}} + // authentication ({{name}}) required +{{#isApiKey}}{{#isKeyInHeader}} + // set key with prefix in header + headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") +{{/isKeyInHeader}}{{#isKeyInQuery}} + // set key with prefix in querystring{{#hasKeyParamName}} + queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") +{{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}} + // http basic authentication required + if a.Configuration.Username != "" || a.Configuration.Password != ""{ + headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() + }{{/isBasic}}{{#isOAuth}} + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + }{{/isOAuth}}{{/authMethods}} + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + }{{#hasQueryParams}}{{#queryParams}} - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}}) + {{/queryParams}}{{/hasQueryParams}} - {{#authMethods}}// authentication ({{name}}) required - {{#isApiKey}}{{#isKeyInHeader}} - // set key with prefix in header - headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") - {{/isKeyInHeader}}{{#isKeyInQuery}} - // set key with prefix in querystring - {{#hasKeyParamName}} - queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") - {{/hasKeyParamName}} - {{/isKeyInQuery}}{{/isApiKey}} - {{#isBasic}} - // http basic authentication required - if a.Configuration.Username != "" || a.Configuration.Password != ""{ - headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() - } - {{/isBasic}} - {{#isOAuth}} - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } - {{/isOAuth}} - {{/authMethods}} + // to determine the Content-Type header + localVarHttpContentTypes := []string{ {{#consumes}}"{{mediaType}}", {{/consumes}} } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - {{#hasQueryParams}} - {{#queryParams}} - queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}}) - {{/queryParams}} - {{/hasQueryParams}} + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + {{#produces}}"{{mediaType}}", +{{/produces}} } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - {{#consumes}} - "{{mediaType}}", - {{/consumes}} - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - {{#produces}} - "{{mediaType}}", - {{/produces}} - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } -{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}" - headerParams["{{baseName}}"] = {{paramName}} -{{/headerParams}}{{/hasHeaderParams}} -{{#hasFormParams}} -{{#formParams}} - {{#isFile}}fbs, _ := ioutil.ReadAll(file) - fileBytes = fbs - fileName = file.Name() - {{/isFile}} -{{^isFile}}formParams["{{paramName}}"] = {{paramName}} - {{/isFile}} -{{/formParams}} -{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params - postBody = &{{paramName}} + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + }{{#hasHeaderParams}} + +{{#headerParams}} // header params "{{baseName}}" + headerParams["{{baseName}}"] = {{paramName}} +{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}} +{{#formParams}}{{#isFile}} + fbs, _ := ioutil.ReadAll(file) + fileBytes = fbs + fileName = file.Name(){{/isFile}} +{{^isFile}} formParams["{{paramName}}"] = {{paramName}}{{/isFile}}{{/formParams}}{{/hasFormParams}}{{#hasBodyParam}} +{{#bodyParams}} // body params + postBody = &{{paramName}} {{/bodyParams}}{{/hasBodyParam}} -{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err - } +{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err + } {{#returnType}} - - err = json.Unmarshal(httpResponse.Body(), &successPayload) -{{/returnType}} - - return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err + err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}} + return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err } -{{/operation}} -{{/operations}} +{{/operation}}{{/operations}} 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 a88445656d7..88c5ce07e4e 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_client.mustache @@ -1,123 +1,120 @@ package {{packageName}} import ( - "strings" - "github.com/go-resty/resty" - "fmt" - "reflect" - "bytes" - "path/filepath" + "bytes" + "fmt" + "path/filepath" + "reflect" + "strings" + + "github.com/go-resty/resty" ) 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' + 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,",") + 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 + for _, a := range source { + if strings.ToLower(a) == strings.ToLower(containvalue) { + return true + } + } + return false } - func (c *APIClient) CallAPI(path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams map[string]string, - formParams map[string]string, - fileName string, - fileBytes []byte) (*resty.Response, error) { + postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) (*resty.Response, error) { - //set debug flag - configuration := NewConfiguration() - resty.SetDebug(configuration.GetDebug()) + //set debug flag + configuration := NewConfiguration() + resty.SetDebug(configuration.GetDebug()) - request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) + request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes) - switch strings.ToUpper(method) { - case "GET": - response, err := request.Get(path) - return response, err - case "POST": - response, err := request.Post(path) - return response, err - case "PUT": - response, err := request.Put(path) - return response, err - case "PATCH": - response, err := request.Patch(path) - return response, err - case "DELETE": - response, err := request.Delete(path) - return response, err - } + switch strings.ToUpper(method) { + case "GET": + response, err := request.Get(path) + return response, err + case "POST": + response, err := request.Post(path) + return response, err + case "PUT": + response, err := request.Put(path) + return response, err + case "PATCH": + response, err := request.Patch(path) + return response, err + case "DELETE": + response, err := request.Delete(path) + return response, err + } - return nil, fmt.Errorf("invalid method %v", method) + return nil, fmt.Errorf("invalid method %v", method) } func (c *APIClient) ParameterToString(obj interface{}) string { - if reflect.TypeOf(obj).String() == "[]string" { - return strings.Join(obj.([]string), ",") - } else { - return obj.(string) - } + if reflect.TypeOf(obj).String() == "[]string" { + return strings.Join(obj.([]string), ",") + } else { + return obj.(string) + } } func prepareRequest(postBody interface{}, - headerParams map[string]string, - queryParams map[string]string, - formParams map[string]string, - fileName string, - fileBytes []byte) *resty.Request { + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) *resty.Request { - request := resty.R() + request := resty.R() + request.SetBody(postBody) - request.SetBody(postBody) + // add header parameter, if any + if len(headerParams) > 0 { + request.SetHeaders(headerParams) + } - // add header parameter, if any - if len(headerParams) > 0 { - request.SetHeaders(headerParams) - } - - // add query parameter, if any - if len(queryParams) > 0 { - request.SetQueryParams(queryParams) - } + // add query parameter, if any + if len(queryParams) > 0 { + request.SetQueryParams(queryParams) + } - // add form parameter, if any - if len(formParams) > 0 { - request.SetFormData(formParams) - } - - if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) - request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) - } - return request + // add form parameter, if any + if len(formParams) > 0 { + request.SetFormData(formParams) + } + + if len(fileBytes) > 0 && fileName != "" { + _, fileNm := filepath.Split(fileName) + request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + } + return request } diff --git a/modules/swagger-codegen/src/main/resources/go/api_response.mustache b/modules/swagger-codegen/src/main/resources/go/api_response.mustache index 9f81de76d62..a15293f4402 100644 --- a/modules/swagger-codegen/src/main/resources/go/api_response.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api_response.mustache @@ -1,24 +1,22 @@ package {{packageName}} import ( - "net/http" + "net/http" ) - type APIResponse struct { - *http.Response - - Message string `json:"message,omitempty"` + *http.Response + Message string `json:"message,omitempty"` } func NewAPIResponse(r *http.Response) *APIResponse { - response := &APIResponse{Response: r} - return response + response := &APIResponse{Response: r} + return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { - response := &APIResponse{Message: errorMessage} - return response -} \ No newline at end of file + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache index d971bf0373b..463f77c54dc 100644 --- a/modules/swagger-codegen/src/main/resources/go/configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -1,59 +1,59 @@ package {{packageName}} import ( - "encoding/base64" + "encoding/base64" ) type Configuration struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` - APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` - APIKey map[string] 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"` - AccessToken string `json:"accessToken,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - APIClient APIClient `json:"APIClient,omitempty"` + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` + APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"` + APIKey map[string]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"` + 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 { - return &Configuration{ - BasePath: "{{basePath}}", - UserName: "", - debug: false, - DefaultHeader: make(map[string]string), - APIKey: make(map[string]string), - APIKeyPrefix: make(map[string]string), - UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}", - } + return &Configuration{ + BasePath: "{{basePath}}", + UserName: "", + debug: false, + DefaultHeader: make(map[string]string), + APIKey: make(map[string]string), + APIKeyPrefix: make(map[string]string), + UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}", + } } func (c *Configuration) GetBasicAuthEncodedString() string { - return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password)) + return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password)) } func (c *Configuration) AddDefaultHeader(key string, value string) { - c.DefaultHeader[key] = value + c.DefaultHeader[key] = value } func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { - if c.APIKeyPrefix[APIKeyIdentifier] != ""{ - return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] - } - - return c.APIKey[APIKeyIdentifier] + if c.APIKeyPrefix[APIKeyIdentifier] != "" { + return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] + } + + return c.APIKey[APIKeyIdentifier] } -func (c *Configuration) SetDebug(enable bool){ - c.debug = enable +func (c *Configuration) SetDebug(enable bool) { + c.debug = enable } func (c *Configuration) GetDebug() bool { - return c.debug -} \ No newline at end of file + return c.debug +} diff --git a/modules/swagger-codegen/src/main/resources/go/model.mustache b/modules/swagger-codegen/src/main/resources/go/model.mustache index 4102299c5e9..fd799a0e35d 100644 --- a/modules/swagger-codegen/src/main/resources/go/model.mustache +++ b/modules/swagger-codegen/src/main/resources/go/model.mustache @@ -1,18 +1,14 @@ package {{packageName}} - -{{#models}} -import ( -{{#imports}} "{{import}}" -{{/imports}} +{{#models}}{{#imports}} +import ({{/imports}}{{#imports}} + "{{import}}"{{/imports}}{{#imports}} ) - -{{#model}} -{{#description}}// {{{description}}}{{/description}} +{{/imports}}{{#model}}{{#description}} +// {{{description}}}{{/description}} type {{classname}} struct { - {{#vars}} - {{#description}}// {{{description}}}{{/description}} - {{name}} {{{datatype}}} `json:"{{baseName}},omitempty"` - {{/vars}} +{{#vars}}{{#description}} + // {{{description}}}{{/description}} + {{name}} {{{datatype}}} `json:"{{baseName}},omitempty"` +{{/vars}} } -{{/model}} -{{/models}} +{{/model}}{{/models}} \ No newline at end of file diff --git a/samples/client/petstore/go/go-petstore/README.md b/samples/client/petstore/go/go-petstore/README.md index 92a8f1b8685..9130ec599b6 100644 --- a/samples/client/petstore/go/go-petstore/README.md +++ b/samples/client/petstore/go/go-petstore/README.md @@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-04-27T21:14:49.805-07:00 +- Build date: 2016-05-02T15:51:26.331+01:00 - Build package: class io.swagger.codegen.languages.GoClientCodegen ## Installation diff --git a/samples/client/petstore/go/go-petstore/api_client.go b/samples/client/petstore/go/go-petstore/api_client.go index 743b45a139d..100a36da7e1 100644 --- a/samples/client/petstore/go/go-petstore/api_client.go +++ b/samples/client/petstore/go/go-petstore/api_client.go @@ -1,123 +1,120 @@ package petstore import ( - "strings" - "github.com/go-resty/resty" - "fmt" - "reflect" - "bytes" - "path/filepath" + "bytes" + "fmt" + "path/filepath" + "reflect" + "strings" + + "github.com/go-resty/resty" ) 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' + 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,",") + 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 + for _, a := range source { + if strings.ToLower(a) == strings.ToLower(containvalue) { + return true + } + } + return false } - func (c *APIClient) CallAPI(path string, method string, - postBody interface{}, - headerParams map[string]string, - queryParams map[string]string, - formParams map[string]string, - fileName string, - fileBytes []byte) (*resty.Response, error) { + postBody interface{}, + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) (*resty.Response, error) { - //set debug flag - configuration := NewConfiguration() - resty.SetDebug(configuration.GetDebug()) + //set debug flag + configuration := NewConfiguration() + resty.SetDebug(configuration.GetDebug()) - request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) + request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes) - switch strings.ToUpper(method) { - case "GET": - response, err := request.Get(path) - return response, err - case "POST": - response, err := request.Post(path) - return response, err - case "PUT": - response, err := request.Put(path) - return response, err - case "PATCH": - response, err := request.Patch(path) - return response, err - case "DELETE": - response, err := request.Delete(path) - return response, err - } + switch strings.ToUpper(method) { + case "GET": + response, err := request.Get(path) + return response, err + case "POST": + response, err := request.Post(path) + return response, err + case "PUT": + response, err := request.Put(path) + return response, err + case "PATCH": + response, err := request.Patch(path) + return response, err + case "DELETE": + response, err := request.Delete(path) + return response, err + } - return nil, fmt.Errorf("invalid method %v", method) + return nil, fmt.Errorf("invalid method %v", method) } func (c *APIClient) ParameterToString(obj interface{}) string { - if reflect.TypeOf(obj).String() == "[]string" { - return strings.Join(obj.([]string), ",") - } else { - return obj.(string) - } + if reflect.TypeOf(obj).String() == "[]string" { + return strings.Join(obj.([]string), ",") + } else { + return obj.(string) + } } func prepareRequest(postBody interface{}, - headerParams map[string]string, - queryParams map[string]string, - formParams map[string]string, - fileName string, - fileBytes []byte) *resty.Request { + headerParams map[string]string, + queryParams map[string]string, + formParams map[string]string, + fileName string, + fileBytes []byte) *resty.Request { - request := resty.R() + request := resty.R() + request.SetBody(postBody) - request.SetBody(postBody) + // add header parameter, if any + if len(headerParams) > 0 { + request.SetHeaders(headerParams) + } - // add header parameter, if any - if len(headerParams) > 0 { - request.SetHeaders(headerParams) - } - - // add query parameter, if any - if len(queryParams) > 0 { - request.SetQueryParams(queryParams) - } + // add query parameter, if any + if len(queryParams) > 0 { + request.SetQueryParams(queryParams) + } - // add form parameter, if any - if len(formParams) > 0 { - request.SetFormData(formParams) - } - - if len(fileBytes) > 0 && fileName != "" { - _, fileNm := filepath.Split(fileName) - request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) - } - return request + // add form parameter, if any + if len(formParams) > 0 { + request.SetFormData(formParams) + } + + if len(fileBytes) > 0 && fileName != "" { + _, fileNm := filepath.Split(fileName) + request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes)) + } + return request } diff --git a/samples/client/petstore/go/go-petstore/api_response.go b/samples/client/petstore/go/go-petstore/api_response.go index b670ad101a8..0404289f96b 100644 --- a/samples/client/petstore/go/go-petstore/api_response.go +++ b/samples/client/petstore/go/go-petstore/api_response.go @@ -1,24 +1,22 @@ package petstore import ( - "net/http" + "net/http" ) - type APIResponse struct { - *http.Response - - Message string `json:"message,omitempty"` + *http.Response + Message string `json:"message,omitempty"` } func NewAPIResponse(r *http.Response) *APIResponse { - response := &APIResponse{Response: r} - return response + response := &APIResponse{Response: r} + return response } func NewAPIResponseWithError(errorMessage string) *APIResponse { - response := &APIResponse{Message: errorMessage} - return response -} \ No newline at end of file + response := &APIResponse{Message: errorMessage} + return response +} diff --git a/samples/client/petstore/go/go-petstore/category.go b/samples/client/petstore/go/go-petstore/category.go index eb715721978..197316d62ef 100644 --- a/samples/client/petstore/go/go-petstore/category.go +++ b/samples/client/petstore/go/go-petstore/category.go @@ -1,12 +1,8 @@ package petstore -import ( -) - - type Category struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` + + Id int64 `json:"id,omitempty"` + + Name string `json:"name,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/configuration.go b/samples/client/petstore/go/go-petstore/configuration.go index 51aad379b42..5d7df91948e 100644 --- a/samples/client/petstore/go/go-petstore/configuration.go +++ b/samples/client/petstore/go/go-petstore/configuration.go @@ -1,59 +1,59 @@ package petstore import ( - "encoding/base64" + "encoding/base64" ) type Configuration struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` - APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` - APIKey map[string] 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"` - AccessToken string `json:"accessToken,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - APIClient APIClient `json:"APIClient,omitempty"` + UserName string `json:"userName,omitempty"` + Password string `json:"password,omitempty"` + APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"` + APIKey map[string]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"` + 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 { - return &Configuration{ - BasePath: "http://petstore.swagger.io/v2", - UserName: "", - debug: false, - DefaultHeader: make(map[string]string), - APIKey: make(map[string]string), - APIKeyPrefix: make(map[string]string), - UserAgent: "Swagger-Codegen/1.0.0/go", - } + return &Configuration{ + BasePath: "http://petstore.swagger.io/v2", + UserName: "", + debug: false, + DefaultHeader: make(map[string]string), + APIKey: make(map[string]string), + APIKeyPrefix: make(map[string]string), + UserAgent: "Swagger-Codegen/1.0.0/go", + } } func (c *Configuration) GetBasicAuthEncodedString() string { - return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password)) + return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password)) } func (c *Configuration) AddDefaultHeader(key string, value string) { - c.DefaultHeader[key] = value + c.DefaultHeader[key] = value } func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { - if c.APIKeyPrefix[APIKeyIdentifier] != ""{ - return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] - } - - return c.APIKey[APIKeyIdentifier] + if c.APIKeyPrefix[APIKeyIdentifier] != "" { + return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] + } + + return c.APIKey[APIKeyIdentifier] } -func (c *Configuration) SetDebug(enable bool){ - c.debug = enable +func (c *Configuration) SetDebug(enable bool) { + c.debug = enable } func (c *Configuration) GetDebug() bool { - return c.debug -} \ No newline at end of file + return c.debug +} diff --git a/samples/client/petstore/go/go-petstore/git_push.sh b/samples/client/petstore/go/go-petstore/git_push.sh index 1a36388db02..ed374619b13 100644 --- a/samples/client/petstore/go/go-petstore/git_push.sh +++ b/samples/client/petstore/go/go-petstore/git_push.sh @@ -8,12 +8,12 @@ git_repo_id=$2 release_note=$3 if [ "$git_user_id" = "" ]; then - git_user_id="YOUR_GIT_USR_ID" + git_user_id="GIT_USER_ID" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" fi if [ "$git_repo_id" = "" ]; then - git_repo_id="YOUR_GIT_REPO_ID" + git_repo_id="GIT_REPO_ID" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" fi diff --git a/samples/client/petstore/go/go-petstore/model_api_response.go b/samples/client/petstore/go/go-petstore/model_api_response.go index 8183399abd9..774f781ee93 100644 --- a/samples/client/petstore/go/go-petstore/model_api_response.go +++ b/samples/client/petstore/go/go-petstore/model_api_response.go @@ -1,14 +1,10 @@ package petstore -import ( -) - - type ModelApiResponse struct { - - Code int32 `json:"code,omitempty"` - - Type_ string `json:"type,omitempty"` - - Message string `json:"message,omitempty"` + + Code int32 `json:"code,omitempty"` + + Type_ string `json:"type,omitempty"` + + Message string `json:"message,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/order.go b/samples/client/petstore/go/go-petstore/order.go index 29b6cffeba0..582d45a747f 100644 --- a/samples/client/petstore/go/go-petstore/order.go +++ b/samples/client/petstore/go/go-petstore/order.go @@ -1,21 +1,21 @@ package petstore import ( - "time" + "time" ) - type Order struct { - - Id int64 `json:"id,omitempty"` - - PetId int64 `json:"petId,omitempty"` - - Quantity int32 `json:"quantity,omitempty"` - - ShipDate time.Time `json:"shipDate,omitempty"` - // Order Status - Status string `json:"status,omitempty"` - - Complete bool `json:"complete,omitempty"` + + Id int64 `json:"id,omitempty"` + + PetId int64 `json:"petId,omitempty"` + + Quantity int32 `json:"quantity,omitempty"` + + ShipDate time.Time `json:"shipDate,omitempty"` + + // Order Status + Status string `json:"status,omitempty"` + + Complete bool `json:"complete,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/pet.go b/samples/client/petstore/go/go-petstore/pet.go index 99016d2d540..88e86af7399 100644 --- a/samples/client/petstore/go/go-petstore/pet.go +++ b/samples/client/petstore/go/go-petstore/pet.go @@ -1,20 +1,17 @@ package petstore -import ( -) - - type Pet struct { - - Id int64 `json:"id,omitempty"` - - Category Category `json:"category,omitempty"` - - Name string `json:"name,omitempty"` - - PhotoUrls []string `json:"photoUrls,omitempty"` - - Tags []Tag `json:"tags,omitempty"` - // pet status in the store - Status string `json:"status,omitempty"` + + Id int64 `json:"id,omitempty"` + + Category Category `json:"category,omitempty"` + + Name string `json:"name,omitempty"` + + PhotoUrls []string `json:"photoUrls,omitempty"` + + Tags []Tag `json:"tags,omitempty"` + + // pet status in the store + Status string `json:"status,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/pet_api.go b/samples/client/petstore/go/go-petstore/pet_api.go index ac4e23656be..0e252159fd0 100644 --- a/samples/client/petstore/go/go-petstore/pet_api.go +++ b/samples/client/petstore/go/go-petstore/pet_api.go @@ -1,602 +1,567 @@ package petstore import ( - "strings" - "fmt" - "errors" - "os" - "io/ioutil" - "encoding/json" + "strings" + "fmt" + "errors" + "os" +"io/ioutil" +"encoding/json" ) type PetApi struct { - Configuration Configuration + Configuration Configuration } -func NewPetApi() *PetApi{ - configuration := NewConfiguration() - return &PetApi { - Configuration: *configuration, - } +func NewPetApi() *PetApi { + configuration := NewConfiguration() + return &PetApi{ + Configuration: *configuration, + } } -func NewPetApiWithBasePath(basePath string) *PetApi{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &PetApi { - Configuration: *configuration, - } +func NewPetApiWithBasePath(basePath string) *PetApi { + configuration := NewConfiguration() + configuration.BasePath = basePath + + return &PetApi{ + Configuration: *configuration, + } } /** * Add a new pet to the store * + * * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) AddPet (body Pet) (APIResponse, error) { +func (a PetApi) AddPet(body Pet) (APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/pet" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet" - // verify the required parameter 'body' is set - if &body == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/xml", } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/json", - "application/xml", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - // body params - postBody = &body + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Deletes a pet * + * * @param petId Pet id to delete * @param apiKey * @return void */ -func (a PetApi) DeletePet (petId int64, apiKey string) (APIResponse, error) { +func (a PetApi) DeletePet(petId int64, apiKey string) (APIResponse, error) { - var httpMethod = "Delete" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" + path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } - // header params "api_key" - headerParams["api_key"] = apiKey + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + + // header params "api_key" + headerParams["api_key"] = apiKey + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings + * * @param status Status values that need to be considered for filter * @return []Pet */ -func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) { +func (a PetApi) FindPetsByStatus(status []string) ([]Pet, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/pet/findByStatus" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/findByStatus" - // verify the required parameter 'status' is set - if &status == nil { - return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") - } + // verify the required parameter 'status' is set + if &status == nil { + return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - queryParams["status"] = a.Configuration.APIClient.ParameterToString(status) + queryParams["status"] = a.Configuration.APIClient.ParameterToString(status) + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - var successPayload = new([]Pet) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new([]Pet) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * * @param tags Tags to filter by * @return []Pet */ -func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) { +func (a PetApi) FindPetsByTags(tags []string) ([]Pet, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/pet/findByTags" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/findByTags" - // verify the required parameter 'tags' is set - if &tags == nil { - return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") - } + // verify the required parameter 'tags' is set + if &tags == nil { + return *new([]Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags) + queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags) + - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - var successPayload = new([]Pet) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new([]Pet) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Find pet by ID * Returns a single pet + * * @param petId ID of pet to return * @return Pet */ -func (a PetApi) GetPetById (petId int64) (Pet, APIResponse, error) { +func (a PetApi) GetPetById(petId int64) (Pet, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" + path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return *new(Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *new(Pet), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (api_key) required - // authentication (api_key) required - - // set key with prefix in header - headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") - + // set key with prefix in header + headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - var successPayload = new(Pet) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new(Pet) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Update an existing pet * + * * @param body Pet object that needs to be added to the store * @return void */ -func (a PetApi) UpdatePet (body Pet) (APIResponse, error) { +func (a PetApi) UpdatePet(body Pet) (APIResponse, error) { - var httpMethod = "Put" - // create path and map variables - path := a.Configuration.BasePath + "/pet" + var httpMethod = "Put" + // create path and map variables + path := a.Configuration.BasePath + "/pet" - // verify the required parameter 'body' is set - if &body == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/json", "application/xml", } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "application/json", - "application/xml", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - // body params - postBody = &body + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Updates a pet in the store with form data * + * * @param petId ID of pet that needs to be updated * @param name Updated name of the pet * @param status Updated status of the pet * @return void */ -func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (APIResponse, error) { +func (a PetApi) UpdatePetWithForm(petId int64, name string, status string) (APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}" + path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "application/x-www-form-urlencoded", } - // 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 != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - formParams["name"] = name - formParams["status"] = status + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + formParams["name"] = name + formParams["status"] = status - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * uploads an image * + * * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload * @return ModelApiResponse */ -func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ModelApiResponse, APIResponse, error) { +func (a PetApi) UploadFile(petId int64, additionalMetadata string, file *os.File) (ModelApiResponse, APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" - path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" + path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1) - // verify the required parameter 'petId' is set - if &petId == nil { - return *new(ModelApiResponse), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") - } + // verify the required parameter 'petId' is set + if &petId == nil { + return *new(ModelApiResponse), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (petstore_auth) required - // authentication (petstore_auth) required - - // oauth required - if a.Configuration.AccessToken != ""{ - headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken - } + // oauth required + if a.Configuration.AccessToken != ""{ + headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken + } + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // to determine the Content-Type header + localVarHttpContentTypes := []string{ "multipart/form-data", } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - "multipart/form-data", - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + } - formParams["additionalMetadata"] = additionalMetadata - fbs, _ := ioutil.ReadAll(file) - fileBytes = fbs - fileName = file.Name() + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } - var successPayload = new(ModelApiResponse) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + formParams["additionalMetadata"] = additionalMetadata + fbs, _ := ioutil.ReadAll(file) + fileBytes = fbs + fileName = file.Name() - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + var successPayload = new(ModelApiResponse) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + diff --git a/samples/client/petstore/go/go-petstore/store_api.go b/samples/client/petstore/go/go-petstore/store_api.go index ae011177354..d2848305114 100644 --- a/samples/client/petstore/go/go-petstore/store_api.go +++ b/samples/client/petstore/go/go-petstore/store_api.go @@ -1,282 +1,264 @@ package petstore import ( - "strings" - "fmt" - "errors" - "encoding/json" + "strings" + "fmt" + "errors" + "encoding/json" ) type StoreApi struct { - Configuration Configuration + Configuration Configuration } -func NewStoreApi() *StoreApi{ - configuration := NewConfiguration() - return &StoreApi { - Configuration: *configuration, - } +func NewStoreApi() *StoreApi { + configuration := NewConfiguration() + return &StoreApi{ + Configuration: *configuration, + } } -func NewStoreApiWithBasePath(basePath string) *StoreApi{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &StoreApi { - Configuration: *configuration, - } +func NewStoreApiWithBasePath(basePath string) *StoreApi { + configuration := NewConfiguration() + configuration.BasePath = basePath + + return &StoreApi{ + 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 + * * @param orderId ID of the order that needs to be deleted * @return void */ -func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) { +func (a StoreApi) DeleteOrder(orderId string) (APIResponse, error) { - var httpMethod = "Delete" - // create path and map variables - path := a.Configuration.BasePath + "/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/store/order/{orderId}" + path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1) - // verify the required parameter 'orderId' is set - if &orderId == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") - } + // verify the required parameter 'orderId' is set + if &orderId == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Returns pet inventories by status * Returns a map of status codes to quantities + * * @return map[string]int32 */ -func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) { +func (a StoreApi) GetInventory() (map[string]int32, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/store/inventory" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/store/inventory" - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte + // authentication (api_key) required - // authentication (api_key) required - - // set key with prefix in header - headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") - + // set key with prefix in header + headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["Content-Type"] = localVarHttpContentType - } - // to determine the Accept header - localVarHttpHeaderAccepts := []string { - "application/json", - } - //set Accept header - localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) - if localVarHttpHeaderAccept != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/json", + } - var successPayload = new(map[string]int32) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new(map[string]int32) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * * @param orderId ID of pet that needs to be fetched * @return Order */ -func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) { +func (a StoreApi) GetOrderById(orderId int64) (Order, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/store/order/{orderId}" - path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/store/order/{orderId}" + path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1) - // verify the required parameter 'orderId' is set - if &orderId == nil { - return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") - } + // verify the required parameter 'orderId' is set + if &orderId == nil { + return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - var successPayload = new(Order) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new(Order) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Place an order for a pet * + * * @param body order placed for purchasing the pet * @return Order */ -func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) { +func (a StoreApi) PlaceOrder(body Order) (Order, APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/store/order" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/store/order" - // verify the required parameter 'body' is set - if &body == nil { - return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") - } + // verify the required parameter 'body' is set + if &body == nil { + return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } - // body params - postBody = &body + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - var successPayload = new(Order) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + var successPayload = new(Order) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + diff --git a/samples/client/petstore/go/go-petstore/tag.go b/samples/client/petstore/go/go-petstore/tag.go index 71bb9d198a4..ae901c30ec4 100644 --- a/samples/client/petstore/go/go-petstore/tag.go +++ b/samples/client/petstore/go/go-petstore/tag.go @@ -1,12 +1,8 @@ package petstore -import ( -) - - type Tag struct { - - Id int64 `json:"id,omitempty"` - - Name string `json:"name,omitempty"` + + Id int64 `json:"id,omitempty"` + + Name string `json:"name,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/user.go b/samples/client/petstore/go/go-petstore/user.go index 91a42e57a0e..140a94a275b 100644 --- a/samples/client/petstore/go/go-petstore/user.go +++ b/samples/client/petstore/go/go-petstore/user.go @@ -1,24 +1,21 @@ package petstore -import ( -) - - type User struct { - - Id int64 `json:"id,omitempty"` - - Username string `json:"username,omitempty"` - - FirstName string `json:"firstName,omitempty"` - - LastName string `json:"lastName,omitempty"` - - Email string `json:"email,omitempty"` - - Password string `json:"password,omitempty"` - - Phone string `json:"phone,omitempty"` - // User Status - UserStatus int32 `json:"userStatus,omitempty"` + + Id int64 `json:"id,omitempty"` + + Username string `json:"username,omitempty"` + + FirstName string `json:"firstName,omitempty"` + + LastName string `json:"lastName,omitempty"` + + Email string `json:"email,omitempty"` + + Password string `json:"password,omitempty"` + + Phone string `json:"phone,omitempty"` + + // User Status + UserStatus int32 `json:"userStatus,omitempty"` } diff --git a/samples/client/petstore/go/go-petstore/user_api.go b/samples/client/petstore/go/go-petstore/user_api.go index 8ac944e79fa..ce23df39d69 100644 --- a/samples/client/petstore/go/go-petstore/user_api.go +++ b/samples/client/petstore/go/go-petstore/user_api.go @@ -1,539 +1,519 @@ package petstore import ( - "strings" - "fmt" - "errors" - "encoding/json" + "strings" + "fmt" + "errors" + "encoding/json" ) type UserApi struct { - Configuration Configuration + Configuration Configuration } -func NewUserApi() *UserApi{ - configuration := NewConfiguration() - return &UserApi { - Configuration: *configuration, - } +func NewUserApi() *UserApi { + configuration := NewConfiguration() + return &UserApi{ + Configuration: *configuration, + } } -func NewUserApiWithBasePath(basePath string) *UserApi{ - configuration := NewConfiguration() - configuration.BasePath = basePath - - return &UserApi { - Configuration: *configuration, - } +func NewUserApiWithBasePath(basePath string) *UserApi { + configuration := NewConfiguration() + configuration.BasePath = basePath + + return &UserApi{ + Configuration: *configuration, + } } /** * Create user * This can only be done by the logged in user. + * * @param body Created user object * @return void */ -func (a UserApi) CreateUser (body User) (APIResponse, error) { +func (a UserApi) CreateUser(body User) (APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/user" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user" - // verify the required parameter 'body' is set - if &body == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } - // body params - postBody = &body + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Creates list of users with given input array * + * * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) { +func (a UserApi) CreateUsersWithArrayInput(body []User) (APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/user/createWithArray" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user/createWithArray" - // verify the required parameter 'body' is set - if &body == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } - // body params - postBody = &body + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Creates list of users with given input array * + * * @param body List of user object * @return void */ -func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) { +func (a UserApi) CreateUsersWithListInput(body []User) (APIResponse, error) { - var httpMethod = "Post" - // create path and map variables - path := a.Configuration.BasePath + "/user/createWithList" + var httpMethod = "Post" + // create path and map variables + path := a.Configuration.BasePath + "/user/createWithList" - // verify the required parameter 'body' is set - if &body == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") - } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } - // body params - postBody = &body + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Delete user * This can only be done by the logged in user. + * * @param username The name that needs to be deleted * @return void */ -func (a UserApi) DeleteUser (username string) (APIResponse, error) { +func (a UserApi) DeleteUser(username string) (APIResponse, error) { - var httpMethod = "Delete" - // create path and map variables - path := a.Configuration.BasePath + "/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + var httpMethod = "Delete" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" + path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - // verify the required parameter 'username' is set - if &username == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") - } + // verify the required parameter 'username' is set + if &username == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Get user by user name * + * * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ -func (a UserApi) GetUserByName (username string) (User, APIResponse, error) { +func (a UserApi) GetUserByName(username string) (User, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" + path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - // verify the required parameter 'username' is set - if &username == nil { - return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") - } + // verify the required parameter 'username' is set + if &username == nil { + return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - var successPayload = new(User) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) - - - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new(User) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Logs user into the system * + * * @param username The user name for login * @param password The password for login in clear text * @return string */ -func (a UserApi) LoginUser (username string, password string) (string, APIResponse, error) { +func (a UserApi) LoginUser(username string, password string) (string, APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/user/login" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/login" - // verify the required parameter 'username' is set - if &username == nil { - return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") - } - // verify the required parameter 'password' is set - if &password == nil { - return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") - } + // verify the required parameter 'username' is set + if &username == nil { + return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser") + } + // verify the required parameter 'password' is set + if &password == nil { + return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - - queryParams["username"] = a.Configuration.APIClient.ParameterToString(username) - queryParams["password"] = a.Configuration.APIClient.ParameterToString(password) + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + queryParams["username"] = a.Configuration.APIClient.ParameterToString(username) + + queryParams["password"] = a.Configuration.APIClient.ParameterToString(password) + - var successPayload = new(string) - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["Content-Type"] = localVarHttpContentType + } + // to determine the Accept header + localVarHttpHeaderAccepts := []string{ + "application/xml", +"application/json", + } - if err != nil { - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err - } - - err = json.Unmarshal(httpResponse.Body(), &successPayload) - - return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + // set Accept header + localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + var successPayload = new(string) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err + } + err = json.Unmarshal(httpResponse.Body(), &successPayload) + return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err } + /** * Logs out current logged in user session * + * * @return void */ -func (a UserApi) LogoutUser () (APIResponse, error) { +func (a UserApi) LogoutUser() (APIResponse, error) { - var httpMethod = "Get" - // create path and map variables - path := a.Configuration.BasePath + "/user/logout" + var httpMethod = "Get" + // create path and map variables + path := a.Configuration.BasePath + "/user/logout" - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } + /** * Updated user * This can only be done by the logged in user. + * * @param username name that need to be deleted * @param body Updated user object * @return void */ -func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) { +func (a UserApi) UpdateUser(username string, body User) (APIResponse, error) { - var httpMethod = "Put" - // create path and map variables - path := a.Configuration.BasePath + "/user/{username}" - path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + var httpMethod = "Put" + // create path and map variables + path := a.Configuration.BasePath + "/user/{username}" + path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1) - // verify the required parameter 'username' is set - if &username == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") - } - // verify the required parameter 'body' is set - if &body == nil { - return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") - } + // verify the required parameter 'username' is set + if &username == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser") + } + // verify the required parameter 'body' is set + if &body == nil { + return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser") + } - headerParams := make(map[string]string) - queryParams := make(map[string]string) - formParams := make(map[string]string) - var postBody interface{} - var fileName string - var fileBytes []byte + headerParams := make(map[string]string) + queryParams := make(map[string]string) + formParams := make(map[string]string) + var postBody interface{} + var fileName string + var fileBytes []byte - - // add default headers if any - for key := range a.Configuration.DefaultHeader { - headerParams[key] = a.Configuration.DefaultHeader[key] - } - + // add default headers if any + for key := range a.Configuration.DefaultHeader { + headerParams[key] = a.Configuration.DefaultHeader[key] + } - // to determine the Content-Type header - localVarHttpContentTypes := []string { - } - //set Content-Type header - localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) - if localVarHttpContentType != "" { - headerParams["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 != "" { - headerParams["Accept"] = localVarHttpHeaderAccept - } + // to determine the Content-Type header + localVarHttpContentTypes := []string{ } - // body params - postBody = &body + // set Content-Type header + localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + headerParams["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 != "" { + headerParams["Accept"] = localVarHttpHeaderAccept + } + // body params + postBody = &body - httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes) + if err != nil { + return *NewAPIResponse(httpResponse.RawResponse), err + } - - if err != nil { - return *NewAPIResponse(httpResponse.RawResponse), err - } - - return *NewAPIResponse(httpResponse.RawResponse), err + return *NewAPIResponse(httpResponse.RawResponse), err } +