mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
added implementation of the new ApiResponse struct
This commit is contained in:
parent
7df5c8ffbf
commit
1de18eb074
@ -49,7 +49,7 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
|
|||||||
{{#required}}
|
{{#required}}
|
||||||
// verify the required parameter '{{paramName}}' is set
|
// verify the required parameter '{{paramName}}' is set
|
||||||
if &{{paramName}} == nil {
|
if &{{paramName}} == nil {
|
||||||
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
return {{#returnType}}*new({{{returnType}}}), {{/returnType}}*NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
|
||||||
}
|
}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
@ -138,14 +138,14 @@ func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return {{#returnType}}*successPayload, {{/returnType}}*a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return {{#returnType}}*successPayload, {{/returnType}}*NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
|
|
||||||
return {{#returnType}}*successPayload, {{/returnType}}*a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return {{#returnType}}*successPayload, {{/returnType}}*NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
|
@ -89,24 +89,6 @@ func (c *ApiClient) ParameterToString(obj interface{}) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{
|
|
||||||
httpResponse := httpResp.(*resty.Response)
|
|
||||||
apiResponse := new(ApiResponse)
|
|
||||||
apiResponse.Code = int32(httpResponse.StatusCode())
|
|
||||||
apiResponse.Message = httpResponse.Status()
|
|
||||||
|
|
||||||
return apiResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{
|
|
||||||
|
|
||||||
apiResponse := new(ApiResponse)
|
|
||||||
apiResponse.Code = int32(400)
|
|
||||||
apiResponse.Message = errorMessage
|
|
||||||
|
|
||||||
return apiResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareRequest(postBody interface{},
|
func prepareRequest(postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
|
@ -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-23T15:46:19.755-07:00
|
- Build date: 2016-04-23T17:00:49.475-07:00
|
||||||
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
- Build package: class io.swagger.codegen.languages.GoClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -89,24 +89,6 @@ func (c *ApiClient) ParameterToString(obj interface{}) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApiClient) GetApiResponse(httpResp interface{}) *ApiResponse{
|
|
||||||
httpResponse := httpResp.(*resty.Response)
|
|
||||||
apiResponse := new(ApiResponse)
|
|
||||||
apiResponse.Code = int32(httpResponse.StatusCode())
|
|
||||||
apiResponse.Message = httpResponse.Status()
|
|
||||||
|
|
||||||
return apiResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ApiClient) SetErrorApiResponse(errorMessage string) *ApiResponse{
|
|
||||||
|
|
||||||
apiResponse := new(ApiResponse)
|
|
||||||
apiResponse.Code = int32(400)
|
|
||||||
apiResponse.Message = errorMessage
|
|
||||||
|
|
||||||
return apiResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareRequest(postBody interface{},
|
func prepareRequest(postBody interface{},
|
||||||
headerParams map[string]string,
|
headerParams map[string]string,
|
||||||
queryParams map[string]string,
|
queryParams map[string]string,
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
package swagger
|
package swagger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type ApiResponse struct {
|
type ApiResponse struct {
|
||||||
|
*http.Response
|
||||||
Code int32 `json:"code,omitempty"`
|
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
Type_ string `json:"type,omitempty"`
|
|
||||||
|
|
||||||
Message string `json:"message,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewApiResponse(r *http.Response) *ApiResponse {
|
||||||
|
response := &ApiResponse{Response: r}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewApiResponseWithError(errorMessage string) *ApiResponse {
|
||||||
|
response := &ApiResponse{Message: errorMessage}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
@ -43,7 +43,7 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet")
|
return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->AddPet")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -95,10 +95,10 @@ func (a PetApi) AddPet (body Pet) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
@ -116,7 +116,7 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if &petId == nil {
|
if &petId == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet")
|
return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->DeletePet")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -166,10 +166,10 @@ func (a PetApi) DeletePet (petId int64, apiKey string) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
@ -185,7 +185,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'status' is set
|
// verify the required parameter 'status' is set
|
||||||
if &status == nil {
|
if &status == nil {
|
||||||
return *new([]Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus")
|
return *new([]Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'status' when calling PetApi->FindPetsByStatus")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -234,12 +234,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
@ -255,7 +255,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'tags' is set
|
// verify the required parameter 'tags' is set
|
||||||
if &tags == nil {
|
if &tags == nil {
|
||||||
return *new([]Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags")
|
return *new([]Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'tags' when calling PetApi->FindPetsByTags")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -304,12 +304,12 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
@ -326,7 +326,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if &petId == nil {
|
if &petId == nil {
|
||||||
return *new(Pet), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById")
|
return *new(Pet), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->GetPetById")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -373,12 +373,12 @@ func (a PetApi) GetPetById (petId int64) (Pet, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
@ -394,7 +394,7 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet")
|
return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'body' when calling PetApi->UpdatePet")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -446,10 +446,10 @@ func (a PetApi) UpdatePet (body Pet) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
@ -468,7 +468,7 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api
|
|||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if &petId == nil {
|
if &petId == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm")
|
return *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UpdatePetWithForm")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -519,10 +519,10 @@ func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (Api
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* uploads an image
|
* uploads an image
|
||||||
@ -541,7 +541,7 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
|
|||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if &petId == nil {
|
if &petId == nil {
|
||||||
return *new(ModelApiResponse), *a.Configuration.ApiClient.SetErrorApiResponse("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile")
|
return *new(ModelApiResponse), *NewApiResponseWithError("400 - Bad Request"), errors.New("Missing required parameter 'petId' when calling PetApi->UploadFile")
|
||||||
}
|
}
|
||||||
|
|
||||||
headerParams := make(map[string]string)
|
headerParams := make(map[string]string)
|
||||||
@ -593,10 +593,10 @@ func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.Fil
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if &orderId == nil {
|
if &orderId == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -84,10 +84,10 @@ func (a StoreApi) DeleteOrder (orderId string) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns pet inventories by status
|
* Returns pet inventories by status
|
||||||
@ -144,12 +144,12 @@ func (a StoreApi) GetInventory () (map[string]int32, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
@ -166,7 +166,7 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if &orderId == nil {
|
if &orderId == nil {
|
||||||
return *new(Order), *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -208,12 +208,12 @@ func (a StoreApi) GetOrderById (orderId int64) (Order, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
@ -229,7 +229,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *new(Order), *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -273,10 +273,10 @@ func (a StoreApi) PlaceOrder (body Order) (Order, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -85,10 +85,10 @@ func (a UserApi) CreateUser (body User) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
@ -104,7 +104,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -148,10 +148,10 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
@ -167,7 +167,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'body' is set
|
// verify the required parameter 'body' is set
|
||||||
if &body == nil {
|
if &body == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -211,10 +211,10 @@ func (a UserApi) CreateUsersWithListInput (body []User) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Delete user
|
* Delete user
|
||||||
@ -231,7 +231,7 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -273,10 +273,10 @@ func (a UserApi) DeleteUser (username string) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get user by user name
|
* Get user by user name
|
||||||
@ -293,7 +293,7 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *new(User), *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -335,12 +335,12 @@ func (a UserApi) GetUserByName (username string) (User, ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
@ -357,11 +357,11 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon
|
|||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *new(string), *a.Configuration.ApiClient.SetErrorApiResponse("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), *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -405,12 +405,12 @@ func (a UserApi) LoginUser (username string, password string) (string, ApiRespon
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
err = json.Unmarshal(httpResponse.Body(), &successPayload)
|
||||||
|
|
||||||
return *successPayload, *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *successPayload, *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
@ -463,10 +463,10 @@ func (a UserApi) LogoutUser () (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Updated user
|
* Updated user
|
||||||
@ -484,11 +484,11 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) {
|
|||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if &username == nil {
|
if &username == nil {
|
||||||
return *a.Configuration.ApiClient.SetErrorApiResponse("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 *a.Configuration.ApiClient.SetErrorApiResponse("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)
|
||||||
@ -532,8 +532,8 @@ func (a UserApi) UpdateUser (username string, body User) (ApiResponse, error) {
|
|||||||
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
return *a.Configuration.ApiClient.GetApiResponse(httpResponse), err
|
return *NewApiResponse(httpResponse.RawResponse), err
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,21 @@ func TestAddPet(t *testing.T) {
|
|||||||
t.Errorf("Error while adding pet")
|
t.Errorf("Error while adding pet")
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
}
|
}
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
|
t.Log(apiResponse.Response)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindPetsByStatusWithMissingParam(t *testing.T) {
|
||||||
|
s := sw.NewPetApi()
|
||||||
|
|
||||||
|
_, apiResponse, err := s.FindPetsByStatus(nil)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error while testing TestFindPetsByStatusWithMissingParam")
|
||||||
|
t.Log(err)
|
||||||
|
}
|
||||||
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,8 +52,8 @@ func TestGetPetById(t *testing.T) {
|
|||||||
|
|
||||||
//t.Log(resp)
|
//t.Log(resp)
|
||||||
}
|
}
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse.Response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,11 +65,10 @@ func TestGetPetByIdWithInvalidID(t *testing.T) {
|
|||||||
t.Log(err)
|
t.Log(err)
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse)
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
t.Log(resp)
|
t.Log(resp)
|
||||||
}
|
}
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse.Response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +81,8 @@ func TestUpdatePetWithForm(t *testing.T) {
|
|||||||
t.Log(err)
|
t.Log(err)
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse)
|
||||||
}
|
}
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse.Response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +99,8 @@ func TestFindPetsByStatus(t *testing.T) {
|
|||||||
t.Errorf("Error no pets returned")
|
t.Errorf("Error no pets returned")
|
||||||
}
|
}
|
||||||
|
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse.Response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,8 +115,8 @@ func TestUploadFile(t *testing.T) {
|
|||||||
t.Errorf("Error while uploading file")
|
t.Errorf("Error while uploading file")
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
}
|
}
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse.Response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,7 +128,7 @@ func TestDeletePet(t *testing.T) {
|
|||||||
t.Errorf("Error while deleting pet by id")
|
t.Errorf("Error while deleting pet by id")
|
||||||
t.Log(err)
|
t.Log(err)
|
||||||
}
|
}
|
||||||
if apiResponse.Code != 200 {
|
if apiResponse.Response.StatusCode != 200 {
|
||||||
t.Log(apiResponse)
|
t.Log(apiResponse.Response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user