Merge pull request #2750 from neilotoole/issue-2748-formatting

Issue #2748 - generated code now conforms more closely to conventions
This commit is contained in:
wing328 2016-05-03 10:01:53 +08:00
commit 766c73497d
19 changed files with 1419 additions and 1552 deletions

View File

@ -5,7 +5,7 @@ import (
"strings" "strings"
"fmt" "fmt"
"errors" "errors"
{{#imports}} "{{import}}" {{#imports}}"{{import}}"
{{/imports}} {{/imports}}
) )
@ -13,45 +13,41 @@ type {{classname}} struct {
Configuration Configuration Configuration Configuration
} }
func New{{classname}}() *{{classname}}{ func New{{classname}}() *{{classname}} {
configuration := NewConfiguration() configuration := NewConfiguration()
return &{{classname}} { return &{{classname}}{
Configuration: *configuration, Configuration: *configuration,
} }
} }
func New{{classname}}WithBasePath(basePath string) *{{classname}}{ func New{{classname}}WithBasePath(basePath string) *{{classname}} {
configuration := NewConfiguration() configuration := NewConfiguration()
configuration.BasePath = basePath configuration.BasePath = basePath
return &{{classname}} { return &{{classname}}{
Configuration: *configuration, Configuration: *configuration,
} }
} }
{{#operation}} {{#operation}}
/** /**
* {{summary}} * {{summary}}{{#notes}}
* {{notes}} * {{notes}}{{/notes}}
*
{{#allParams}} * @param {{paramName}} {{description}} {{#allParams}} * @param {{paramName}} {{description}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{/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}}" var httpMethod = "{{httpMethod}}"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "{{path}}" path := a.Configuration.BasePath + "{{path}}"{{#pathParams}}
{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1) path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
{{/pathParams}} {{#allParams}}{{#required}}
{{#allParams}}
{{#required}}
// verify the required parameter '{{paramName}}' is set // verify the required parameter '{{paramName}}' is set
if &{{paramName}} == nil { if &{{paramName}} == nil {
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
} }{{/required}}{{/allParams}}
{{/required}}
{{/allParams}}
headerParams := make(map[string]string) headerParams := make(map[string]string)
queryParams := make(map[string]string) queryParams := make(map[string]string)
@ -59,92 +55,68 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
{{#authMethods}}
{{#authMethods}}// authentication ({{name}}) required // authentication ({{name}}) required
{{#isApiKey}}{{#isKeyInHeader}} {{#isApiKey}}{{#isKeyInHeader}}
// set key with prefix in header // set key with prefix in header
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/isKeyInHeader}}{{#isKeyInQuery}} {{/isKeyInHeader}}{{#isKeyInQuery}}
// set key with prefix in querystring // set key with prefix in querystring{{#hasKeyParamName}}
{{#hasKeyParamName}}
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}") queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/hasKeyParamName}} {{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
{{/isKeyInQuery}}{{/isApiKey}}
{{#isBasic}}
// http basic authentication required // http basic authentication required
if a.Configuration.Username != "" || a.Configuration.Password != ""{ if a.Configuration.Username != "" || a.Configuration.Password != ""{
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString() headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
} }{{/isBasic}}{{#isOAuth}}
{{/isBasic}}
{{#isOAuth}}
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }{{/isOAuth}}{{/authMethods}}
{{/isOAuth}}
{{/authMethods}}
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }{{#hasQueryParams}}{{#queryParams}}
{{#hasQueryParams}}
{{#queryParams}}
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}}) queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
{{/queryParams}} {{/queryParams}}{{/hasQueryParams}}
{{/hasQueryParams}}
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ {{#consumes}}"{{mediaType}}", {{/consumes}} }
{{#consumes}}
"{{mediaType}}", // set Content-Type header
{{/consumes}}
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
{{#produces}} {{#produces}}"{{mediaType}}",
"{{mediaType}}", {{/produces}} }
{{/produces}}
} // set Accept header
//set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }{{#hasHeaderParams}}
{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
{{#headerParams}} // header params "{{baseName}}"
headerParams["{{baseName}}"] = {{paramName}} headerParams["{{baseName}}"] = {{paramName}}
{{/headerParams}}{{/hasHeaderParams}} {{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}}
{{#hasFormParams}} {{#formParams}}{{#isFile}}
{{#formParams}} fbs, _ := ioutil.ReadAll(file)
{{#isFile}}fbs, _ := ioutil.ReadAll(file)
fileBytes = fbs fileBytes = fbs
fileName = file.Name() fileName = file.Name(){{/isFile}}
{{/isFile}} {{^isFile}} formParams["{{paramName}}"] = {{paramName}}{{/isFile}}{{/formParams}}{{/hasFormParams}}{{#hasBodyParam}}
{{^isFile}}formParams["{{paramName}}"] = {{paramName}} {{#bodyParams}} // body params
{{/isFile}}
{{/formParams}}
{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params
postBody = &{{paramName}} postBody = &{{paramName}}
{{/bodyParams}}{{/hasBodyParam}} {{/bodyParams}}{{/hasBodyParam}}
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}} {{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
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 { if err != nil {
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
} }
{{#returnType}} {{#returnType}}
err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
{{/returnType}}
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
} }
{{/operation}} {{/operation}}{{/operations}}
{{/operations}}

View File

@ -1,39 +1,38 @@
package {{packageName}} package {{packageName}}
import ( import (
"strings"
"github.com/go-resty/resty"
"fmt"
"reflect"
"bytes" "bytes"
"fmt"
"path/filepath" "path/filepath"
"reflect"
"strings"
"github.com/go-resty/resty"
) )
type APIClient struct { type APIClient struct {
} }
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
if (len(contentTypes) == 0){
if len(contentTypes) == 0 {
return "" return ""
} }
if contains(contentTypes,"application/json") { if contains(contentTypes, "application/json") {
return "application/json" return "application/json"
} }
return contentTypes[0] // use the first content type specified in 'consumes' return contentTypes[0] // use the first content type specified in 'consumes'
} }
func (c *APIClient) SelectHeaderAccept(accepts []string) string { func (c *APIClient) SelectHeaderAccept(accepts []string) string {
if (len(accepts) == 0){
if len(accepts) == 0 {
return "" return ""
} }
if contains(accepts, "application/json") {
if contains(accepts,"application/json"){
return "application/json" return "application/json"
} }
return strings.Join(accepts, ",")
return strings.Join(accepts,",")
} }
func contains(source []string, containvalue string) bool { func contains(source []string, containvalue string) bool {
@ -45,7 +44,6 @@ func contains(source []string, containvalue string) bool {
return false return false
} }
func (c *APIClient) CallAPI(path string, method string, func (c *APIClient) CallAPI(path string, method string,
postBody interface{}, postBody interface{},
headerParams map[string]string, headerParams map[string]string,
@ -58,7 +56,7 @@ func (c *APIClient) CallAPI(path string, method string,
configuration := NewConfiguration() configuration := NewConfiguration()
resty.SetDebug(configuration.GetDebug()) resty.SetDebug(configuration.GetDebug())
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
switch strings.ToUpper(method) { switch strings.ToUpper(method) {
case "GET": case "GET":
@ -97,7 +95,6 @@ func prepareRequest(postBody interface{},
fileBytes []byte) *resty.Request { fileBytes []byte) *resty.Request {
request := resty.R() request := resty.R()
request.SetBody(postBody) request.SetBody(postBody)
// add header parameter, if any // add header parameter, if any

View File

@ -4,21 +4,19 @@ import (
"net/http" "net/http"
) )
type APIResponse struct { type APIResponse struct {
*http.Response *http.Response
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
} }
func NewAPIResponse(r *http.Response) *APIResponse { func NewAPIResponse(r *http.Response) *APIResponse {
response := &APIResponse{Response: r}
response := &APIResponse{Response: r}
return response return response
} }
func NewAPIResponseWithError(errorMessage string) *APIResponse { func NewAPIResponseWithError(errorMessage string) *APIResponse {
response := &APIResponse{Message: errorMessage}
response := &APIResponse{Message: errorMessage}
return response return response
} }

View File

@ -7,8 +7,8 @@ import (
type Configuration struct { type Configuration struct {
UserName string `json:"userName,omitempty"` UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
APIKey map[string] string `json:"APIKey,omitempty"` APIKey map[string]string `json:"APIKey,omitempty"`
debug bool `json:"debug,omitempty"` debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"` DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"`
@ -43,14 +43,14 @@ func (c *Configuration) AddDefaultHeader(key string, value string) {
} }
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
if c.APIKeyPrefix[APIKeyIdentifier] != ""{ if c.APIKeyPrefix[APIKeyIdentifier] != "" {
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
} }
return c.APIKey[APIKeyIdentifier] return c.APIKey[APIKeyIdentifier]
} }
func (c *Configuration) SetDebug(enable bool){ func (c *Configuration) SetDebug(enable bool) {
c.debug = enable c.debug = enable
} }

View File

@ -1,18 +1,14 @@
package {{packageName}} package {{packageName}}
{{#models}}{{#imports}}
{{#models}} import ({{/imports}}{{#imports}}
import ( "{{import}}"{{/imports}}{{#imports}}
{{#imports}} "{{import}}"
{{/imports}}
) )
{{/imports}}{{#model}}{{#description}}
{{#model}} // {{{description}}}{{/description}}
{{#description}}// {{{description}}}{{/description}}
type {{classname}} struct { type {{classname}} struct {
{{#vars}} {{#vars}}{{#description}}
{{#description}}// {{{description}}}{{/description}} // {{{description}}}{{/description}}
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"` {{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
{{/vars}} {{/vars}}
} }
{{/model}} {{/model}}{{/models}}
{{/models}}

View File

@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge
- API version: 1.0.0 - API version: 1.0.0
- Package 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 - Build package: class io.swagger.codegen.languages.GoClientCodegen
## Installation ## Installation

View File

@ -1,39 +1,38 @@
package petstore package petstore
import ( import (
"strings"
"github.com/go-resty/resty"
"fmt"
"reflect"
"bytes" "bytes"
"fmt"
"path/filepath" "path/filepath"
"reflect"
"strings"
"github.com/go-resty/resty"
) )
type APIClient struct { type APIClient struct {
} }
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string { func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
if (len(contentTypes) == 0){
if len(contentTypes) == 0 {
return "" return ""
} }
if contains(contentTypes,"application/json") { if contains(contentTypes, "application/json") {
return "application/json" return "application/json"
} }
return contentTypes[0] // use the first content type specified in 'consumes' return contentTypes[0] // use the first content type specified in 'consumes'
} }
func (c *APIClient) SelectHeaderAccept(accepts []string) string { func (c *APIClient) SelectHeaderAccept(accepts []string) string {
if (len(accepts) == 0){
if len(accepts) == 0 {
return "" return ""
} }
if contains(accepts, "application/json") {
if contains(accepts,"application/json"){
return "application/json" return "application/json"
} }
return strings.Join(accepts, ",")
return strings.Join(accepts,",")
} }
func contains(source []string, containvalue string) bool { func contains(source []string, containvalue string) bool {
@ -45,7 +44,6 @@ func contains(source []string, containvalue string) bool {
return false return false
} }
func (c *APIClient) CallAPI(path string, method string, func (c *APIClient) CallAPI(path string, method string,
postBody interface{}, postBody interface{},
headerParams map[string]string, headerParams map[string]string,
@ -58,7 +56,7 @@ func (c *APIClient) CallAPI(path string, method string,
configuration := NewConfiguration() configuration := NewConfiguration()
resty.SetDebug(configuration.GetDebug()) resty.SetDebug(configuration.GetDebug())
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes) request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
switch strings.ToUpper(method) { switch strings.ToUpper(method) {
case "GET": case "GET":
@ -97,7 +95,6 @@ func prepareRequest(postBody interface{},
fileBytes []byte) *resty.Request { fileBytes []byte) *resty.Request {
request := resty.R() request := resty.R()
request.SetBody(postBody) request.SetBody(postBody)
// add header parameter, if any // add header parameter, if any

View File

@ -4,21 +4,19 @@ import (
"net/http" "net/http"
) )
type APIResponse struct { type APIResponse struct {
*http.Response *http.Response
Message string `json:"message,omitempty"` Message string `json:"message,omitempty"`
} }
func NewAPIResponse(r *http.Response) *APIResponse { func NewAPIResponse(r *http.Response) *APIResponse {
response := &APIResponse{Response: r}
response := &APIResponse{Response: r}
return response return response
} }
func NewAPIResponseWithError(errorMessage string) *APIResponse { func NewAPIResponseWithError(errorMessage string) *APIResponse {
response := &APIResponse{Message: errorMessage}
response := &APIResponse{Message: errorMessage}
return response return response
} }

View File

@ -1,9 +1,5 @@
package petstore package petstore
import (
)
type Category struct { type Category struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`

View File

@ -7,8 +7,8 @@ import (
type Configuration struct { type Configuration struct {
UserName string `json:"userName,omitempty"` UserName string `json:"userName,omitempty"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"` APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
APIKey map[string] string `json:"APIKey,omitempty"` APIKey map[string]string `json:"APIKey,omitempty"`
debug bool `json:"debug,omitempty"` debug bool `json:"debug,omitempty"`
DebugFile string `json:"debugFile,omitempty"` DebugFile string `json:"debugFile,omitempty"`
OAuthToken string `json:"oAuthToken,omitempty"` OAuthToken string `json:"oAuthToken,omitempty"`
@ -43,14 +43,14 @@ func (c *Configuration) AddDefaultHeader(key string, value string) {
} }
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string { func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
if c.APIKeyPrefix[APIKeyIdentifier] != ""{ if c.APIKeyPrefix[APIKeyIdentifier] != "" {
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier] return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
} }
return c.APIKey[APIKeyIdentifier] return c.APIKey[APIKeyIdentifier]
} }
func (c *Configuration) SetDebug(enable bool){ func (c *Configuration) SetDebug(enable bool) {
c.debug = enable c.debug = enable
} }

View File

@ -8,12 +8,12 @@ git_repo_id=$2
release_note=$3 release_note=$3
if [ "$git_user_id" = "" ]; then 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" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi fi
if [ "$git_repo_id" = "" ]; then 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" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi fi

View File

@ -1,9 +1,5 @@
package petstore package petstore
import (
)
type ModelApiResponse struct { type ModelApiResponse struct {
Code int32 `json:"code,omitempty"` Code int32 `json:"code,omitempty"`

View File

@ -4,7 +4,6 @@ import (
"time" "time"
) )
type Order struct { type Order struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
@ -14,6 +13,7 @@ type Order struct {
Quantity int32 `json:"quantity,omitempty"` Quantity int32 `json:"quantity,omitempty"`
ShipDate time.Time `json:"shipDate,omitempty"` ShipDate time.Time `json:"shipDate,omitempty"`
// Order Status // Order Status
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`

View File

@ -1,9 +1,5 @@
package petstore package petstore
import (
)
type Pet struct { type Pet struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
@ -15,6 +11,7 @@ type Pet struct {
PhotoUrls []string `json:"photoUrls,omitempty"` PhotoUrls []string `json:"photoUrls,omitempty"`
Tags []Tag `json:"tags,omitempty"` Tags []Tag `json:"tags,omitempty"`
// pet status in the store // pet status in the store
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
} }

View File

@ -5,26 +5,26 @@ import (
"fmt" "fmt"
"errors" "errors"
"os" "os"
"io/ioutil" "io/ioutil"
"encoding/json" "encoding/json"
) )
type PetApi struct { type PetApi struct {
Configuration Configuration Configuration Configuration
} }
func NewPetApi() *PetApi{ func NewPetApi() *PetApi {
configuration := NewConfiguration() configuration := NewConfiguration()
return &PetApi { return &PetApi{
Configuration: *configuration, Configuration: *configuration,
} }
} }
func NewPetApiWithBasePath(basePath string) *PetApi{ func NewPetApiWithBasePath(basePath string) *PetApi {
configuration := NewConfiguration() configuration := NewConfiguration()
configuration.BasePath = basePath configuration.BasePath = basePath
return &PetApi { return &PetApi{
Configuration: *configuration, Configuration: *configuration,
} }
} }
@ -32,10 +32,11 @@ func NewPetApiWithBasePath(basePath string) *PetApi{
/** /**
* Add a new pet to the store * Add a new pet to the store
* *
*
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
* @return void * @return void
*/ */
func (a PetApi) AddPet (body Pet) (APIResponse, error) { func (a PetApi) AddPet(body Pet) (APIResponse, error) {
var httpMethod = "Post" var httpMethod = "Post"
// create path and map variables // create path and map variables
@ -52,67 +53,62 @@ func (a PetApi) AddPet (body Pet) (APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ "application/json", "application/xml", }
"application/json",
"application/xml", // set Content-Type header
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Deletes a pet * Deletes a pet
* *
*
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
* @return void * @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" var httpMethod = "Delete"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/pet/{petId}" path := a.Configuration.BasePath + "/pet/{petId}"
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set // verify the required parameter 'petId' is set
if &petId == nil { if &petId == nil {
@ -125,59 +121,57 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// header params "api_key" // header params "api_key"
headerParams["api_key"] = apiKey headerParams["api_key"] = apiKey
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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
*
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
* @return []Pet * @return []Pet
*/ */
func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) { func (a PetApi) FindPetsByStatus(status []string) ([]Pet, APIResponse, error) {
var httpMethod = "Get" var httpMethod = "Get"
// create path and map variables // create path and map variables
@ -194,14 +188,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
@ -209,45 +201,43 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) {
queryParams["status"] = a.Configuration.APIClient.ParameterToString(status) queryParams["status"] = a.Configuration.APIClient.ParameterToString(status)
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new([]Pet) var successPayload = new([]Pet)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
*
* @param tags Tags to filter by * @param tags Tags to filter by
* @return []Pet * @return []Pet
*/ */
func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) { func (a PetApi) FindPetsByTags(tags []string) ([]Pet, APIResponse, error) {
var httpMethod = "Get" var httpMethod = "Get"
// create path and map variables // create path and map variables
@ -264,14 +254,12 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
@ -279,50 +267,48 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) {
queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags) queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags)
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new([]Pet) var successPayload = new([]Pet)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Find pet by ID * Find pet by ID
* Returns a single pet * Returns a single pet
*
* @param petId ID of pet to return * @param petId ID of pet to return
* @return Pet * @return Pet
*/ */
func (a PetApi) GetPetById (petId int64) (Pet, APIResponse, error) { func (a PetApi) GetPetById(petId int64) (Pet, APIResponse, error) {
var httpMethod = "Get" var httpMethod = "Get"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/pet/{petId}" path := a.Configuration.BasePath + "/pet/{petId}"
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set // verify the required parameter 'petId' is set
if &petId == nil { if &petId == nil {
@ -335,58 +321,52 @@ func (a PetApi) GetPetById (petId int64) (Pet, APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (api_key) required // authentication (api_key) required
// set key with prefix in header // set key with prefix in header
headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key")
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new(Pet) var successPayload = new(Pet)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Update an existing pet * Update an existing pet
* *
*
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
* @return void * @return void
*/ */
func (a PetApi) UpdatePet (body Pet) (APIResponse, error) { func (a PetApi) UpdatePet(body Pet) (APIResponse, error) {
var httpMethod = "Put" var httpMethod = "Put"
// create path and map variables // create path and map variables
@ -403,68 +383,63 @@ func (a PetApi) UpdatePet (body Pet) (APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ "application/json", "application/xml", }
"application/json",
"application/xml", // set Content-Type header
}
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
* *
*
* @param petId ID of pet that needs to be updated * @param petId ID of pet that needs to be updated
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
* @return void * @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" var httpMethod = "Post"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/pet/{petId}" path := a.Configuration.BasePath + "/pet/{petId}"
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set // verify the required parameter 'petId' is set
if &petId == nil { if &petId == nil {
@ -477,35 +452,32 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (API
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ "application/x-www-form-urlencoded", }
"application/x-www-form-urlencoded",
} // set Content-Type header
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
@ -514,30 +486,29 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (API
formParams["name"] = name formParams["name"] = name
formParams["status"] = status 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* uploads an image * uploads an image
* *
*
* @param petId ID of pet to update * @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
* @return ModelApiResponse * @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" var httpMethod = "Post"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/pet/{petId}/uploadImage" path := a.Configuration.BasePath + "/pet/{petId}/uploadImage"
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set // verify the required parameter 'petId' is set
if &petId == nil { if &petId == nil {
@ -550,34 +521,31 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (petstore_auth) required // authentication (petstore_auth) required
// oauth required // oauth required
if a.Configuration.AccessToken != ""{ if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
} }
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ "multipart/form-data", }
"multipart/form-data",
} // set Content-Type header
//set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
@ -590,13 +558,10 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
var successPayload = new(ModelApiResponse) var successPayload = new(ModelApiResponse)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }

View File

@ -11,18 +11,18 @@ type StoreApi struct {
Configuration Configuration Configuration Configuration
} }
func NewStoreApi() *StoreApi{ func NewStoreApi() *StoreApi {
configuration := NewConfiguration() configuration := NewConfiguration()
return &StoreApi { return &StoreApi{
Configuration: *configuration, Configuration: *configuration,
} }
} }
func NewStoreApiWithBasePath(basePath string) *StoreApi{ func NewStoreApiWithBasePath(basePath string) *StoreApi {
configuration := NewConfiguration() configuration := NewConfiguration()
configuration.BasePath = basePath configuration.BasePath = basePath
return &StoreApi { return &StoreApi{
Configuration: *configuration, Configuration: *configuration,
} }
} }
@ -30,15 +30,16 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{
/** /**
* Delete purchase order by ID * Delete purchase order by ID
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * 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 * @param orderId ID of the order that needs to be deleted
* @return void * @return void
*/ */
func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) { func (a StoreApi) DeleteOrder(orderId string) (APIResponse, error) {
var httpMethod = "Delete" var httpMethod = "Delete"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/store/order/{orderId}" path := a.Configuration.BasePath + "/store/order/{orderId}"
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
// verify the required parameter 'orderId' is set // verify the required parameter 'orderId' is set
if &orderId == nil { if &orderId == nil {
@ -52,49 +53,46 @@ func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*
* @return map[string]int32 * @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" var httpMethod = "Get"
// create path and map variables // create path and map variables
@ -107,62 +105,56 @@ func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) {
var postBody interface{} var postBody interface{}
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// authentication (api_key) required // authentication (api_key) required
// set key with prefix in header // set key with prefix in header
headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key") headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key")
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new(map[string]int32) var successPayload = new(map[string]int32)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * 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 * @param orderId ID of pet that needs to be fetched
* @return Order * @return Order
*/ */
func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) { func (a StoreApi) GetOrderById(orderId int64) (Order, APIResponse, error) {
var httpMethod = "Get" var httpMethod = "Get"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/store/order/{orderId}" path := a.Configuration.BasePath + "/store/order/{orderId}"
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
// verify the required parameter 'orderId' is set // verify the required parameter 'orderId' is set
if &orderId == nil { if &orderId == nil {
@ -176,52 +168,47 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new(Order) var successPayload = new(Order)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Place an order for a pet * Place an order for a pet
* *
*
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
* @return Order * @return Order
*/ */
func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) { func (a StoreApi) PlaceOrder(body Order) (Order, APIResponse, error) {
var httpMethod = "Post" var httpMethod = "Post"
// create path and map variables // create path and map variables
@ -239,44 +226,39 @@ func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body postBody = &body
var successPayload = new(Order) var successPayload = new(Order)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }

View File

@ -1,9 +1,5 @@
package petstore package petstore
import (
)
type Tag struct { type Tag struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`

View File

@ -1,9 +1,5 @@
package petstore package petstore
import (
)
type User struct { type User struct {
Id int64 `json:"id,omitempty"` Id int64 `json:"id,omitempty"`
@ -19,6 +15,7 @@ type User struct {
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
Phone string `json:"phone,omitempty"` Phone string `json:"phone,omitempty"`
// User Status // User Status
UserStatus int32 `json:"userStatus,omitempty"` UserStatus int32 `json:"userStatus,omitempty"`
} }

View File

@ -11,18 +11,18 @@ type UserApi struct {
Configuration Configuration Configuration Configuration
} }
func NewUserApi() *UserApi{ func NewUserApi() *UserApi {
configuration := NewConfiguration() configuration := NewConfiguration()
return &UserApi { return &UserApi{
Configuration: *configuration, Configuration: *configuration,
} }
} }
func NewUserApiWithBasePath(basePath string) *UserApi{ func NewUserApiWithBasePath(basePath string) *UserApi {
configuration := NewConfiguration() configuration := NewConfiguration()
configuration.BasePath = basePath configuration.BasePath = basePath
return &UserApi { return &UserApi{
Configuration: *configuration, Configuration: *configuration,
} }
} }
@ -30,10 +30,11 @@ func NewUserApiWithBasePath(basePath string) *UserApi{
/** /**
* Create user * Create user
* This can only be done by the logged in user. * This can only be done by the logged in user.
*
* @param body Created user object * @param body Created user object
* @return void * @return void
*/ */
func (a UserApi) CreateUser (body User) (APIResponse, error) { func (a UserApi) CreateUser(body User) (APIResponse, error) {
var httpMethod = "Post" var httpMethod = "Post"
// create path and map variables // create path and map variables
@ -51,52 +52,50 @@ func (a UserApi) CreateUser (body User) (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
* *
*
* @param body List of user object * @param body List of user object
* @return void * @return void
*/ */
func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) { func (a UserApi) CreateUsersWithArrayInput(body []User) (APIResponse, error) {
var httpMethod = "Post" var httpMethod = "Post"
// create path and map variables // create path and map variables
@ -114,52 +113,50 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Creates list of users with given input array * Creates list of users with given input array
* *
*
* @param body List of user object * @param body List of user object
* @return void * @return void
*/ */
func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) { func (a UserApi) CreateUsersWithListInput(body []User) (APIResponse, error) {
var httpMethod = "Post" var httpMethod = "Post"
// create path and map variables // create path and map variables
@ -177,57 +174,55 @@ func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Delete user * Delete user
* This can only be done by the logged in user. * This can only be done by the logged in user.
*
* @param username The name that needs to be deleted * @param username The name that needs to be deleted
* @return void * @return void
*/ */
func (a UserApi) DeleteUser (username string) (APIResponse, error) { func (a UserApi) DeleteUser(username string) (APIResponse, error) {
var httpMethod = "Delete" var httpMethod = "Delete"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/user/{username}" path := a.Configuration.BasePath + "/user/{username}"
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
// verify the required parameter 'username' is set // verify the required parameter 'username' is set
if &username == nil { if &username == nil {
@ -241,55 +236,52 @@ func (a UserApi) DeleteUser (username string) (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Get user by user name * Get user by user name
* *
*
* @param username The name that needs to be fetched. Use user1 for testing. * @param username The name that needs to be fetched. Use user1 for testing.
* @return User * @return User
*/ */
func (a UserApi) GetUserByName (username string) (User, APIResponse, error) { func (a UserApi) GetUserByName(username string) (User, APIResponse, error) {
var httpMethod = "Get" var httpMethod = "Get"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/user/{username}" path := a.Configuration.BasePath + "/user/{username}"
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
// verify the required parameter 'username' is set // verify the required parameter 'username' is set
if &username == nil { if &username == nil {
@ -303,53 +295,48 @@ func (a UserApi) GetUserByName (username string) (User, APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new(User) var successPayload = new(User)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Logs user into the system * Logs user into the system
* *
*
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
* @return string * @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" var httpMethod = "Get"
// create path and map variables // create path and map variables
@ -371,53 +358,52 @@ func (a UserApi) LoginUser (username string, password string) (string, APIRespon
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
queryParams["username"] = a.Configuration.APIClient.ParameterToString(username) queryParams["username"] = a.Configuration.APIClient.ParameterToString(username)
queryParams["password"] = a.Configuration.APIClient.ParameterToString(password) queryParams["password"] = a.Configuration.APIClient.ParameterToString(password)
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
var successPayload = new(string) var successPayload = new(string)
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 { if err != nil {
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
err = json.Unmarshal(httpResponse.Body(), &successPayload) err = json.Unmarshal(httpResponse.Body(), &successPayload)
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Logs out current logged in user session * Logs out current logged in user session
* *
*
* @return void * @return void
*/ */
func (a UserApi) LogoutUser () (APIResponse, error) { func (a UserApi) LogoutUser() (APIResponse, error) {
var httpMethod = "Get" var httpMethod = "Get"
// create path and map variables // create path and map variables
@ -431,56 +417,53 @@ func (a UserApi) LogoutUser () (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
/** /**
* Updated user * Updated user
* This can only be done by the logged in user. * This can only be done by the logged in user.
*
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
* @return void * @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" var httpMethod = "Put"
// create path and map variables // create path and map variables
path := a.Configuration.BasePath + "/user/{username}" path := a.Configuration.BasePath + "/user/{username}"
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
// verify the required parameter 'username' is set // verify the required parameter 'username' is set
if &username == nil { if &username == nil {
@ -498,42 +481,39 @@ func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) {
var fileName string var fileName string
var fileBytes []byte var fileBytes []byte
// add default headers if any // add default headers if any
for key := range a.Configuration.DefaultHeader { for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key] headerParams[key] = a.Configuration.DefaultHeader[key]
} }
// to determine the Content-Type header // to determine the Content-Type header
localVarHttpContentTypes := []string { localVarHttpContentTypes := []string{ }
}
//set Content-Type header // set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" { if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType headerParams["Content-Type"] = localVarHttpContentType
} }
// to determine the Accept header // to determine the Accept header
localVarHttpHeaderAccepts := []string { localVarHttpHeaderAccepts := []string{
"application/xml", "application/xml",
"application/json", "application/json",
} }
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts) localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" { if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept headerParams["Accept"] = localVarHttpHeaderAccept
} }
// body params // body params
postBody = &body 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 { if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }
return *NewAPIResponse(httpResponse.RawResponse), err return *NewAPIResponse(httpResponse.RawResponse), err
} }