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"
"fmt"
"errors"
{{#imports}} "{{import}}"
{{#imports}}"{{import}}"
{{/imports}}
)
@ -13,45 +13,41 @@ type {{classname}} struct {
Configuration Configuration
}
func New{{classname}}() *{{classname}}{
func New{{classname}}() *{{classname}} {
configuration := NewConfiguration()
return &{{classname}} {
return &{{classname}}{
Configuration: *configuration,
}
}
func New{{classname}}WithBasePath(basePath string) *{{classname}}{
func New{{classname}}WithBasePath(basePath string) *{{classname}} {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &{{classname}} {
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}}
{{#allParams}}
{{#required}}
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}}
}{{/required}}{{/allParams}}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
@ -59,92 +55,68 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
var postBody interface{}
var fileName string
var fileBytes []byte
{{#authMethods}}// authentication ({{name}}) required
{{#isApiKey}}{{#isKeyInHeader}}
{{#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}}
{{/isKeyInHeader}}{{#isKeyInQuery}}
// set key with prefix in querystring{{#hasKeyParamName}}
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
{{/hasKeyParamName}}
{{/isKeyInQuery}}{{/isApiKey}}
{{#isBasic}}
{{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
// http basic authentication required
if a.Configuration.Username != "" || a.Configuration.Password != ""{
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
}
{{/isBasic}}
{{#isOAuth}}
}{{/isBasic}}{{#isOAuth}}
// oauth required
if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
}
{{/isOAuth}}
{{/authMethods}}
}{{/isOAuth}}{{/authMethods}}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
}{{#hasQueryParams}}{{#queryParams}}
{{#hasQueryParams}}
{{#queryParams}}
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
{{/queryParams}}
{{/hasQueryParams}}
{{/queryParams}}{{/hasQueryParams}}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
{{#consumes}}
"{{mediaType}}",
{{/consumes}}
}
//set 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
localVarHttpHeaderAccepts := []string{
{{#produces}}"{{mediaType}}",
{{/produces}} }
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
}{{#hasHeaderParams}}
{{#headerParams}} // header params "{{baseName}}"
headerParams["{{baseName}}"] = {{paramName}}
{{/headerParams}}{{/hasHeaderParams}}
{{#hasFormParams}}
{{#formParams}}
{{#isFile}}fbs, _ := ioutil.ReadAll(file)
{{/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
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}}
err = json.Unmarshal(httpResponse.Body(), &successPayload)
{{/returnType}}
err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}}
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
}
{{/operation}}
{{/operations}}
{{/operation}}{{/operations}}

View File

@ -1,39 +1,38 @@
package {{packageName}}
import (
"strings"
"github.com/go-resty/resty"
"fmt"
"reflect"
"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){
if len(contentTypes) == 0 {
return ""
}
if contains(contentTypes,"application/json") {
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){
if len(accepts) == 0 {
return ""
}
if contains(accepts,"application/json"){
if contains(accepts, "application/json") {
return "application/json"
}
return strings.Join(accepts,",")
return strings.Join(accepts, ",")
}
func contains(source []string, containvalue string) bool {
@ -45,7 +44,6 @@ func contains(source []string, containvalue string) bool {
return false
}
func (c *APIClient) CallAPI(path string, method string,
postBody interface{},
headerParams map[string]string,
@ -58,7 +56,7 @@ func (c *APIClient) CallAPI(path string, method string,
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":
@ -97,7 +95,6 @@ func prepareRequest(postBody interface{},
fileBytes []byte) *resty.Request {
request := resty.R()
request.SetBody(postBody)
// add header parameter, if any

View File

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

View File

@ -7,8 +7,8 @@ import (
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"`
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"`
@ -43,14 +43,14 @@ func (c *Configuration) AddDefaultHeader(key string, value 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.APIKey[APIKeyIdentifier]
}
func (c *Configuration) SetDebug(enable bool){
func (c *Configuration) SetDebug(enable bool) {
c.debug = enable
}

View File

@ -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}}
{{#vars}}{{#description}}
// {{{description}}}{{/description}}
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
{{/vars}}
{{/vars}}
}
{{/model}}
{{/models}}
{{/model}}{{/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
- 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

View File

@ -1,39 +1,38 @@
package petstore
import (
"strings"
"github.com/go-resty/resty"
"fmt"
"reflect"
"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){
if len(contentTypes) == 0 {
return ""
}
if contains(contentTypes,"application/json") {
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){
if len(accepts) == 0 {
return ""
}
if contains(accepts,"application/json"){
if contains(accepts, "application/json") {
return "application/json"
}
return strings.Join(accepts,",")
return strings.Join(accepts, ",")
}
func contains(source []string, containvalue string) bool {
@ -45,7 +44,6 @@ func contains(source []string, containvalue string) bool {
return false
}
func (c *APIClient) CallAPI(path string, method string,
postBody interface{},
headerParams map[string]string,
@ -58,7 +56,7 @@ func (c *APIClient) CallAPI(path string, method string,
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":
@ -97,7 +95,6 @@ func prepareRequest(postBody interface{},
fileBytes []byte) *resty.Request {
request := resty.R()
request.SetBody(postBody)
// add header parameter, if any

View File

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

View File

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

View File

@ -7,8 +7,8 @@ import (
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"`
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"`
@ -43,14 +43,14 @@ func (c *Configuration) AddDefaultHeader(key string, value 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.APIKey[APIKeyIdentifier]
}
func (c *Configuration) SetDebug(enable bool){
func (c *Configuration) SetDebug(enable bool) {
c.debug = enable
}

View File

@ -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

View File

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

View File

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

View File

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

View File

@ -5,26 +5,26 @@ import (
"fmt"
"errors"
"os"
"io/ioutil"
"encoding/json"
"io/ioutil"
"encoding/json"
)
type PetApi struct {
Configuration Configuration
}
func NewPetApi() *PetApi{
func NewPetApi() *PetApi {
configuration := NewConfiguration()
return &PetApi {
return &PetApi{
Configuration: *configuration,
}
}
func NewPetApiWithBasePath(basePath string) *PetApi{
func NewPetApiWithBasePath(basePath string) *PetApi {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &PetApi {
return &PetApi{
Configuration: *configuration,
}
}
@ -32,10 +32,11 @@ func NewPetApiWithBasePath(basePath string) *PetApi{
/**
* 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
@ -52,67 +53,62 @@ func (a PetApi) AddPet (body Pet) (APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
"application/json",
"application/xml",
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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)
path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set
if &petId == nil {
@ -125,59 +121,57 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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
}
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
@ -194,14 +188,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
@ -209,45 +201,43 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, APIResponse, error) {
queryParams["status"] = a.Configuration.APIClient.ParameterToString(status)
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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
@ -264,14 +254,12 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
@ -279,50 +267,48 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, APIResponse, error) {
queryParams["tags"] = a.Configuration.APIClient.ParameterToString(tags)
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set
if &petId == nil {
@ -335,58 +321,52 @@ func (a PetApi) GetPetById (petId int64) (Pet, APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (api_key) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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
@ -403,68 +383,63 @@ func (a PetApi) UpdatePet (body Pet) (APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
"application/json",
"application/xml",
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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)
path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set
if &petId == nil {
@ -477,35 +452,32 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (API
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
"application/x-www-form-urlencoded",
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
@ -514,30 +486,29 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (API
formParams["name"] = name
formParams["status"] = status
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
}
/**
* 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)
path = strings.Replace(path, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
// verify the required parameter 'petId' is set
if &petId == nil {
@ -550,34 +521,31 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (petstore_auth) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
"multipart/form-data",
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/json",
}
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
@ -590,13 +558,10 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
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
}

View File

@ -11,18 +11,18 @@ type StoreApi struct {
Configuration Configuration
}
func NewStoreApi() *StoreApi{
func NewStoreApi() *StoreApi {
configuration := NewConfiguration()
return &StoreApi {
return &StoreApi{
Configuration: *configuration,
}
}
func NewStoreApiWithBasePath(basePath string) *StoreApi{
func NewStoreApiWithBasePath(basePath string) *StoreApi {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &StoreApi {
return &StoreApi{
Configuration: *configuration,
}
}
@ -30,15 +30,16 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{
/**
* 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)
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
// verify the required parameter 'orderId' is set
if &orderId == nil {
@ -52,49 +53,46 @@ func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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
@ -107,62 +105,56 @@ func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) {
var postBody interface{}
var fileName string
var fileBytes []byte
// authentication (api_key) required
// 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]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/json",
}
//set Accept header
// 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)
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
// verify the required parameter 'orderId' is set
if &orderId == nil {
@ -176,52 +168,47 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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
@ -239,44 +226,39 @@ func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// body params
postBody = &body
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
}

View File

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

View File

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

View File

@ -11,18 +11,18 @@ type UserApi struct {
Configuration Configuration
}
func NewUserApi() *UserApi{
func NewUserApi() *UserApi {
configuration := NewConfiguration()
return &UserApi {
return &UserApi{
Configuration: *configuration,
}
}
func NewUserApiWithBasePath(basePath string) *UserApi{
func NewUserApiWithBasePath(basePath string) *UserApi {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &UserApi {
return &UserApi{
Configuration: *configuration,
}
}
@ -30,10 +30,11 @@ func NewUserApiWithBasePath(basePath string) *UserApi{
/**
* 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
@ -51,52 +52,50 @@ func (a UserApi) CreateUser (body User) (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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
@ -114,52 +113,50 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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
@ -177,57 +174,55 @@ func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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)
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
// verify the required parameter 'username' is set
if &username == nil {
@ -241,55 +236,52 @@ func (a UserApi) DeleteUser (username string) (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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)
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
// verify the required parameter 'username' is set
if &username == nil {
@ -303,53 +295,48 @@ func (a UserApi) GetUserByName (username string) (User, APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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
@ -371,53 +358,52 @@ func (a UserApi) LoginUser (username string, password string) (string, APIRespon
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)
// to determine the Content-Type header
localVarHttpContentTypes := []string {
}
//set 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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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
@ -431,56 +417,53 @@ func (a UserApi) LogoutUser () (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
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)
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
// verify the required parameter 'username' is set
if &username == nil {
@ -498,42 +481,39 @@ func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) {
var fileName string
var fileBytes []byte
// 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
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 {
localVarHttpHeaderAccepts := []string{
"application/xml",
"application/json",
"application/json",
}
//set Accept header
// 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)
if err != nil {
return *NewAPIResponse(httpResponse.RawResponse), err
}
return *NewAPIResponse(httpResponse.RawResponse), err
}