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}}
|
{{#operations}}
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"errors"
|
"errors"
|
||||||
{{#imports}} "{{import}}"
|
{{#imports}}"{{import}}"
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
)
|
)
|
||||||
|
|
||||||
type {{classname}} struct {
|
type {{classname}} struct {
|
||||||
Configuration Configuration
|
Configuration Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
func New{{classname}}() *{{classname}}{
|
func New{{classname}}() *{{classname}} {
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
return &{{classname}} {
|
return &{{classname}}{
|
||||||
Configuration: *configuration,
|
Configuration: *configuration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func New{{classname}}WithBasePath(basePath string) *{{classname}}{
|
func New{{classname}}WithBasePath(basePath string) *{{classname}} {
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
configuration.BasePath = basePath
|
configuration.BasePath = basePath
|
||||||
|
|
||||||
return &{{classname}} {
|
|
||||||
Configuration: *configuration,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return &{{classname}}{
|
||||||
|
Configuration: *configuration,
|
||||||
|
}
|
||||||
|
}
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {{summary}}
|
* {{summary}}{{#notes}}
|
||||||
* {{notes}}
|
* {{notes}}{{/notes}}
|
||||||
|
*
|
||||||
{{#allParams}} * @param {{paramName}} {{description}}
|
{{#allParams}} * @param {{paramName}} {{description}}
|
||||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||||
*/
|
*/
|
||||||
func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) {
|
func (a {{classname}}) {{nickname}}({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "{{httpMethod}}"
|
var httpMethod = "{{httpMethod}}"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "{{path}}"
|
path := a.Configuration.BasePath + "{{path}}"{{#pathParams}}
|
||||||
{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1)
|
path = strings.Replace(path, "{"+"{{baseName}}"+"}", fmt.Sprintf("%v", {{paramName}}), -1){{/pathParams}}
|
||||||
{{/pathParams}}
|
{{#allParams}}{{#required}}
|
||||||
|
// 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}}
|
headerParams := make(map[string]string)
|
||||||
{{#required}}
|
queryParams := make(map[string]string)
|
||||||
// verify the required parameter '{{paramName}}' is set
|
formParams := make(map[string]string)
|
||||||
if &{{paramName}} == nil {
|
var postBody interface{}
|
||||||
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
var fileName string
|
||||||
}
|
var fileBytes []byte
|
||||||
{{/required}}
|
{{#authMethods}}
|
||||||
{{/allParams}}
|
// 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["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
|
||||||
queryParams := make(map[string]string)
|
{{/queryParams}}{{/hasQueryParams}}
|
||||||
formParams := make(map[string]string)
|
|
||||||
var postBody interface{}
|
|
||||||
var fileName string
|
|
||||||
var fileBytes []byte
|
|
||||||
|
|
||||||
{{#authMethods}}// authentication ({{name}}) required
|
// to determine the Content-Type header
|
||||||
{{#isApiKey}}{{#isKeyInHeader}}
|
localVarHttpContentTypes := []string{ {{#consumes}}"{{mediaType}}", {{/consumes}} }
|
||||||
// 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
|
// set Content-Type header
|
||||||
for key := range a.Configuration.DefaultHeader {
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
if localVarHttpContentType != "" {
|
||||||
}
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
{{#hasQueryParams}}
|
// to determine the Accept header
|
||||||
{{#queryParams}}
|
localVarHttpHeaderAccepts := []string{
|
||||||
queryParams["{{paramName}}"] = a.Configuration.APIClient.ParameterToString({{paramName}})
|
{{#produces}}"{{mediaType}}",
|
||||||
{{/queryParams}}
|
{{/produces}} }
|
||||||
{{/hasQueryParams}}
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// set Accept header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
{{#consumes}}
|
if localVarHttpHeaderAccept != "" {
|
||||||
"{{mediaType}}",
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
{{/consumes}}
|
}{{#hasHeaderParams}}
|
||||||
}
|
|
||||||
//set Content-Type header
|
{{#headerParams}} // header params "{{baseName}}"
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
headerParams["{{baseName}}"] = {{paramName}}
|
||||||
if localVarHttpContentType != "" {
|
{{/headerParams}}{{/hasHeaderParams}}{{#hasFormParams}}
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
{{#formParams}}{{#isFile}}
|
||||||
}
|
fbs, _ := ioutil.ReadAll(file)
|
||||||
// to determine the Accept header
|
fileBytes = fbs
|
||||||
localVarHttpHeaderAccepts := []string {
|
fileName = file.Name(){{/isFile}}
|
||||||
{{#produces}}
|
{{^isFile}} formParams["{{paramName}}"] = {{paramName}}{{/isFile}}{{/formParams}}{{/hasFormParams}}{{#hasBodyParam}}
|
||||||
"{{mediaType}}",
|
{{#bodyParams}} // body params
|
||||||
{{/produces}}
|
postBody = &{{paramName}}
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
|
|
||||||
headerParams["{{baseName}}"] = {{paramName}}
|
|
||||||
{{/headerParams}}{{/hasHeaderParams}}
|
|
||||||
{{#hasFormParams}}
|
|
||||||
{{#formParams}}
|
|
||||||
{{#isFile}}fbs, _ := ioutil.ReadAll(file)
|
|
||||||
fileBytes = fbs
|
|
||||||
fileName = file.Name()
|
|
||||||
{{/isFile}}
|
|
||||||
{{^isFile}}formParams["{{paramName}}"] = {{paramName}}
|
|
||||||
{{/isFile}}
|
|
||||||
{{/formParams}}
|
|
||||||
{{/hasFormParams}}{{#hasBodyParam}}{{#bodyParams}} // body params
|
|
||||||
postBody = &{{paramName}}
|
|
||||||
{{/bodyParams}}{{/hasBodyParam}}
|
{{/bodyParams}}{{/hasBodyParam}}
|
||||||
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
|
{{#returnType}} var successPayload = new({{returnType}}){{/returnType}}
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
}
|
||||||
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
|
err = json.Unmarshal(httpResponse.Body(), &successPayload){{/returnType}}
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
||||||
{{/returnType}}
|
|
||||||
|
|
||||||
return {{#returnType}}*successPayload, {{/returnType}}*NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}{{/operations}}
|
||||||
{{/operations}}
|
|
||||||
|
@ -1,123 +1,120 @@
|
|||||||
package {{packageName}}
|
package {{packageName}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"bytes"
|
||||||
"github.com/go-resty/resty"
|
"fmt"
|
||||||
"fmt"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"bytes"
|
"strings"
|
||||||
"path/filepath"
|
|
||||||
|
"github.com/go-resty/resty"
|
||||||
)
|
)
|
||||||
|
|
||||||
type APIClient struct {
|
type APIClient struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
||||||
if (len(contentTypes) == 0){
|
|
||||||
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 {
|
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
|
||||||
if (len(accepts) == 0){
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if contains(accepts,"application/json"){
|
if len(accepts) == 0 {
|
||||||
return "application/json"
|
return ""
|
||||||
}
|
}
|
||||||
|
if contains(accepts, "application/json") {
|
||||||
return strings.Join(accepts,",")
|
return "application/json"
|
||||||
|
}
|
||||||
|
return strings.Join(accepts, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
func contains(source []string, containvalue string) bool {
|
func contains(source []string, containvalue string) bool {
|
||||||
for _, a := range source {
|
for _, a := range source {
|
||||||
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *APIClient) CallAPI(path string, method string,
|
func (c *APIClient) CallAPI(path string, method string,
|
||||||
postBody interface{},
|
postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
formParams map[string]string,
|
formParams map[string]string,
|
||||||
fileName string,
|
fileName string,
|
||||||
fileBytes []byte) (*resty.Response, error) {
|
fileBytes []byte) (*resty.Response, error) {
|
||||||
|
|
||||||
//set debug flag
|
//set debug flag
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
resty.SetDebug(configuration.GetDebug())
|
resty.SetDebug(configuration.GetDebug())
|
||||||
|
|
||||||
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
|
||||||
switch strings.ToUpper(method) {
|
switch strings.ToUpper(method) {
|
||||||
case "GET":
|
case "GET":
|
||||||
response, err := request.Get(path)
|
response, err := request.Get(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "POST":
|
case "POST":
|
||||||
response, err := request.Post(path)
|
response, err := request.Post(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "PUT":
|
case "PUT":
|
||||||
response, err := request.Put(path)
|
response, err := request.Put(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "PATCH":
|
case "PATCH":
|
||||||
response, err := request.Patch(path)
|
response, err := request.Patch(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
response, err := request.Delete(path)
|
response, err := request.Delete(path)
|
||||||
return response, err
|
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 {
|
func (c *APIClient) ParameterToString(obj interface{}) string {
|
||||||
if reflect.TypeOf(obj).String() == "[]string" {
|
if reflect.TypeOf(obj).String() == "[]string" {
|
||||||
return strings.Join(obj.([]string), ",")
|
return strings.Join(obj.([]string), ",")
|
||||||
} else {
|
} else {
|
||||||
return obj.(string)
|
return obj.(string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareRequest(postBody interface{},
|
func prepareRequest(postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
formParams map[string]string,
|
formParams map[string]string,
|
||||||
fileName string,
|
fileName string,
|
||||||
fileBytes []byte) *resty.Request {
|
fileBytes []byte) *resty.Request {
|
||||||
|
|
||||||
request := resty.R()
|
request := resty.R()
|
||||||
|
request.SetBody(postBody)
|
||||||
|
|
||||||
request.SetBody(postBody)
|
// add header parameter, if any
|
||||||
|
if len(headerParams) > 0 {
|
||||||
|
request.SetHeaders(headerParams)
|
||||||
|
}
|
||||||
|
|
||||||
// add header parameter, if any
|
// add query parameter, if any
|
||||||
if len(headerParams) > 0 {
|
if len(queryParams) > 0 {
|
||||||
request.SetHeaders(headerParams)
|
request.SetQueryParams(queryParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add query parameter, if any
|
|
||||||
if len(queryParams) > 0 {
|
|
||||||
request.SetQueryParams(queryParams)
|
|
||||||
}
|
|
||||||
|
|
||||||
// add form parameter, if any
|
// add form parameter, if any
|
||||||
if len(formParams) > 0 {
|
if len(formParams) > 0 {
|
||||||
request.SetFormData(formParams)
|
request.SetFormData(formParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(fileBytes) > 0 && fileName != "" {
|
if len(fileBytes) > 0 && fileName != "" {
|
||||||
_, fileNm := filepath.Split(fileName)
|
_, fileNm := filepath.Split(fileName)
|
||||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||||
}
|
}
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
package {{packageName}}
|
package {{packageName}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type APIResponse struct {
|
type APIResponse struct {
|
||||||
*http.Response
|
*http.Response
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
Message string `json:"message,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||||
response := &APIResponse{Response: r}
|
|
||||||
|
|
||||||
return response
|
response := &APIResponse{Response: r}
|
||||||
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||||
response := &APIResponse{Message: errorMessage}
|
|
||||||
|
|
||||||
return response
|
response := &APIResponse{Message: errorMessage}
|
||||||
}
|
return response
|
||||||
|
}
|
||||||
|
@ -1,59 +1,59 @@
|
|||||||
package {{packageName}}
|
package {{packageName}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
UserName string `json:"userName,omitempty"`
|
UserName string `json:"userName,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"`
|
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
||||||
APIKey map[string] string `json:"APIKey,omitempty"`
|
APIKey map[string]string `json:"APIKey,omitempty"`
|
||||||
debug bool `json:"debug,omitempty"`
|
debug bool `json:"debug,omitempty"`
|
||||||
DebugFile string `json:"debugFile,omitempty"`
|
DebugFile string `json:"debugFile,omitempty"`
|
||||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||||
Timeout int `json:"timeout,omitempty"`
|
Timeout int `json:"timeout,omitempty"`
|
||||||
BasePath string `json:"basePath,omitempty"`
|
BasePath string `json:"basePath,omitempty"`
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
Scheme string `json:"scheme,omitempty"`
|
Scheme string `json:"scheme,omitempty"`
|
||||||
AccessToken string `json:"accessToken,omitempty"`
|
AccessToken string `json:"accessToken,omitempty"`
|
||||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||||
UserAgent string `json:"userAgent,omitempty"`
|
UserAgent string `json:"userAgent,omitempty"`
|
||||||
APIClient APIClient `json:"APIClient,omitempty"`
|
APIClient APIClient `json:"APIClient,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfiguration() *Configuration {
|
func NewConfiguration() *Configuration {
|
||||||
return &Configuration{
|
return &Configuration{
|
||||||
BasePath: "{{basePath}}",
|
BasePath: "{{basePath}}",
|
||||||
UserName: "",
|
UserName: "",
|
||||||
debug: false,
|
debug: false,
|
||||||
DefaultHeader: make(map[string]string),
|
DefaultHeader: make(map[string]string),
|
||||||
APIKey: make(map[string]string),
|
APIKey: make(map[string]string),
|
||||||
APIKeyPrefix: make(map[string]string),
|
APIKeyPrefix: make(map[string]string),
|
||||||
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}",
|
UserAgent: "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/go{{/httpUserAgent}}",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
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) {
|
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||||
c.DefaultHeader[key] = value
|
c.DefaultHeader[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
||||||
if c.APIKeyPrefix[APIKeyIdentifier] != ""{
|
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
|
||||||
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.APIKey[APIKeyIdentifier]
|
return c.APIKey[APIKeyIdentifier]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) SetDebug(enable bool){
|
func (c *Configuration) SetDebug(enable bool) {
|
||||||
c.debug = enable
|
c.debug = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) GetDebug() bool {
|
func (c *Configuration) GetDebug() bool {
|
||||||
return c.debug
|
return c.debug
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
package {{packageName}}
|
package {{packageName}}
|
||||||
|
{{#models}}{{#imports}}
|
||||||
{{#models}}
|
import ({{/imports}}{{#imports}}
|
||||||
import (
|
"{{import}}"{{/imports}}{{#imports}}
|
||||||
{{#imports}} "{{import}}"
|
|
||||||
{{/imports}}
|
|
||||||
)
|
)
|
||||||
|
{{/imports}}{{#model}}{{#description}}
|
||||||
{{#model}}
|
// {{{description}}}{{/description}}
|
||||||
{{#description}}// {{{description}}}{{/description}}
|
|
||||||
type {{classname}} struct {
|
type {{classname}} struct {
|
||||||
{{#vars}}
|
{{#vars}}{{#description}}
|
||||||
{{#description}}// {{{description}}}{{/description}}
|
// {{{description}}}{{/description}}
|
||||||
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
|
{{name}} {{{datatype}}} `json:"{{baseName}},omitempty"`
|
||||||
{{/vars}}
|
{{/vars}}
|
||||||
}
|
}
|
||||||
{{/model}}
|
{{/model}}{{/models}}
|
||||||
{{/models}}
|
|
@ -7,7 +7,7 @@ This API client was generated by the [swagger-codegen](https://github.com/swagge
|
|||||||
|
|
||||||
- API version: 1.0.0
|
- API version: 1.0.0
|
||||||
- Package version: 1.0.0
|
- Package version: 1.0.0
|
||||||
- Build date: 2016-04-27T21:14:49.805-07:00
|
- Build date: 2016-05-02T15:51:26.331+01:00
|
||||||
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -1,123 +1,120 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"bytes"
|
||||||
"github.com/go-resty/resty"
|
"fmt"
|
||||||
"fmt"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"bytes"
|
"strings"
|
||||||
"path/filepath"
|
|
||||||
|
"github.com/go-resty/resty"
|
||||||
)
|
)
|
||||||
|
|
||||||
type APIClient struct {
|
type APIClient struct {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
func (c *APIClient) SelectHeaderContentType(contentTypes []string) string {
|
||||||
if (len(contentTypes) == 0){
|
|
||||||
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 {
|
func (c *APIClient) SelectHeaderAccept(accepts []string) string {
|
||||||
if (len(accepts) == 0){
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if contains(accepts,"application/json"){
|
if len(accepts) == 0 {
|
||||||
return "application/json"
|
return ""
|
||||||
}
|
}
|
||||||
|
if contains(accepts, "application/json") {
|
||||||
return strings.Join(accepts,",")
|
return "application/json"
|
||||||
|
}
|
||||||
|
return strings.Join(accepts, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
func contains(source []string, containvalue string) bool {
|
func contains(source []string, containvalue string) bool {
|
||||||
for _, a := range source {
|
for _, a := range source {
|
||||||
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
if strings.ToLower(a) == strings.ToLower(containvalue) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *APIClient) CallAPI(path string, method string,
|
func (c *APIClient) CallAPI(path string, method string,
|
||||||
postBody interface{},
|
postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
formParams map[string]string,
|
formParams map[string]string,
|
||||||
fileName string,
|
fileName string,
|
||||||
fileBytes []byte) (*resty.Response, error) {
|
fileBytes []byte) (*resty.Response, error) {
|
||||||
|
|
||||||
//set debug flag
|
//set debug flag
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
resty.SetDebug(configuration.GetDebug())
|
resty.SetDebug(configuration.GetDebug())
|
||||||
|
|
||||||
request := prepareRequest(postBody, headerParams, queryParams, formParams,fileName,fileBytes)
|
request := prepareRequest(postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
|
||||||
switch strings.ToUpper(method) {
|
switch strings.ToUpper(method) {
|
||||||
case "GET":
|
case "GET":
|
||||||
response, err := request.Get(path)
|
response, err := request.Get(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "POST":
|
case "POST":
|
||||||
response, err := request.Post(path)
|
response, err := request.Post(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "PUT":
|
case "PUT":
|
||||||
response, err := request.Put(path)
|
response, err := request.Put(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "PATCH":
|
case "PATCH":
|
||||||
response, err := request.Patch(path)
|
response, err := request.Patch(path)
|
||||||
return response, err
|
return response, err
|
||||||
case "DELETE":
|
case "DELETE":
|
||||||
response, err := request.Delete(path)
|
response, err := request.Delete(path)
|
||||||
return response, err
|
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 {
|
func (c *APIClient) ParameterToString(obj interface{}) string {
|
||||||
if reflect.TypeOf(obj).String() == "[]string" {
|
if reflect.TypeOf(obj).String() == "[]string" {
|
||||||
return strings.Join(obj.([]string), ",")
|
return strings.Join(obj.([]string), ",")
|
||||||
} else {
|
} else {
|
||||||
return obj.(string)
|
return obj.(string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareRequest(postBody interface{},
|
func prepareRequest(postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
formParams map[string]string,
|
formParams map[string]string,
|
||||||
fileName string,
|
fileName string,
|
||||||
fileBytes []byte) *resty.Request {
|
fileBytes []byte) *resty.Request {
|
||||||
|
|
||||||
request := resty.R()
|
request := resty.R()
|
||||||
|
request.SetBody(postBody)
|
||||||
|
|
||||||
request.SetBody(postBody)
|
// add header parameter, if any
|
||||||
|
if len(headerParams) > 0 {
|
||||||
|
request.SetHeaders(headerParams)
|
||||||
|
}
|
||||||
|
|
||||||
// add header parameter, if any
|
// add query parameter, if any
|
||||||
if len(headerParams) > 0 {
|
if len(queryParams) > 0 {
|
||||||
request.SetHeaders(headerParams)
|
request.SetQueryParams(queryParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add query parameter, if any
|
|
||||||
if len(queryParams) > 0 {
|
|
||||||
request.SetQueryParams(queryParams)
|
|
||||||
}
|
|
||||||
|
|
||||||
// add form parameter, if any
|
// add form parameter, if any
|
||||||
if len(formParams) > 0 {
|
if len(formParams) > 0 {
|
||||||
request.SetFormData(formParams)
|
request.SetFormData(formParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(fileBytes) > 0 && fileName != "" {
|
if len(fileBytes) > 0 && fileName != "" {
|
||||||
_, fileNm := filepath.Split(fileName)
|
_, fileNm := filepath.Split(fileName)
|
||||||
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
request.SetFileReader("file", fileNm, bytes.NewReader(fileBytes))
|
||||||
}
|
}
|
||||||
return request
|
return request
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,22 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type APIResponse struct {
|
type APIResponse struct {
|
||||||
*http.Response
|
*http.Response
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
Message string `json:"message,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPIResponse(r *http.Response) *APIResponse {
|
func NewAPIResponse(r *http.Response) *APIResponse {
|
||||||
response := &APIResponse{Response: r}
|
|
||||||
|
|
||||||
return response
|
response := &APIResponse{Response: r}
|
||||||
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
func NewAPIResponseWithError(errorMessage string) *APIResponse {
|
||||||
response := &APIResponse{Message: errorMessage}
|
|
||||||
|
|
||||||
return response
|
response := &APIResponse{Message: errorMessage}
|
||||||
}
|
return response
|
||||||
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
type Category struct {
|
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
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
UserName string `json:"userName,omitempty"`
|
UserName string `json:"userName,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
APIKeyPrefix map[string] string `json:"APIKeyPrefix,omitempty"`
|
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
||||||
APIKey map[string] string `json:"APIKey,omitempty"`
|
APIKey map[string]string `json:"APIKey,omitempty"`
|
||||||
debug bool `json:"debug,omitempty"`
|
debug bool `json:"debug,omitempty"`
|
||||||
DebugFile string `json:"debugFile,omitempty"`
|
DebugFile string `json:"debugFile,omitempty"`
|
||||||
OAuthToken string `json:"oAuthToken,omitempty"`
|
OAuthToken string `json:"oAuthToken,omitempty"`
|
||||||
Timeout int `json:"timeout,omitempty"`
|
Timeout int `json:"timeout,omitempty"`
|
||||||
BasePath string `json:"basePath,omitempty"`
|
BasePath string `json:"basePath,omitempty"`
|
||||||
Host string `json:"host,omitempty"`
|
Host string `json:"host,omitempty"`
|
||||||
Scheme string `json:"scheme,omitempty"`
|
Scheme string `json:"scheme,omitempty"`
|
||||||
AccessToken string `json:"accessToken,omitempty"`
|
AccessToken string `json:"accessToken,omitempty"`
|
||||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||||
UserAgent string `json:"userAgent,omitempty"`
|
UserAgent string `json:"userAgent,omitempty"`
|
||||||
APIClient APIClient `json:"APIClient,omitempty"`
|
APIClient APIClient `json:"APIClient,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfiguration() *Configuration {
|
func NewConfiguration() *Configuration {
|
||||||
return &Configuration{
|
return &Configuration{
|
||||||
BasePath: "http://petstore.swagger.io/v2",
|
BasePath: "http://petstore.swagger.io/v2",
|
||||||
UserName: "",
|
UserName: "",
|
||||||
debug: false,
|
debug: false,
|
||||||
DefaultHeader: make(map[string]string),
|
DefaultHeader: make(map[string]string),
|
||||||
APIKey: make(map[string]string),
|
APIKey: make(map[string]string),
|
||||||
APIKeyPrefix: make(map[string]string),
|
APIKeyPrefix: make(map[string]string),
|
||||||
UserAgent: "Swagger-Codegen/1.0.0/go",
|
UserAgent: "Swagger-Codegen/1.0.0/go",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) GetBasicAuthEncodedString() string {
|
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) {
|
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||||
c.DefaultHeader[key] = value
|
c.DefaultHeader[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
||||||
if c.APIKeyPrefix[APIKeyIdentifier] != ""{
|
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
|
||||||
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.APIKey[APIKeyIdentifier]
|
return c.APIKey[APIKeyIdentifier]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) SetDebug(enable bool){
|
func (c *Configuration) SetDebug(enable bool) {
|
||||||
c.debug = enable
|
c.debug = enable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Configuration) GetDebug() bool {
|
func (c *Configuration) GetDebug() bool {
|
||||||
return c.debug
|
return c.debug
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@ git_repo_id=$2
|
|||||||
release_note=$3
|
release_note=$3
|
||||||
|
|
||||||
if [ "$git_user_id" = "" ]; then
|
if [ "$git_user_id" = "" ]; then
|
||||||
git_user_id="YOUR_GIT_USR_ID"
|
git_user_id="GIT_USER_ID"
|
||||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$git_repo_id" = "" ]; then
|
if [ "$git_repo_id" = "" ]; then
|
||||||
git_repo_id="YOUR_GIT_REPO_ID"
|
git_repo_id="GIT_REPO_ID"
|
||||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
type ModelApiResponse struct {
|
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
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type Order struct {
|
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"`
|
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||||
// Order Status
|
|
||||||
Status string `json:"status,omitempty"`
|
// Order Status
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
Complete bool `json:"complete,omitempty"`
|
|
||||||
|
Complete bool `json:"complete,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
type Pet struct {
|
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"`
|
Tags []Tag `json:"tags,omitempty"`
|
||||||
// pet status in the store
|
|
||||||
Status string `json:"status,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
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"errors"
|
"errors"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StoreApi struct {
|
type StoreApi struct {
|
||||||
Configuration Configuration
|
Configuration Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStoreApi() *StoreApi{
|
func NewStoreApi() *StoreApi {
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
return &StoreApi {
|
return &StoreApi{
|
||||||
Configuration: *configuration,
|
Configuration: *configuration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStoreApiWithBasePath(basePath string) *StoreApi{
|
func NewStoreApiWithBasePath(basePath string) *StoreApi {
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
configuration.BasePath = basePath
|
configuration.BasePath = basePath
|
||||||
|
|
||||||
return &StoreApi {
|
return &StoreApi{
|
||||||
Configuration: *configuration,
|
Configuration: *configuration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
*
|
||||||
* @param orderId ID of the order that needs to be deleted
|
* @param orderId ID of the order that needs to be deleted
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a StoreApi) DeleteOrder (orderId string) (APIResponse, error) {
|
func (a StoreApi) DeleteOrder(orderId string) (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Delete"
|
var httpMethod = "Delete"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
||||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
|
||||||
|
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if &orderId == nil {
|
if &orderId == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->DeleteOrder")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
|
||||||
if localVarHttpContentType != "" {
|
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
|
||||||
}
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHttpHeaderAccepts := []string {
|
|
||||||
"application/xml",
|
|
||||||
"application/json",
|
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns pet inventories by status
|
* Returns pet inventories by status
|
||||||
* Returns a map of status codes to quantities
|
* Returns a map of status codes to quantities
|
||||||
|
*
|
||||||
* @return map[string]int32
|
* @return map[string]int32
|
||||||
*/
|
*/
|
||||||
func (a StoreApi) GetInventory () (map[string]int32, APIResponse, error) {
|
func (a StoreApi) GetInventory() (map[string]int32, APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Get"
|
var httpMethod = "Get"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/store/inventory"
|
path := a.Configuration.BasePath + "/store/inventory"
|
||||||
|
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
// authentication (api_key) required
|
||||||
|
|
||||||
// authentication (api_key) required
|
// set key with prefix in header
|
||||||
|
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
|
// add default headers if any
|
||||||
for key := range a.Configuration.DefaultHeader {
|
for key := range a.Configuration.DefaultHeader {
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
|
||||||
if localVarHttpContentType != "" {
|
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
|
||||||
}
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHttpHeaderAccepts := []string {
|
|
||||||
"application/json",
|
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
var successPayload = new(map[string]int32)
|
// set Accept header
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
if err != nil {
|
}
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
var successPayload = new(map[string]int32)
|
||||||
}
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
*
|
||||||
* @param orderId ID of pet that needs to be fetched
|
* @param orderId ID of pet that needs to be fetched
|
||||||
* @return Order
|
* @return Order
|
||||||
*/
|
*/
|
||||||
func (a StoreApi) GetOrderById (orderId int64) (Order, APIResponse, error) {
|
func (a StoreApi) GetOrderById(orderId int64) (Order, APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Get"
|
var httpMethod = "Get"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
path := a.Configuration.BasePath + "/store/order/{orderId}"
|
||||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
path = strings.Replace(path, "{"+"orderId"+"}", fmt.Sprintf("%v", orderId), -1)
|
||||||
|
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if &orderId == nil {
|
if &orderId == nil {
|
||||||
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById")
|
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'orderId' when calling StoreApi->GetOrderById")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
|
||||||
if localVarHttpContentType != "" {
|
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
|
||||||
}
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHttpHeaderAccepts := []string {
|
|
||||||
"application/xml",
|
|
||||||
"application/json",
|
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
var successPayload = new(Order)
|
// set Accept header
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
if err != nil {
|
}
|
||||||
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 {
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param body order placed for purchasing the pet
|
* @param body order placed for purchasing the pet
|
||||||
* @return Order
|
* @return Order
|
||||||
*/
|
*/
|
||||||
func (a StoreApi) PlaceOrder (body Order) (Order, APIResponse, error) {
|
func (a StoreApi) PlaceOrder(body Order) (Order, APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Post"
|
var httpMethod = "Post"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/store/order"
|
path := a.Configuration.BasePath + "/store/order"
|
||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder")
|
return *new(Order), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling StoreApi->PlaceOrder")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
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
|
// set Content-Type header
|
||||||
postBody = &body
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
var successPayload = new(Order)
|
// set Accept header
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
// body params
|
||||||
|
postBody = &body
|
||||||
|
|
||||||
|
var successPayload = new(Order)
|
||||||
if err != nil {
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
if err != nil {
|
||||||
}
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
type Tag struct {
|
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
|
package petstore
|
||||||
|
|
||||||
import (
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
type User struct {
|
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"`
|
Phone string `json:"phone,omitempty"`
|
||||||
// User Status
|
|
||||||
UserStatus int32 `json:"userStatus,omitempty"`
|
// User Status
|
||||||
|
UserStatus int32 `json:"userStatus,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -1,539 +1,519 @@
|
|||||||
package petstore
|
package petstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"errors"
|
"errors"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserApi struct {
|
type UserApi struct {
|
||||||
Configuration Configuration
|
Configuration Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserApi() *UserApi{
|
func NewUserApi() *UserApi {
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
return &UserApi {
|
return &UserApi{
|
||||||
Configuration: *configuration,
|
Configuration: *configuration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserApiWithBasePath(basePath string) *UserApi{
|
func NewUserApiWithBasePath(basePath string) *UserApi {
|
||||||
configuration := NewConfiguration()
|
configuration := NewConfiguration()
|
||||||
configuration.BasePath = basePath
|
configuration.BasePath = basePath
|
||||||
|
|
||||||
return &UserApi {
|
return &UserApi{
|
||||||
Configuration: *configuration,
|
Configuration: *configuration,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create user
|
* Create user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
* @param body Created user object
|
* @param body Created user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a UserApi) CreateUser (body User) (APIResponse, error) {
|
func (a UserApi) CreateUser(body User) (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Post"
|
var httpMethod = "Post"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user"
|
path := a.Configuration.BasePath + "/user"
|
||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUser")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
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
|
// set Content-Type header
|
||||||
postBody = &body
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
// body params
|
||||||
|
postBody = &body
|
||||||
|
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param body List of user object
|
* @param body List of user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a UserApi) CreateUsersWithArrayInput (body []User) (APIResponse, error) {
|
func (a UserApi) CreateUsersWithArrayInput(body []User) (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Post"
|
var httpMethod = "Post"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/createWithArray"
|
path := a.Configuration.BasePath + "/user/createWithArray"
|
||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithArrayInput")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
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
|
// set Content-Type header
|
||||||
postBody = &body
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
// body params
|
||||||
|
postBody = &body
|
||||||
|
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param body List of user object
|
* @param body List of user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a UserApi) CreateUsersWithListInput (body []User) (APIResponse, error) {
|
func (a UserApi) CreateUsersWithListInput(body []User) (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Post"
|
var httpMethod = "Post"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/createWithList"
|
path := a.Configuration.BasePath + "/user/createWithList"
|
||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->CreateUsersWithListInput")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
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
|
// set Content-Type header
|
||||||
postBody = &body
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
// body params
|
||||||
|
postBody = &body
|
||||||
|
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete user
|
* Delete user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
* @param username The name that needs to be deleted
|
* @param username The name that needs to be deleted
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a UserApi) DeleteUser (username string) (APIResponse, error) {
|
func (a UserApi) DeleteUser(username string) (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Delete"
|
var httpMethod = "Delete"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/{username}"
|
path := a.Configuration.BasePath + "/user/{username}"
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->DeleteUser")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
|
||||||
if localVarHttpContentType != "" {
|
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
|
||||||
}
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHttpHeaderAccepts := []string {
|
|
||||||
"application/xml",
|
|
||||||
"application/json",
|
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user by user name
|
* Get user by user name
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
func (a UserApi) GetUserByName (username string) (User, APIResponse, error) {
|
func (a UserApi) GetUserByName(username string) (User, APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Get"
|
var httpMethod = "Get"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/{username}"
|
path := a.Configuration.BasePath + "/user/{username}"
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName")
|
return *new(User), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->GetUserByName")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
|
||||||
if localVarHttpContentType != "" {
|
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
|
||||||
}
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHttpHeaderAccepts := []string {
|
|
||||||
"application/xml",
|
|
||||||
"application/json",
|
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
var successPayload = new(User)
|
// set Accept header
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
if err != nil {
|
}
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
var successPayload = new(User)
|
||||||
}
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param username The user name for login
|
* @param username The user name for login
|
||||||
* @param password The password for login in clear text
|
* @param password The password for login in clear text
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
func (a UserApi) LoginUser (username string, password string) (string, APIResponse, error) {
|
func (a UserApi) LoginUser(username string, password string) (string, APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Get"
|
var httpMethod = "Get"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/login"
|
path := a.Configuration.BasePath + "/user/login"
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser")
|
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->LoginUser")
|
||||||
}
|
}
|
||||||
// verify the required parameter 'password' is set
|
// verify the required parameter 'password' is set
|
||||||
if &password == nil {
|
if &password == nil {
|
||||||
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser")
|
return *new(string), *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'password' when calling UserApi->LoginUser")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
queryParams["username"] = a.Configuration.APIClient.ParameterToString(username)
|
|
||||||
queryParams["password"] = a.Configuration.APIClient.ParameterToString(password)
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
queryParams["username"] = a.Configuration.APIClient.ParameterToString(username)
|
||||||
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)
|
// to determine the Content-Type header
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
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 {
|
// set Accept header
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
}
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
}
|
||||||
|
var successPayload = new(string)
|
||||||
return *successPayload, *NewAPIResponse(httpResponse.RawResponse), err
|
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
|
* Logs out current logged in user session
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a UserApi) LogoutUser () (APIResponse, error) {
|
func (a UserApi) LogoutUser() (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Get"
|
var httpMethod = "Get"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/logout"
|
path := a.Configuration.BasePath + "/user/logout"
|
||||||
|
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
|
||||||
if localVarHttpContentType != "" {
|
|
||||||
headerParams["Content-Type"] = localVarHttpContentType
|
|
||||||
}
|
|
||||||
// to determine the Accept header
|
|
||||||
localVarHttpHeaderAccepts := []string {
|
|
||||||
"application/xml",
|
|
||||||
"application/json",
|
|
||||||
}
|
|
||||||
//set Accept header
|
|
||||||
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
|
||||||
if localVarHttpHeaderAccept != "" {
|
|
||||||
headerParams["Accept"] = localVarHttpHeaderAccept
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// set Content-Type header
|
||||||
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated user
|
* Updated user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
|
*
|
||||||
* @param username name that need to be deleted
|
* @param username name that need to be deleted
|
||||||
* @param body Updated user object
|
* @param body Updated user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
func (a UserApi) UpdateUser (username string, body User) (APIResponse, error) {
|
func (a UserApi) UpdateUser(username string, body User) (APIResponse, error) {
|
||||||
|
|
||||||
var httpMethod = "Put"
|
var httpMethod = "Put"
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := a.Configuration.BasePath + "/user/{username}"
|
path := a.Configuration.BasePath + "/user/{username}"
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
path = strings.Replace(path, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'username' when calling UserApi->UpdateUser")
|
||||||
}
|
}
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser")
|
return *NewAPIResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling UserApi->UpdateUser")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
queryParams := make(map[string]string)
|
queryParams := make(map[string]string)
|
||||||
formParams := make(map[string]string)
|
formParams := make(map[string]string)
|
||||||
var postBody interface{}
|
var postBody interface{}
|
||||||
var fileName string
|
var fileName string
|
||||||
var fileBytes []byte
|
var fileBytes []byte
|
||||||
|
|
||||||
|
// add default headers if any
|
||||||
// add default headers if any
|
for key := range a.Configuration.DefaultHeader {
|
||||||
for key := range a.Configuration.DefaultHeader {
|
headerParams[key] = a.Configuration.DefaultHeader[key]
|
||||||
headerParams[key] = a.Configuration.DefaultHeader[key]
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// to determine the Content-Type header
|
// to determine the Content-Type header
|
||||||
localVarHttpContentTypes := []string {
|
localVarHttpContentTypes := []string{ }
|
||||||
}
|
|
||||||
//set Content-Type header
|
|
||||||
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
|
// set Content-Type header
|
||||||
postBody = &body
|
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
|
||||||
|
if localVarHttpContentType != "" {
|
||||||
|
headerParams["Content-Type"] = localVarHttpContentType
|
||||||
|
}
|
||||||
|
// to determine the Accept header
|
||||||
|
localVarHttpHeaderAccepts := []string{
|
||||||
|
"application/xml",
|
||||||
|
"application/json",
|
||||||
|
}
|
||||||
|
|
||||||
|
// set Accept header
|
||||||
|
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
|
||||||
|
if localVarHttpHeaderAccept != "" {
|
||||||
|
headerParams["Accept"] = localVarHttpHeaderAccept
|
||||||
|
}
|
||||||
|
// body params
|
||||||
|
postBody = &body
|
||||||
|
|
||||||
|
|
||||||
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
|
||||||
|
if err != nil {
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
|
}
|
||||||
|
|
||||||
|
return *NewAPIResponse(httpResponse.RawResponse), err
|
||||||
if err != nil {
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
|
||||||
|
|
||||||
return *NewAPIResponse(httpResponse.RawResponse), err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user