forked from loafle/openapi-generator-original
remove logger, fix deserialization of json response
This commit is contained in:
parent
3ebefba678
commit
4062deed92
@ -1045,8 +1045,6 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
property.baseType = getSwaggerType(p);
|
property.baseType = getSwaggerType(p);
|
||||||
LOGGER.info("property.baseType=" + property.baseType);
|
|
||||||
LOGGER.info("property.datatype=" + property.datatype);
|
|
||||||
|
|
||||||
if (p instanceof ArrayProperty) {
|
if (p instanceof ArrayProperty) {
|
||||||
property.isContainer = true;
|
property.isContainer = true;
|
||||||
|
@ -657,7 +657,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
for (String nextImport : allImports) {
|
for (String nextImport : allImports) {
|
||||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||||
String mapping = config.importMapping().get(nextImport);
|
String mapping = config.importMapping().get(nextImport);
|
||||||
LOGGER.info("mapping = " + mapping);
|
|
||||||
if (mapping == null) {
|
if (mapping == null) {
|
||||||
mapping = config.toModelImport(nextImport);
|
mapping = config.toModelImport(nextImport);
|
||||||
}
|
}
|
||||||
@ -704,7 +703,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
|
|
||||||
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
List<Map<String, String>> imports = new ArrayList<Map<String, String>>();
|
||||||
for (String nextImport : allImports) {
|
for (String nextImport : allImports) {
|
||||||
LOGGER.info("nextImport=" + nextImport);
|
|
||||||
Map<String, String> im = new LinkedHashMap<String, String>();
|
Map<String, String> im = new LinkedHashMap<String, String>();
|
||||||
String mapping = config.importMapping().get(nextImport);
|
String mapping = config.importMapping().get(nextImport);
|
||||||
if (mapping == null) {
|
if (mapping == null) {
|
||||||
@ -713,14 +711,12 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||||
im.put("import", mapping);
|
im.put("import", mapping);
|
||||||
imports.add(im);
|
imports.add(im);
|
||||||
LOGGER.info("config.importMaping added " + mapping);
|
|
||||||
}
|
}
|
||||||
// add instantiation types
|
// add instantiation types
|
||||||
mapping = config.instantiationTypes().get(nextImport);
|
mapping = config.instantiationTypes().get(nextImport);
|
||||||
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
if (mapping != null && !config.defaultIncludes().contains(mapping)) {
|
||||||
im.put("import", mapping);
|
im.put("import", mapping);
|
||||||
imports.add(im);
|
imports.add(im);
|
||||||
LOGGER.info("config.instantiationTypes added " + mapping);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
return name;
|
return name;
|
||||||
|
|
||||||
// camelize (lower first character) the variable name
|
// camelize (lower first character) the variable name
|
||||||
// pet_id => petId
|
// pet_id => PetId
|
||||||
name = camelize(name, true);
|
name = camelize(name);
|
||||||
|
|
||||||
// for reserved word or word starting with number, append _
|
// for reserved word or word starting with number, append _
|
||||||
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||||
@ -163,7 +163,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Property p) {
|
public String getTypeDeclaration(Property p) {
|
||||||
LOGGER.info("getTypeDeclaration=" + p.getName());
|
String swaggerType = getSwaggerType(p);
|
||||||
if(p instanceof ArrayProperty) {
|
if(p instanceof ArrayProperty) {
|
||||||
ArrayProperty ap = (ArrayProperty) p;
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
Property inner = ap.getItems();
|
Property inner = ap.getItems();
|
||||||
@ -175,14 +175,6 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
return getSwaggerType(p) + "[string]" + getTypeDeclaration(inner);
|
return getSwaggerType(p) + "[string]" + getTypeDeclaration(inner);
|
||||||
}
|
}
|
||||||
LOGGER.info("super.getTypeDeclaration=" + super.getTypeDeclaration(p));
|
|
||||||
return super.getTypeDeclaration(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSwaggerType(Property p) {
|
|
||||||
String swaggerType = super.getSwaggerType(p);
|
|
||||||
LOGGER.info("swaggerType=" + swaggerType);
|
|
||||||
String type = null;
|
String type = null;
|
||||||
if(typeMapping.containsKey(swaggerType)) {
|
if(typeMapping.containsKey(swaggerType)) {
|
||||||
type = typeMapping.get(swaggerType);
|
type = typeMapping.get(swaggerType);
|
||||||
@ -200,7 +192,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
if(reservedWords.contains(operationId))
|
if(reservedWords.contains(operationId))
|
||||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
||||||
|
|
||||||
return camelize(operationId, true);
|
return camelize(operationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
type {{classname}} struct {
|
type {{classname}} struct {
|
||||||
basePath string
|
basePath string
|
||||||
apiClient ApiClient
|
apiClient ApiClient
|
||||||
sling *sling.Sling
|
//sling *sling.Sling
|
||||||
}
|
}
|
||||||
|
|
||||||
func New{{classname}}() *{{classname}}{
|
func New{{classname}}() *{{classname}}{
|
||||||
@ -39,68 +39,49 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{
|
|||||||
//func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
|
//func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
|
||||||
func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
|
func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) {
|
||||||
|
|
||||||
_sling := a.sling.{{httpMethod}}(a.basePath)
|
_sling := sling.New().{{httpMethod}}(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "{{path}}"
|
path := "{{basePathWithoutHost}}{{path}}"
|
||||||
{{#pathParams}}//path = regexp.MustCompile("{" + "{{paramName}}" + "}").ReplaceAllString(path, "$1")
|
{{#pathParams}} path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%v", {{paramName}}), -1)
|
||||||
//path = path.Replace("\\{" + "{{paramName}}" + "\\}", ApiClient.EscapeString({{{paramName}}}))
|
{{/pathParams}}
|
||||||
path = strings.Replace(path, "{" + "{{baseName}}" + "}", fmt.Sprintf("%b", {{paramName}}), -1)
|
|
||||||
{{/pathParams}}
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
{{#hasQueryParams}}type QueryParams struct {
|
{{#hasQueryParams}} type QueryParams struct {
|
||||||
{{#queryParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
|
{{#queryParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
|
}
|
||||||
|
_sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{paramName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} })
|
||||||
|
{{/hasQueryParams}}
|
||||||
|
// accept header
|
||||||
|
accepts := []string { {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
{{#hasHeaderParams}}{{#headerParams}} // header params "{{baseName}}"
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ {{#queryParams}}{{paramName}}: {{baseName}}{{#hasMore}},{{/hasMore}}{{/queryParams}} })
|
|
||||||
{{/hasQueryParams}}
|
|
||||||
|
|
||||||
{{#headerParams}}// header params "{{baseName}}"
|
|
||||||
_sling = _sling.Set("{{baseName}}", {{paramName}})
|
_sling = _sling.Set("{{baseName}}", {{paramName}})
|
||||||
{{/headerParams}}
|
{{/headerParams}}{{/hasHeaderParams}}
|
||||||
|
{{#hasFormParams}} type FormParams struct {
|
||||||
//contentTypes := []string { {{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}} }
|
{{#formParams}} {{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
|
||||||
|
{{/formParams}}
|
||||||
{{#hasFormParams}}type FormParams struct {
|
|
||||||
{{#formParams}}{{paramName}} {{dataType}} `url:"{{baseName}},omitempty"`
|
|
||||||
{{/formParams}}
|
|
||||||
}
|
}
|
||||||
_sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{paramName}}: {{baseName}}{{#hasMore}},{{/hasMore}}{{/formParams}} })
|
_sling = _sling.BodyForm(&FormParams{ {{#formParams}}{{paramName}}: {{paramName}}{{#hasMore}},{{/hasMore}}{{/formParams}} })
|
||||||
{{/hasFormParams}}
|
{{/hasFormParams}}
|
||||||
|
{{#hasBodyParams}}{{#bodyParams}}// body params
|
||||||
{{#bodyParams}}// body params
|
|
||||||
_sling = _sling.BodyJSON({{paramName}})
|
_sling = _sling.BodyJSON({{paramName}})
|
||||||
//b, _ := json.Marshal(body)
|
{{/bodyParams}}{{/hasBodyParams}}
|
||||||
//bodyParams["{{baseName}}"] = string(b)
|
|
||||||
{{/bodyParams}}
|
|
||||||
|
|
||||||
{{#returnType}}
|
{{#returnType}} response := new({{returnType}})
|
||||||
var response {{returnType}}
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("{{operationId}} response: ", response, resp, err)
|
fmt.Println("{{operationId}} response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
{{/returnType}}{{^returnType}}
|
{{/returnType}}{{^returnType}}
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("{{operationId}} response: void, ", resp, err)
|
fmt.Println("{{operationId}} response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "{{httpMethod}}", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//{{#returnType}}ApiClient.Deserialize(response, "{{returnContainer}}", "{{returnBaseType}}"){{/returnType}}
|
|
||||||
|
|
||||||
//{{#returnType}}var response {{returnType}}
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, err{{/returnType}}
|
|
||||||
//{{^returnType}}return err{{/returnType}}
|
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -4,7 +4,7 @@ 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,15 +1,14 @@
|
|||||||
package swagger
|
package swagger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"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"`
|
||||||
status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
complete bool `json:"complete,omitempty"`
|
Complete bool `json:"complete,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,11 @@ 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"`
|
||||||
status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,13 +6,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
// "log"
|
// "log"
|
||||||
"github.com/dghubble/sling"
|
"github.com/dghubble/sling"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type PetApi struct {
|
type PetApi struct {
|
||||||
basePath string
|
basePath string
|
||||||
apiClient ApiClient
|
apiClient ApiClient
|
||||||
sling *sling.Sling
|
//sling *sling.Sling
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPetApi() *PetApi{
|
func NewPetApi() *PetApi{
|
||||||
@ -30,420 +29,271 @@ func NewPetApiWithBasePath(basePath string) *PetApi{
|
|||||||
/**
|
/**
|
||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param Body Pet object that needs to be added to the store
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) updatePet (body Pet) (error) {
|
//func (a PetApi) UpdatePet (Body Pet) (error) {
|
||||||
func (a PetApi) updatePet (body Pet) (error) {
|
func (a PetApi) UpdatePet (Body Pet) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Put(a.basePath)
|
_sling := sling.New().Put(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet"
|
path := "/v2/pet"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { "application/json","application/xml" }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("updatePet response: void, ", resp, err)
|
fmt.Println("UpdatePet response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Put", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
*
|
*
|
||||||
* @param body Pet object that needs to be added to the store
|
* @param Body Pet object that needs to be added to the store
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) addPet (body Pet) (error) {
|
//func (a PetApi) AddPet (Body Pet) (error) {
|
||||||
func (a PetApi) addPet (body Pet) (error) {
|
func (a PetApi) AddPet (Body Pet) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet"
|
path := "/v2/pet"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { "application/json","application/xml" }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("addPet response: void, ", resp, err)
|
fmt.Println("AddPet response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
* Multiple status values can be provided with comma seperated strings
|
* Multiple status values can be provided with comma seperated strings
|
||||||
* @param status Status values that need to be considered for filter
|
* @param Status Status values that need to be considered for filter
|
||||||
* @return []Pet
|
* @return []Pet
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) findPetsByStatus (status []string) ([]Pet, error) {
|
//func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) {
|
||||||
func (a PetApi) findPetsByStatus (status []string) ([]Pet, error) {
|
func (a PetApi) FindPetsByStatus (Status []string) ([]Pet, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet/findByStatus"
|
path := "/v2/pet/findByStatus"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
type QueryParams struct {
|
type QueryParams struct {
|
||||||
status []string `url:"status,omitempty"`
|
Status []string `url:"status,omitempty"`
|
||||||
|
|
||||||
|
}
|
||||||
|
_sling = _sling.QueryStruct(&QueryParams{ Status: Status })
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ status: status })
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new([]Pet)
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response []Pet
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("findPetsByStatus response: ", response, resp, err)
|
fmt.Println("FindPetsByStatus response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "array", "Pet")
|
|
||||||
|
|
||||||
//var response []Pet
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, err
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
* @param tags Tags to filter by
|
* @param Tags Tags to filter by
|
||||||
* @return []Pet
|
* @return []Pet
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) findPetsByTags (tags []string) ([]Pet, error) {
|
//func (a PetApi) FindPetsByTags (Tags []string) ([]Pet, error) {
|
||||||
func (a PetApi) findPetsByTags (tags []string) ([]Pet, error) {
|
func (a PetApi) FindPetsByTags (Tags []string) ([]Pet, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet/findByTags"
|
path := "/v2/pet/findByTags"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
type QueryParams struct {
|
type QueryParams struct {
|
||||||
tags []string `url:"tags,omitempty"`
|
Tags []string `url:"tags,omitempty"`
|
||||||
|
|
||||||
|
}
|
||||||
|
_sling = _sling.QueryStruct(&QueryParams{ Tags: Tags })
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ tags: tags })
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new([]Pet)
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response []Pet
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("findPetsByTags response: ", response, resp, err)
|
fmt.Println("FindPetsByTags response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "array", "Pet")
|
|
||||||
|
|
||||||
//var response []Pet
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, err
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
* @param petId ID of pet that needs to be fetched
|
* @param PetId ID of pet that needs to be fetched
|
||||||
* @return Pet
|
* @return Pet
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) getPetById (petId int64) (Pet, error) {
|
//func (a PetApi) GetPetById (PetId int64) (Pet, error) {
|
||||||
func (a PetApi) getPetById (petId int64) (Pet, error) {
|
func (a PetApi) GetPetById (PetId int64) (Pet, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet/{petId}"
|
path := "/v2/pet/{petId}"
|
||||||
//path = regexp.MustCompile("{" + "petId" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
|
||||||
//path = path.Replace("\\{" + "petId" + "\\}", ApiClient.EscapeString(petId))
|
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%b", petId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new(Pet)
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response Pet
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("getPetById response: ", response, resp, err)
|
fmt.Println("GetPetById response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "", "Pet")
|
|
||||||
|
|
||||||
//var response Pet
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, err
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
*
|
*
|
||||||
* @param petId ID of pet that needs to be updated
|
* @param PetId ID of pet that needs to be updated
|
||||||
* @param name Updated name of the pet
|
* @param Name Updated name of the pet
|
||||||
* @param status Updated status of the pet
|
* @param Status Updated status of the pet
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) updatePetWithForm (petId string, name string, status string) (error) {
|
//func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) {
|
||||||
func (a PetApi) updatePetWithForm (petId string, name string, status string) (error) {
|
func (a PetApi) UpdatePetWithForm (PetId string, Name string, Status string) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet/{petId}"
|
path := "/v2/pet/{petId}"
|
||||||
//path = regexp.MustCompile("{" + "petId" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
|
||||||
//path = path.Replace("\\{" + "petId" + "\\}", ApiClient.EscapeString(petId))
|
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%b", petId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
//contentTypes := []string { "application/x-www-form-urlencoded" }
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
type FormParams struct {
|
type FormParams struct {
|
||||||
name string `url:"name,omitempty"`
|
Name string `url:"name,omitempty"`
|
||||||
status string `url:"status,omitempty"`
|
Status string `url:"status,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
_sling = _sling.BodyForm(&FormParams{ name: name,status: status })
|
_sling = _sling.BodyForm(&FormParams{ Name: Name,Status: Status })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("updatePetWithForm response: void, ", resp, err)
|
fmt.Println("UpdatePetWithForm response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*
|
*
|
||||||
* @param petId Pet id to delete
|
* @param PetId Pet id to delete
|
||||||
* @param apiKey
|
* @param ApiKey
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) deletePet (petId int64, apiKey string) (error) {
|
//func (a PetApi) DeletePet (PetId int64, ApiKey string) (error) {
|
||||||
func (a PetApi) deletePet (petId int64, apiKey string) (error) {
|
func (a PetApi) DeletePet (PetId int64, ApiKey string) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Delete(a.basePath)
|
_sling := sling.New().Delete(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet/{petId}"
|
path := "/v2/pet/{petId}"
|
||||||
//path = regexp.MustCompile("{" + "petId" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
|
||||||
//path = path.Replace("\\{" + "petId" + "\\}", ApiClient.EscapeString(petId))
|
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%b", petId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
// header params "api_key"
|
// header params "api_key"
|
||||||
_sling = _sling.Set("api_key", apiKey)
|
_sling = _sling.Set("api_key", ApiKey)
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("deletePet response: void, ", resp, err)
|
fmt.Println("DeletePet response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Delete", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* uploads an image
|
* uploads an image
|
||||||
*
|
*
|
||||||
* @param petId ID of pet to update
|
* @param PetId ID of pet to update
|
||||||
* @param additionalMetadata Additional data to pass to server
|
* @param AdditionalMetadata Additional data to pass to server
|
||||||
* @param file file to upload
|
* @param File file to upload
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) uploadFile (petId int64, additionalMetadata string, file *os.File) (error) {
|
//func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) {
|
||||||
func (a PetApi) uploadFile (petId int64, additionalMetadata string, file *os.File) (error) {
|
func (a PetApi) UploadFile (PetId int64, AdditionalMetadata string, File *os.File) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/pet/{petId}/uploadImage"
|
path := "/v2/pet/{petId}/uploadImage"
|
||||||
//path = regexp.MustCompile("{" + "petId" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", PetId), -1)
|
||||||
//path = path.Replace("\\{" + "petId" + "\\}", ApiClient.EscapeString(petId))
|
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%b", petId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
//contentTypes := []string { "multipart/form-data" }
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
type FormParams struct {
|
type FormParams struct {
|
||||||
additionalMetadata string `url:"additionalMetadata,omitempty"`
|
AdditionalMetadata string `url:"additionalMetadata,omitempty"`
|
||||||
file *os.File `url:"file,omitempty"`
|
File *os.File `url:"file,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
_sling = _sling.BodyForm(&FormParams{ additionalMetadata: additionalMetadata,file: file })
|
_sling = _sling.BodyForm(&FormParams{ AdditionalMetadata: AdditionalMetadata,File: File })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("uploadFile response: void, ", resp, err)
|
fmt.Println("UploadFile response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
type StoreApi struct {
|
type StoreApi struct {
|
||||||
basePath string
|
basePath string
|
||||||
apiClient ApiClient
|
apiClient ApiClient
|
||||||
sling *sling.Sling
|
//sling *sling.Sling
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStoreApi() *StoreApi{
|
func NewStoreApi() *StoreApi{
|
||||||
@ -31,196 +31,119 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{
|
|||||||
* 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, error) {
|
//func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||||
func (a StoreApi) getInventory () (map[string]int32, error) {
|
func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/store/inventory"
|
path := "/v2/store/inventory"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new(map[string]int32)
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response map[string]int32
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("getInventory response: ", response, resp, err)
|
fmt.Println("GetInventory response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "map", "map")
|
|
||||||
|
|
||||||
//var response map[string]int32
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, 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, error) {
|
//func (a StoreApi) PlaceOrder (Body Order) (Order, error) {
|
||||||
func (a StoreApi) placeOrder (body Order) (Order, error) {
|
func (a StoreApi) PlaceOrder (Body Order) (Order, error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/store/order"
|
path := "/v2/store/order"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new(Order)
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response Order
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("placeOrder response: ", response, resp, err)
|
fmt.Println("PlaceOrder response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "", "Order")
|
|
||||||
|
|
||||||
//var response Order
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, 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 string) (Order, error) {
|
//func (a StoreApi) GetOrderById (OrderId string) (Order, error) {
|
||||||
func (a StoreApi) getOrderById (orderId string) (Order, error) {
|
func (a StoreApi) GetOrderById (OrderId string) (Order, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/store/order/{orderId}"
|
path := "/v2/store/order/{orderId}"
|
||||||
//path = regexp.MustCompile("{" + "orderId" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", OrderId), -1)
|
||||||
//path = path.Replace("\\{" + "orderId" + "\\}", ApiClient.EscapeString(orderId))
|
|
||||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%b", orderId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new(Order)
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response Order
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("getOrderById response: ", response, resp, err)
|
fmt.Println("GetOrderById response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "", "Order")
|
|
||||||
|
|
||||||
//var response Order
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, err
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 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) (error) {
|
//func (a StoreApi) DeleteOrder (OrderId string) (error) {
|
||||||
func (a StoreApi) deleteOrder (orderId string) (error) {
|
func (a StoreApi) DeleteOrder (OrderId string) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Delete(a.basePath)
|
_sling := sling.New().Delete(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/store/order/{orderId}"
|
path := "/v2/store/order/{orderId}"
|
||||||
//path = regexp.MustCompile("{" + "orderId" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", OrderId), -1)
|
||||||
//path = path.Replace("\\{" + "orderId" + "\\}", ApiClient.EscapeString(orderId))
|
|
||||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%b", orderId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
//contentTypes := []string { }
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("deleteOrder response: void, ", resp, err)
|
fmt.Println("DeleteOrder response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Delete", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ 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"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@ 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"`
|
||||||
userStatus int32 `json:"userStatus,omitempty"`
|
UserStatus int32 `json:"userStatus,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
type UserApi struct {
|
type UserApi struct {
|
||||||
basePath string
|
basePath string
|
||||||
apiClient ApiClient
|
apiClient ApiClient
|
||||||
sling *sling.Sling
|
//sling *sling.Sling
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUserApi() *UserApi{
|
func NewUserApi() *UserApi{
|
||||||
@ -29,399 +29,250 @@ func NewUserApiWithBasePath(basePath string) *UserApi{
|
|||||||
/**
|
/**
|
||||||
* Create user
|
* Create user
|
||||||
* This can only be done by the logged in user.
|
* This can only be done by the logged in user.
|
||||||
* @param body Created user object
|
* @param Body Created user object
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a UserApi) createUser (body User) (error) {
|
//func (a UserApi) CreateUser (Body User) (error) {
|
||||||
func (a UserApi) createUser (body User) (error) {
|
func (a UserApi) CreateUser (Body User) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user"
|
path := "/v2/user"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("createUser response: void, ", resp, err)
|
fmt.Println("CreateUser response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return 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) (error) {
|
//func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) {
|
||||||
func (a UserApi) createUsersWithArrayInput (body []User) (error) {
|
func (a UserApi) CreateUsersWithArrayInput (Body []User) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/createWithArray"
|
path := "/v2/user/createWithArray"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("createUsersWithArrayInput response: void, ", resp, err)
|
fmt.Println("CreateUsersWithArrayInput response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return 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) (error) {
|
//func (a UserApi) CreateUsersWithListInput (Body []User) (error) {
|
||||||
func (a UserApi) createUsersWithListInput (body []User) (error) {
|
func (a UserApi) CreateUsersWithListInput (Body []User) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Post(a.basePath)
|
_sling := sling.New().Post(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/createWithList"
|
path := "/v2/user/createWithList"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("createUsersWithListInput response: void, ", resp, err)
|
fmt.Println("CreateUsersWithListInput response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Post", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return 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, error) {
|
//func (a UserApi) LoginUser (Username string, Password string) (string, error) {
|
||||||
func (a UserApi) loginUser (username string, password string) (string, error) {
|
func (a UserApi) LoginUser (Username string, Password string) (string, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/login"
|
path := "/v2/user/login"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
type QueryParams struct {
|
type QueryParams struct {
|
||||||
username string `url:"username,omitempty"`
|
Username string `url:"username,omitempty"`
|
||||||
password string `url:"password,omitempty"`
|
Password string `url:"password,omitempty"`
|
||||||
|
|
||||||
|
}
|
||||||
|
_sling = _sling.QueryStruct(&QueryParams{ Username: Username,Password: Password })
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ username: username,password: password })
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new(string)
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response string
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("loginUser response: ", response, resp, err)
|
fmt.Println("LoginUser response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "", "string")
|
|
||||||
|
|
||||||
//var response string
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, err
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a UserApi) logoutUser () (error) {
|
//func (a UserApi) LogoutUser () (error) {
|
||||||
func (a UserApi) logoutUser () (error) {
|
func (a UserApi) LogoutUser () (error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/logout"
|
path := "/v2/user/logout"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
//contentTypes := []string { }
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("logoutUser response: void, ", resp, err)
|
fmt.Println("LogoutUser response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return 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, error) {
|
//func (a UserApi) GetUserByName (Username string) (User, error) {
|
||||||
func (a UserApi) getUserByName (username string) (User, error) {
|
func (a UserApi) GetUserByName (Username string) (User, error) {
|
||||||
|
|
||||||
_sling := a.sling.Get(a.basePath)
|
_sling := sling.New().Get(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/{username}"
|
path := "/v2/user/{username}"
|
||||||
//path = regexp.MustCompile("{" + "username" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1)
|
||||||
//path = path.Replace("\\{" + "username" + "\\}", ApiClient.EscapeString(username))
|
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%b", username), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
response := new(User)
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var response User
|
|
||||||
resp, err := _sling.ReceiveSuccess(response)
|
resp, err := _sling.ReceiveSuccess(response)
|
||||||
fmt.Println("getUserByName response: ", response, resp, err)
|
fmt.Println("GetUserByName response: ", response, resp, err)
|
||||||
return response, err
|
return *response, err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Get", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ApiClient.Deserialize(response, "", "User")
|
|
||||||
|
|
||||||
//var response User
|
|
||||||
//err = json.Unmarshal([]byte(req), &response)
|
|
||||||
//return response, 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) (error) {
|
//func (a UserApi) UpdateUser (Username string, Body User) (error) {
|
||||||
func (a UserApi) updateUser (username string, body User) (error) {
|
func (a UserApi) UpdateUser (Username string, Body User) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Put(a.basePath)
|
_sling := sling.New().Put(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/{username}"
|
path := "/v2/user/{username}"
|
||||||
//path = regexp.MustCompile("{" + "username" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1)
|
||||||
//path = path.Replace("\\{" + "username" + "\\}", ApiClient.EscapeString(username))
|
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%b", username), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//contentTypes := []string { }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// body params
|
|
||||||
_sling = _sling.BodyJSON(body)
|
|
||||||
//b, _ := json.Marshal(body)
|
|
||||||
//bodyParams["body"] = string(b)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("updateUser response: void, ", resp, err)
|
fmt.Println("UpdateUser response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Put", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return 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) (error) {
|
//func (a UserApi) DeleteUser (Username string) (error) {
|
||||||
func (a UserApi) deleteUser (username string) (error) {
|
func (a UserApi) DeleteUser (Username string) (error) {
|
||||||
|
|
||||||
_sling := a.sling.Delete(a.basePath)
|
_sling := sling.New().Delete(a.basePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/user/{username}"
|
path := "/v2/user/{username}"
|
||||||
//path = regexp.MustCompile("{" + "username" + "}").ReplaceAllString(path, "$1")
|
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", Username), -1)
|
||||||
//path = path.Replace("\\{" + "username" + "\\}", ApiClient.EscapeString(username))
|
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%b", username), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
// accept header
|
||||||
|
accepts := []string { "application/json", "application/xml" }
|
||||||
|
for key := range accepts {
|
||||||
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
//contentTypes := []string { }
|
break // only use the first Accept
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
resp, err := _sling.Request()
|
resp, err := _sling.Request()
|
||||||
fmt.Println("deleteUser response: void, ", resp, err)
|
fmt.Println("DeleteUser response: void, ", resp, err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//response, err := a.apiClient.CallApi(a.basePath, path, "Delete", queryParams, headerParams, formParams, fileParams, bodyParams, contentTypes)
|
|
||||||
//if err != nil {
|
|
||||||
// log.Fatal(err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//return err
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
sw "./swagger"
|
||||||
"fmt"
|
"fmt"
|
||||||
// "log"
|
|
||||||
swagger "./swagger"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
fmt.Println("hello world")
|
fmt.Println("hello world")
|
||||||
s := swagger.NewPetApi()
|
s := sw.NewPetApi()
|
||||||
&s.updatePetWithForm("2", "golang", "available")
|
//s.UpdatePetWithForm("2", "golang", "available")
|
||||||
|
|
||||||
|
// test Get
|
||||||
|
resp, err := s.GetPetById(3)
|
||||||
|
fmt.Println("GetPetById: ", resp, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user