forked from loafle/openapi-generator-original
Merge pull request #2750 from neilotoole/issue-2748-formatting
Issue #2748 - generated code now conforms more closely to conventions
This commit is contained in:
commit
766c73497d
@ -2,149 +2,121 @@ package {{packageName}}
|
||||
|
||||
{{#operations}}
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
{{#imports}} "{{import}}"
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
{{#imports}}"{{import}}"
|
||||
{{/imports}}
|
||||
)
|
||||
|
||||
type {{classname}} struct {
|
||||
Configuration Configuration
|
||||
Configuration Configuration
|
||||
}
|
||||
|
||||
func New{{classname}}() *{{classname}}{
|
||||
configuration := NewConfiguration()
|
||||
return &{{classname}} {
|
||||
Configuration: *configuration,
|
||||
}
|
||||
func New{{classname}}() *{{classname}} {
|
||||
configuration := NewConfiguration()
|
||||
return &{{classname}}{
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
func New{{classname}}WithBasePath(basePath string) *{{classname}}{
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
func New{{classname}}WithBasePath(basePath string) *{{classname}} {
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
|
||||
return &{{classname}} {
|
||||
Configuration: *configuration,
|
||||
}
|
||||
return &{{classname}}{
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
* {{summary}}{{#notes}}
|
||||
* {{notes}}{{/notes}}
|
||||
*
|
||||
{{#allParams}} * @param {{paramName}} {{description}}
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
*/
|
||||
func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) {
|
||||
func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) {
|
||||
|
||||
var httpMethod = "{{httpMethod}}"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "{{path}}"
|
||||
{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1)
|
||||
{{/pathParams}}
|
||||
var httpMethod = "{{httpMethod}}"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "{{path}}"{{#pathParams}}
|
||||
path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if &{{paramName}} == nil {
|
||||
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
||||
}{{/required}}{{/allParams}}
|
||||
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if &{{paramName}} == nil {
|
||||
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
||||
}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
{{#authMethods}}
|
||||
// authentication ({{name}}) required
|
||||
{{#isApiKey}}{{#isKeyInHeader}}
|
||||
// set key with prefix in header
|
||||
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
|
||||
{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||
// set key with prefix in querystring{{#hasKeyParamName}}
|
||||
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
|
||||
{{/hasKeyParamName}}{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}
|
||||
// http basic authentication required
|
||||
if a.Configuration.Username != "" || a.Configuration.Password != ""{
|
||||
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
|
||||
}{{/isBasic}}{{#isOAuth}}
|
||||
// oauth required
|
||||
if a.Configuration.AccessToken != ""{
|
||||
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
|
||||
}{{/isOAuth}}{{/authMethods}}
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}{{#hasQueryParams}}{{#queryParams}}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
|
||||
{{/queryParams}}{{/hasQueryParams}}
|
||||
|
||||
{{#authMethods}}// authentication ({{name}}) required
|
||||
{{#isApiKey}}{{#isKeyInHeader}}
|
||||
// set key with prefix in header
|
||||
headerParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
|
||||
{{/isKeyInHeader}}{{#isKeyInQuery}}
|
||||
// set key with prefix in querystring
|
||||
{{#hasKeyParamName}}
|
||||
queryParams["{{keyParamName}}"] = a.Configuration.GetAPIKeyWithPrefix("{{keyParamName}}")
|
||||
{{/hasKeyParamName}}
|
||||
{{/isKeyInQuery}}{{/isApiKey}}
|
||||
{{#isBasic}}
|
||||
// http basic authentication required
|
||||
if a.Configuration.Username != "" || a.Configuration.Password != ""{
|
||||
headerParams["Authorization"] = "Basic " + a.Configuration.GetBasicAuthEncodedString()
|
||||
}
|
||||
{{/isBasic}}
|
||||
{{#isOAuth}}
|
||||
// oauth required
|
||||
if a.Configuration.AccessToken != ""{
|
||||
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
|
||||
}
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ {{#consumes}}"{{mediaType}}", {{/consumes}} }
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// 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}} }
|
||||
|
||||
{{#hasQueryParams}}
|
||||
{{#queryParams}}
|
||||
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
|
||||
{{/queryParams}}
|
||||
{{/hasQueryParams}}
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}{{#hasHeaderParams}}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
{{#consumes}}
|
||||
"{{mediaType}}",
|
||||
{{/consumes}}
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
{{#produces}}
|
||||
"{{mediaType}}",
|
||||
{{/produces}}
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
|
||||
headerParams["{{baseName}}"] = {{paramName}}
|
||||
{{/headerParams}}{{/hasHeaderParams}}
|
||||
{{#hasFormParams}}
|
||||
{{#formParams}}
|
||||
{{#isFile}}fbs, _ := ioutil.ReadAll(file)
|
||||
fileBytes = fbs
|
||||
fileName = file.Name()
|
||||
{{/isFile}}
|
||||
{{^isFile}}formParams["{{paramName}}"] = {{paramName}}
|
||||
{{/isFile}}
|
||||
{{/formParams}}
|
||||
{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params
|
||||
postBody = &{{paramName}}
|
||||
{{#headerParams}} // header params "{{baseName}}"
|
||||
headerParams["{{baseName}}"] = {{paramName}}
|
||||
{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}}
|
||||
{{#formParams}}{{#isFile}}
|
||||
fbs, _ := ioutil.ReadAll(file)
|
||||
fileBytes = fbs
|
||||
fileName = file.Name(){{/isFile}}
|
||||
{{^isFile}} formParams["{{paramName}}"] = {{paramName}}{{/isFile}}{{/formParams}}{{/hasFormParams}}{{#hasBodyParam}}
|
||||
{{#bodyParams}} // body params
|
||||
postBody = &{{paramName}}
|
||||
{{/bodyParams}}{{/hasBodyParam}}
|
||||
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
{{#returnType}}
|
||||
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
{{/returnType}}
|
||||
|
||||
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}}
|
||||
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/operation}}{{/operations}}
|
||||
|
@ -1,123 +1,120 @@
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"github.com/go-resty/resty"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/go-resty/resty"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
|
||||
}
|
||||
|
||||
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
||||
if (len(contentTypes) == 0){
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes,"application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
if len(contentTypes) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
}
|
||||
|
||||
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
|
||||
if (len(accepts) == 0){
|
||||
return ""
|
||||
}
|
||||
|
||||
if contains(accepts,"application/json"){
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return strings.Join(accepts,",")
|
||||
if len(accepts) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(accepts, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return strings.Join(accepts, ",")
|
||||
}
|
||||
|
||||
func contains(source []string, containvalue string) bool {
|
||||
for _, a := range source {
|
||||
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
for _, a := range source {
|
||||
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func (c *APIClient) CallAPI(path string, method string,
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) (*resty.Response, error) {
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) (*resty.Response, error) {
|
||||
|
||||
//set debug flag
|
||||
configuration := NewConfiguration()
|
||||
resty.SetDebug(configuration.GetDebug())
|
||||
//set debug flag
|
||||
configuration := NewConfiguration()
|
||||
resty.SetDebug(configuration.GetDebug())
|
||||
|
||||
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
||||
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
switch strings.ToUpper(method) {
|
||||
case "GET":
|
||||
response, err := request.Get(path)
|
||||
return response, err
|
||||
case "POST":
|
||||
response, err := request.Post(path)
|
||||
return response, err
|
||||
case "PUT":
|
||||
response, err := request.Put(path)
|
||||
return response, err
|
||||
case "PATCH":
|
||||
response, err := request.Patch(path)
|
||||
return response, err
|
||||
case "DELETE":
|
||||
response, err := request.Delete(path)
|
||||
return response, err
|
||||
}
|
||||
switch strings.ToUpper(method) {
|
||||
case "GET":
|
||||
response, err := request.Get(path)
|
||||
return response, err
|
||||
case "POST":
|
||||
response, err := request.Post(path)
|
||||
return response, err
|
||||
case "PUT":
|
||||
response, err := request.Put(path)
|
||||
return response, err
|
||||
case "PATCH":
|
||||
response, err := request.Patch(path)
|
||||
return response, err
|
||||
case "DELETE":
|
||||
response, err := request.Delete(path)
|
||||
return response, err
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("invalid method %v", method)
|
||||
return nil, fmt.Errorf("invalid method %v", method)
|
||||
}
|
||||
|
||||
func (c *APIClient) ParameterToString(obj interface{}) string {
|
||||
if reflect.TypeOf(obj).String() == "[]string" {
|
||||
return strings.Join(obj.([]string), ",")
|
||||
} else {
|
||||
return obj.(string)
|
||||
}
|
||||
if reflect.TypeOf(obj).String() == "[]string" {
|
||||
return strings.Join(obj.([]string), ",")
|
||||
} else {
|
||||
return obj.(string)
|
||||
}
|
||||
}
|
||||
|
||||
func prepareRequest(postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) *resty.Request {
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) *resty.Request {
|
||||
|
||||
request := resty.R()
|
||||
request := resty.R()
|
||||
request.SetBody(postBody)
|
||||
|
||||
request.SetBody(postBody)
|
||||
// add header parameter, if any
|
||||
if len(headerParams) > 0 {
|
||||
request.SetHeaders(headerParams)
|
||||
}
|
||||
|
||||
// add header parameter, if any
|
||||
if len(headerParams) > 0 {
|
||||
request.SetHeaders(headerParams)
|
||||
}
|
||||
// add query parameter, if any
|
||||
if len(queryParams) > 0 {
|
||||
request.SetQueryParams(queryParams)
|
||||
}
|
||||
|
||||
// add query parameter, if any
|
||||
if len(queryParams) > 0 {
|
||||
request.SetQueryParams(queryParams)
|
||||
}
|
||||
// add form parameter, if any
|
||||
if len(formParams) > 0 {
|
||||
request.SetFormData(formParams)
|
||||
}
|
||||
|
||||
// add form parameter, if any
|
||||
if len(formParams) > 0 {
|
||||
request.SetFormData(formParams)
|
||||
}
|
||||
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
_, fileNm := filepath.Split(fileName)
|
||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||
}
|
||||
return request
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
_, fileNm := filepath.Split(fileName)
|
||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
@ -1,24 +1,22 @@
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
type APIResponse struct {
|
||||
*http.Response
|
||||
|
||||
Message string `json:"message,omitempty"`
|
||||
*http.Response
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||
response := &APIResponse{Response: r}
|
||||
|
||||
return response
|
||||
response := &APIResponse{Response: r}
|
||||
return response
|
||||
}
|
||||
|
||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||
response := &APIResponse{Message: errorMessage}
|
||||
|
||||
return response
|
||||
response := &APIResponse{Message: errorMessage}
|
||||
return response
|
||||
}
|
@ -1,59 +1,59 @@
|
||||
package {{packageName}}
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"`
|
||||
APIKey map[string] string `json:"APIKey,omitempty"`
|
||||
debug bool `json:"debug,omitempty"`
|
||||
DebugFile string `json:"debugFile,omitempty"`
|
||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
AccessToken string `json:"accessToken,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
APIClient APIClient `json:"APIClient,omitempty"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
||||
APIKey map[string]string `json:"APIKey,omitempty"`
|
||||
debug bool `json:"debug,omitempty"`
|
||||
DebugFile string `json:"debugFile,omitempty"`
|
||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
AccessToken string `json:"accessToken,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
APIClient APIClient `json:"APIClient,omitempty"`
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
return &Configuration{
|
||||
BasePath: "{{basePath}}",
|
||||
UserName: "",
|
||||
debug: false,
|
||||
DefaultHeader: make(map[string]string),
|
||||
APIKey: make(map[string]string),
|
||||
APIKeyPrefix: make(map[string]string),
|
||||
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}",
|
||||
}
|
||||
return &Configuration{
|
||||
BasePath: "{{basePath}}",
|
||||
UserName: "",
|
||||
debug: false,
|
||||
DefaultHeader: make(map[string]string),
|
||||
APIKey: make(map[string]string),
|
||||
APIKeyPrefix: make(map[string]string),
|
||||
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}",
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
||||
|
||||
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
||||
if c.APIKeyPrefix[APIKeyIdentifier] != ""{
|
||||
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||
}
|
||||
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
|
||||
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||
}
|
||||
|
||||
return c.APIKey[APIKeyIdentifier]
|
||||
return c.APIKey[APIKeyIdentifier]
|
||||
}
|
||||
|
||||
func (c *Configuration) SetDebug(enable bool){
|
||||
c.debug = enable
|
||||
func (c *Configuration) SetDebug(enable bool) {
|
||||
c.debug = enable
|
||||
}
|
||||
|
||||
func (c *Configuration) GetDebug() bool {
|
||||
return c.debug
|
||||
return c.debug
|
||||
}
|
@ -1,18 +1,14 @@
|
||||
package {{packageName}}
|
||||
|
||||
{{#models}}
|
||||
import (
|
||||
{{#imports}} "{{import}}"
|
||||
{{/imports}}
|
||||
{{#models}}{{#imports}}
|
||||
import ({{/imports}}{{#imports}}
|
||||
"{{import}}"{{/imports}}{{#imports}}
|
||||
)
|
||||
|
||||
{{#model}}
|
||||
{{#description}}// {{{description}}}{{/description}}
|
||||
{{/imports}}{{#model}}{{#description}}
|
||||
// {{{description}}}{{/description}}
|
||||
type {{classname}} struct {
|
||||
{{#vars}}
|
||||
{{#description}}// {{{description}}}{{/description}}
|
||||
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
|
||||
{{/vars}}
|
||||
{{#vars}}{{#description}}
|
||||
// {{{description}}}{{/description}}
|
||||
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
|
||||
{{/vars}}
|
||||
}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
{{/model}}{{/models}}
|
@ -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
|
||||
|
@ -1,123 +1,120 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"github.com/go-resty/resty"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"bytes"
|
||||
"path/filepath"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/go-resty/resty"
|
||||
)
|
||||
|
||||
type APIClient struct {
|
||||
|
||||
}
|
||||
|
||||
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
||||
if (len(contentTypes) == 0){
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes,"application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
if len(contentTypes) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
}
|
||||
|
||||
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
|
||||
if (len(accepts) == 0){
|
||||
return ""
|
||||
}
|
||||
|
||||
if contains(accepts,"application/json"){
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return strings.Join(accepts,",")
|
||||
if len(accepts) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(accepts, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return strings.Join(accepts, ",")
|
||||
}
|
||||
|
||||
func contains(source []string, containvalue string) bool {
|
||||
for _, a := range source {
|
||||
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
for _, a := range source {
|
||||
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
func (c *APIClient) CallAPI(path string, method string,
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) (*resty.Response, error) {
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) (*resty.Response, error) {
|
||||
|
||||
//set debug flag
|
||||
configuration := NewConfiguration()
|
||||
resty.SetDebug(configuration.GetDebug())
|
||||
//set debug flag
|
||||
configuration := NewConfiguration()
|
||||
resty.SetDebug(configuration.GetDebug())
|
||||
|
||||
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
||||
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
switch strings.ToUpper(method) {
|
||||
case "GET":
|
||||
response, err := request.Get(path)
|
||||
return response, err
|
||||
case "POST":
|
||||
response, err := request.Post(path)
|
||||
return response, err
|
||||
case "PUT":
|
||||
response, err := request.Put(path)
|
||||
return response, err
|
||||
case "PATCH":
|
||||
response, err := request.Patch(path)
|
||||
return response, err
|
||||
case "DELETE":
|
||||
response, err := request.Delete(path)
|
||||
return response, err
|
||||
}
|
||||
switch strings.ToUpper(method) {
|
||||
case "GET":
|
||||
response, err := request.Get(path)
|
||||
return response, err
|
||||
case "POST":
|
||||
response, err := request.Post(path)
|
||||
return response, err
|
||||
case "PUT":
|
||||
response, err := request.Put(path)
|
||||
return response, err
|
||||
case "PATCH":
|
||||
response, err := request.Patch(path)
|
||||
return response, err
|
||||
case "DELETE":
|
||||
response, err := request.Delete(path)
|
||||
return response, err
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("invalid method %v", method)
|
||||
return nil, fmt.Errorf("invalid method %v", method)
|
||||
}
|
||||
|
||||
func (c *APIClient) ParameterToString(obj interface{}) string {
|
||||
if reflect.TypeOf(obj).String() == "[]string" {
|
||||
return strings.Join(obj.([]string), ",")
|
||||
} else {
|
||||
return obj.(string)
|
||||
}
|
||||
if reflect.TypeOf(obj).String() == "[]string" {
|
||||
return strings.Join(obj.([]string), ",")
|
||||
} else {
|
||||
return obj.(string)
|
||||
}
|
||||
}
|
||||
|
||||
func prepareRequest(postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) *resty.Request {
|
||||
headerParams map[string]string,
|
||||
queryParams map[string]string,
|
||||
formParams map[string]string,
|
||||
fileName string,
|
||||
fileBytes []byte) *resty.Request {
|
||||
|
||||
request := resty.R()
|
||||
request := resty.R()
|
||||
request.SetBody(postBody)
|
||||
|
||||
request.SetBody(postBody)
|
||||
// add header parameter, if any
|
||||
if len(headerParams) > 0 {
|
||||
request.SetHeaders(headerParams)
|
||||
}
|
||||
|
||||
// add header parameter, if any
|
||||
if len(headerParams) > 0 {
|
||||
request.SetHeaders(headerParams)
|
||||
}
|
||||
// add query parameter, if any
|
||||
if len(queryParams) > 0 {
|
||||
request.SetQueryParams(queryParams)
|
||||
}
|
||||
|
||||
// add query parameter, if any
|
||||
if len(queryParams) > 0 {
|
||||
request.SetQueryParams(queryParams)
|
||||
}
|
||||
// add form parameter, if any
|
||||
if len(formParams) > 0 {
|
||||
request.SetFormData(formParams)
|
||||
}
|
||||
|
||||
// add form parameter, if any
|
||||
if len(formParams) > 0 {
|
||||
request.SetFormData(formParams)
|
||||
}
|
||||
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
_, fileNm := filepath.Split(fileName)
|
||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||
}
|
||||
return request
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
_, fileNm := filepath.Split(fileName)
|
||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||
}
|
||||
return request
|
||||
}
|
||||
|
@ -1,24 +1,22 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
||||
type APIResponse struct {
|
||||
*http.Response
|
||||
|
||||
Message string `json:"message,omitempty"`
|
||||
*http.Response
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||
response := &APIResponse{Response: r}
|
||||
|
||||
return response
|
||||
response := &APIResponse{Response: r}
|
||||
return response
|
||||
}
|
||||
|
||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||
response := &APIResponse{Message: errorMessage}
|
||||
|
||||
return response
|
||||
response := &APIResponse{Message: errorMessage}
|
||||
return response
|
||||
}
|
@ -1,12 +1,8 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type Category struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
@ -1,59 +1,59 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
type Configuration struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"`
|
||||
APIKey map[string] string `json:"APIKey,omitempty"`
|
||||
debug bool `json:"debug,omitempty"`
|
||||
DebugFile string `json:"debugFile,omitempty"`
|
||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
AccessToken string `json:"accessToken,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
APIClient APIClient `json:"APIClient,omitempty"`
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
||||
APIKey map[string]string `json:"APIKey,omitempty"`
|
||||
debug bool `json:"debug,omitempty"`
|
||||
DebugFile string `json:"debugFile,omitempty"`
|
||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||
Timeout int `json:"timeout,omitempty"`
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
AccessToken string `json:"accessToken,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
APIClient APIClient `json:"APIClient,omitempty"`
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
return &Configuration{
|
||||
BasePath: "http://petstore.swagger.io/v2",
|
||||
UserName: "",
|
||||
debug: false,
|
||||
DefaultHeader: make(map[string]string),
|
||||
APIKey: make(map[string]string),
|
||||
APIKeyPrefix: make(map[string]string),
|
||||
UserAgent: "Swagger-Codegen/1.0.0/go",
|
||||
}
|
||||
return &Configuration{
|
||||
BasePath: "http://petstore.swagger.io/v2",
|
||||
UserName: "",
|
||||
debug: false,
|
||||
DefaultHeader: make(map[string]string),
|
||||
APIKey: make(map[string]string),
|
||||
APIKeyPrefix: make(map[string]string),
|
||||
UserAgent: "Swagger-Codegen/1.0.0/go",
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
||||
|
||||
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
||||
if c.APIKeyPrefix[APIKeyIdentifier] != ""{
|
||||
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||
}
|
||||
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
|
||||
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||
}
|
||||
|
||||
return c.APIKey[APIKeyIdentifier]
|
||||
return c.APIKey[APIKeyIdentifier]
|
||||
}
|
||||
|
||||
func (c *Configuration) SetDebug(enable bool){
|
||||
c.debug = enable
|
||||
func (c *Configuration) SetDebug(enable bool) {
|
||||
c.debug = enable
|
||||
}
|
||||
|
||||
func (c *Configuration) GetDebug() bool {
|
||||
return c.debug
|
||||
return c.debug
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -1,14 +1,10 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type ModelApiResponse struct {
|
||||
|
||||
Code int32 `json:"code,omitempty"`
|
||||
Code int32 `json:"code,omitempty"`
|
||||
|
||||
Type_ string `json:"type,omitempty"`
|
||||
Type_ string `json:"type,omitempty"`
|
||||
|
||||
Message string `json:"message,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"time"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
type Order struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
PetId int64 `json:"petId,omitempty"`
|
||||
PetId int64 `json:"petId,omitempty"`
|
||||
|
||||
Quantity int32 `json:"quantity,omitempty"`
|
||||
Quantity int32 `json:"quantity,omitempty"`
|
||||
|
||||
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||
// Order Status
|
||||
Status string `json:"status,omitempty"`
|
||||
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
// Order Status
|
||||
Status string `json:"status,omitempty"`
|
||||
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
}
|
||||
|
@ -1,20 +1,17 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type Pet struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Category Category `json:"category,omitempty"`
|
||||
Category Category `json:"category,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
// pet status in the store
|
||||
Status string `json:"status,omitempty"`
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
|
||||
// pet status in the store
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,282 +1,264 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type StoreApi struct {
|
||||
Configuration Configuration
|
||||
Configuration Configuration
|
||||
}
|
||||
|
||||
func NewStoreApi() *StoreApi{
|
||||
configuration := NewConfiguration()
|
||||
return &StoreApi {
|
||||
Configuration: *configuration,
|
||||
}
|
||||
func NewStoreApi() *StoreApi {
|
||||
configuration := NewConfiguration()
|
||||
return &StoreApi{
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
func NewStoreApiWithBasePath(basePath string) *StoreApi{
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
func NewStoreApiWithBasePath(basePath string) *StoreApi {
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
|
||||
return &StoreApi {
|
||||
Configuration: *configuration,
|
||||
}
|
||||
return &StoreApi{
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
* @return void
|
||||
*/
|
||||
func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) {
|
||||
func (a StoreApi) DeleteOrder(orderId string) (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Delete"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
||||
var httpMethod = "Delete"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
||||
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if &orderId == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder")
|
||||
}
|
||||
// verify the required parameter 'orderId' is set
|
||||
if &orderId == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @return map[string]int32
|
||||
*/
|
||||
func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) {
|
||||
func (a StoreApi) GetInventory() (map[string]int32, APIResponse, error) {
|
||||
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/inventory"
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/inventory"
|
||||
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
// authentication (api_key) required
|
||||
|
||||
// authentication (api_key) required
|
||||
// set key with prefix in header
|
||||
headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key")
|
||||
|
||||
// set key with prefix in header
|
||||
headerParams["api_key"] = a.Configuration.GetAPIKeyWithPrefix("api_key")
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/json",
|
||||
}
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
|
||||
var successPayload = new(map[string]int32)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
var successPayload = new(map[string]int32)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
*
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @return Order
|
||||
*/
|
||||
func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) {
|
||||
func (a StoreApi) GetOrderById(orderId int64) (Order, APIResponse, error) {
|
||||
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
||||
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if &orderId == nil {
|
||||
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById")
|
||||
}
|
||||
// verify the required parameter 'orderId' is set
|
||||
if &orderId == nil {
|
||||
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
|
||||
var successPayload = new(Order)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
var successPayload = new(Order)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
* @return Order
|
||||
*/
|
||||
func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) {
|
||||
func (a StoreApi) PlaceOrder(body Order) (Order, APIResponse, error) {
|
||||
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/order"
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/store/order"
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder")
|
||||
}
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
postBody = &body
|
||||
|
||||
// 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
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type Tag struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
@ -1,24 +1,21 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
|
||||
type User struct {
|
||||
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
|
||||
Username string `json:"username,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
|
||||
Email string `json:"email,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
|
||||
Password string `json:"password,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
|
||||
Phone string `json:"phone,omitempty"`
|
||||
// User Status
|
||||
UserStatus int32 `json:"userStatus,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
|
||||
// User Status
|
||||
UserStatus int32 `json:"userStatus,omitempty"`
|
||||
}
|
||||
|
@ -1,539 +1,519 @@
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"fmt"
|
||||
"errors"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type UserApi struct {
|
||||
Configuration Configuration
|
||||
Configuration Configuration
|
||||
}
|
||||
|
||||
func NewUserApi() *UserApi{
|
||||
configuration := NewConfiguration()
|
||||
return &UserApi {
|
||||
Configuration: *configuration,
|
||||
}
|
||||
func NewUserApi() *UserApi {
|
||||
configuration := NewConfiguration()
|
||||
return &UserApi{
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
func NewUserApiWithBasePath(basePath string) *UserApi{
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
func NewUserApiWithBasePath(basePath string) *UserApi {
|
||||
configuration := NewConfiguration()
|
||||
configuration.BasePath = basePath
|
||||
|
||||
return &UserApi {
|
||||
Configuration: *configuration,
|
||||
}
|
||||
return &UserApi{
|
||||
Configuration: *configuration,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param body Created user object
|
||||
* @return void
|
||||
*/
|
||||
func (a UserApi) CreateUser (body User) (APIResponse, error) {
|
||||
func (a UserApi) CreateUser(body User) (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user"
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user"
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser")
|
||||
}
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
postBody = &body
|
||||
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
// 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
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param body List of user object
|
||||
* @return void
|
||||
*/
|
||||
func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) {
|
||||
func (a UserApi) CreateUsersWithArrayInput(body []User) (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/createWithArray"
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/createWithArray"
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput")
|
||||
}
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
postBody = &body
|
||||
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
// 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
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param body List of user object
|
||||
* @return void
|
||||
*/
|
||||
func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) {
|
||||
func (a UserApi) CreateUsersWithListInput(body []User) (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/createWithList"
|
||||
var httpMethod = "Post"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/createWithList"
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput")
|
||||
}
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
postBody = &body
|
||||
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
// 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
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username The name that needs to be deleted
|
||||
* @return void
|
||||
*/
|
||||
func (a UserApi) DeleteUser (username string) (APIResponse, error) {
|
||||
func (a UserApi) DeleteUser(username string) (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Delete"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/{username}"
|
||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||
var httpMethod = "Delete"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/{username}"
|
||||
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser")
|
||||
}
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
* @return User
|
||||
*/
|
||||
func (a UserApi) GetUserByName (username string) (User, APIResponse, error) {
|
||||
func (a UserApi) GetUserByName(username string) (User, APIResponse, error) {
|
||||
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/{username}"
|
||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/{username}"
|
||||
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName")
|
||||
}
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
|
||||
var successPayload = new(User)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
var successPayload = new(User)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
* @param username The user name for login
|
||||
* @param password The password for login in clear text
|
||||
* @return string
|
||||
*/
|
||||
func (a UserApi) LoginUser (username string, password string) (string, APIResponse, error) {
|
||||
func (a UserApi) LoginUser(username string, password string) (string, APIResponse, error) {
|
||||
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/login"
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/login"
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser")
|
||||
}
|
||||
// verify the required parameter 'password' is set
|
||||
if &password == nil {
|
||||
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser")
|
||||
}
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser")
|
||||
}
|
||||
// verify the required parameter 'password' is set
|
||||
if &password == nil {
|
||||
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
queryParams["username"] = a.Configuration.APIClient.ParameterToString(username)
|
||||
|
||||
|
||||
// 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
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
queryParams["password"] = a.Configuration.APIClient.ParameterToString(password)
|
||||
|
||||
|
||||
var successPayload = new(string)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
var successPayload = new(string)
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
func (a UserApi) LogoutUser () (APIResponse, error) {
|
||||
func (a UserApi) LogoutUser() (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/logout"
|
||||
var httpMethod = "Get"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/logout"
|
||||
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username name that need to be deleted
|
||||
* @param body Updated user object
|
||||
* @return void
|
||||
*/
|
||||
func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) {
|
||||
func (a UserApi) UpdateUser(username string, body User) (APIResponse, error) {
|
||||
|
||||
var httpMethod = "Put"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/{username}"
|
||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||
var httpMethod = "Put"
|
||||
// create path and map variables
|
||||
path := a.Configuration.BasePath + "/user/{username}"
|
||||
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser")
|
||||
}
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser")
|
||||
}
|
||||
// verify the required parameter 'username' is set
|
||||
if &username == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser")
|
||||
}
|
||||
// verify the required parameter 'body' is set
|
||||
if &body == nil {
|
||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser")
|
||||
}
|
||||
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
headerParams := make(map[string]string)
|
||||
queryParams := make(map[string]string)
|
||||
formParams := make(map[string]string)
|
||||
var postBody interface{}
|
||||
var fileName string
|
||||
var fileBytes []byte
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{ }
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
postBody = &body
|
||||
|
||||
|
||||
// add default headers if any
|
||||
for key := range a.Configuration.DefaultHeader {
|
||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||
}
|
||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||
if err != nil {
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string {
|
||||
}
|
||||
//set Content-Type header
|
||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
headerParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string {
|
||||
"application/xml",
|
||||
"application/json",
|
||||
}
|
||||
//set Accept header
|
||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
|
||||
// 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
|
||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user