mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-06 10:35:25 +00:00
Add withXml option for Go language (#7566)
* Added support for application/xml content-type for GO language Issue #7463 * Added test scripts for Go lang "withXml" feature * Added samples for Go land "withXml" feature. * "withXml" feature for Go language is only available for client.
This commit is contained in:
parent
8668175879
commit
ee561fcd63
31
bin/go-petstore-withxml.sh
Normal file
31
bin/go-petstore-withxml.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/go -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l go -o samples/client/petstore/go/go-petstore-withXml -DpackageName=petstore,withXml=true "
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
10
bin/windows/go-petstore-withxml.bat
Normal file
10
bin/windows/go-petstore-withxml.bat
Normal file
@ -0,0 +1,10 @@
|
||||
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -t modules\swagger-codegen\src\main\resources\go -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l go -o samples\client\petstore\go\go-petstore-withXml -DpackageName=petstore,withXml=true
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
@ -21,6 +21,8 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
|
||||
protected static Logger LOGGER = LoggerFactory.getLogger(AbstractGoCodegen.class);
|
||||
|
||||
protected boolean withXml = false;
|
||||
|
||||
protected String packageName = "swagger";
|
||||
|
||||
public AbstractGoCodegen() {
|
||||
@ -84,7 +86,6 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
.defaultValue("swagger"));
|
||||
cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "hides the timestamp when files were generated")
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -305,10 +306,12 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
// if their is a return type, import encoding/json
|
||||
// if their is a return type, import encoding/json and if needed encoding/xml
|
||||
for (CodegenOperation operation : operations) {
|
||||
if(operation.returnBaseType != null ) {
|
||||
imports.add(createMapping("import", "encoding/json"));
|
||||
if (withXml)
|
||||
imports.add(createMapping("import", "encoding/xml"));
|
||||
break; //just need to import once
|
||||
}
|
||||
}
|
||||
@ -470,4 +473,7 @@ public abstract class AbstractGoCodegen extends DefaultCodegen implements Codege
|
||||
}
|
||||
}
|
||||
|
||||
public void setWithXml(boolean withXml) {
|
||||
this.withXml = withXml;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
protected String packageVersion = "1.0.0";
|
||||
protected String apiDocPath = "docs/";
|
||||
protected String modelDocPath = "docs/";
|
||||
public static final String WITH_XML = "withXml";
|
||||
|
||||
public GoClientCodegen() {
|
||||
super();
|
||||
@ -49,6 +50,7 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
|
||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "Go package version.")
|
||||
.defaultValue("1.0.0"));
|
||||
cliOptions.add(CliOption.newBoolean(WITH_XML, "whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)"));
|
||||
|
||||
}
|
||||
|
||||
@ -95,6 +97,13 @@ public class GoClientCodegen extends AbstractGoCodegen {
|
||||
supportingFiles.add(new SupportingFile("client.mustache", "", "client.go"));
|
||||
supportingFiles.add(new SupportingFile("response.mustache", "", "response.go"));
|
||||
supportingFiles.add(new SupportingFile(".travis.yml", "", ".travis.yml"));
|
||||
|
||||
if(additionalProperties.containsKey(WITH_XML)) {
|
||||
setWithXml(Boolean.parseBoolean(additionalProperties.get(WITH_XML).toString()));
|
||||
if ( withXml ) {
|
||||
additionalProperties.put(WITH_XML, "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,6 +215,16 @@ func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}
|
||||
return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
{{#returnType}}
|
||||
{{#withXml}}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
{{/withXml}}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return {{#returnType}}successPayload, {{/returnType}}localVarHttpResponse, err
|
||||
|
@ -27,6 +27,6 @@ type {{classname}} struct {
|
||||
{{#description}}
|
||||
// {{{description}}}
|
||||
{{/description}}
|
||||
{{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"`
|
||||
{{name}} {{^isEnum}}{{^isPrimitiveType}}{{^isContainer}}{{^isDateTime}}*{{/isDateTime}}{{/isContainer}}{{/isPrimitiveType}}{{/isEnum}}{{{datatype}}} `json:"{{baseName}}{{^required}},omitempty{{/required}}"{{#withXml}} xml:"{{baseName}}"{{/withXml}}`
|
||||
{{/vars}}
|
||||
}{{/isEnum}}{{/model}}{{/models}}
|
||||
|
@ -30,6 +30,8 @@ public class GoClientOptionsTest extends AbstractOptionsTest {
|
||||
times = 1;
|
||||
clientCodegen.setPackageName(GoClientOptionsProvider.PACKAGE_NAME_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setWithXml(GoClientOptionsProvider.WITH_XML_VALUE);
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ public class GoClientOptionsProvider implements OptionsProvider {
|
||||
|
||||
public static final String PACKAGE_VERSION_VALUE = "1.0.0";
|
||||
public static final String PACKAGE_NAME_VALUE = "Go";
|
||||
public static final boolean WITH_XML_VALUE = true;
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
@ -24,6 +25,7 @@ public class GoClientOptionsProvider implements OptionsProvider {
|
||||
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
|
||||
.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
|
||||
.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, "true")
|
||||
.put(CodegenConstants.WITH_XML, "true")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
24
samples/client/petstore/go/go-petstore-withXml/.gitignore
vendored
Normal file
24
samples/client/petstore/go/go-petstore-withXml/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1 @@
|
||||
2.4.0-SNAPSHOT
|
@ -0,0 +1,8 @@
|
||||
language: go
|
||||
|
||||
install:
|
||||
- go get -d -v .
|
||||
|
||||
script:
|
||||
- go build -v ./
|
||||
|
160
samples/client/petstore/go/go-petstore-withXml/README.md
Normal file
160
samples/client/petstore/go/go-petstore-withXml/README.md
Normal file
@ -0,0 +1,160 @@
|
||||
# Go API client for petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build package: io.swagger.codegen.languages.GoClientCodegen
|
||||
|
||||
## Installation
|
||||
Put the package under your project folder and add the following in import:
|
||||
```golang
|
||||
import "./petstore"
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**TestSpecialTags**](docs/AnotherFakeApi.md#testspecialtags) | **Patch** /another-fake/dummy | To test special tags
|
||||
*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **Post** /fake/outer/boolean |
|
||||
*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **Post** /fake/outer/composite |
|
||||
*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **Post** /fake/outer/number |
|
||||
*FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **Post** /fake/outer/string |
|
||||
*FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **Patch** /fake | To test \"client\" model
|
||||
*FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **Get** /fake | To test enum parameters
|
||||
*FakeApi* | [**TestInlineAdditionalProperties**](docs/FakeApi.md#testinlineadditionalproperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | [**TestJsonFormData**](docs/FakeApi.md#testjsonformdata) | **Get** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeClassnameTags123Api* | [**TestClassname**](docs/FakeClassnameTags123Api.md#testclassname) | **Patch** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**AddPet**](docs/PetApi.md#addpet) | **Post** /pet | Add a new pet to the store
|
||||
*PetApi* | [**DeletePet**](docs/PetApi.md#deletepet) | **Delete** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**FindPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **Get** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**FindPetsByTags**](docs/PetApi.md#findpetsbytags) | **Get** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**GetPetById**](docs/PetApi.md#getpetbyid) | **Get** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**UpdatePet**](docs/PetApi.md#updatepet) | **Put** /pet | Update an existing pet
|
||||
*PetApi* | [**UpdatePetWithForm**](docs/PetApi.md#updatepetwithform) | **Post** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**UploadFile**](docs/PetApi.md#uploadfile) | **Post** /pet/{petId}/uploadImage | uploads an image
|
||||
*StoreApi* | [**DeleteOrder**](docs/StoreApi.md#deleteorder) | **Delete** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | [**GetInventory**](docs/StoreApi.md#getinventory) | **Get** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**GetOrderById**](docs/StoreApi.md#getorderbyid) | **Get** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreApi* | [**PlaceOrder**](docs/StoreApi.md#placeorder) | **Post** /store/order | Place an order for a pet
|
||||
*UserApi* | [**CreateUser**](docs/UserApi.md#createuser) | **Post** /user | Create user
|
||||
*UserApi* | [**CreateUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **Post** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**CreateUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **Post** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**DeleteUser**](docs/UserApi.md#deleteuser) | **Delete** /user/{username} | Delete user
|
||||
*UserApi* | [**GetUserByName**](docs/UserApi.md#getuserbyname) | **Get** /user/{username} | Get user by user name
|
||||
*UserApi* | [**LoginUser**](docs/UserApi.md#loginuser) | **Get** /user/login | Logs user into the system
|
||||
*UserApi* | [**LogoutUser**](docs/UserApi.md#logoutuser) | **Get** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **Put** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnimalFarm](docs/AnimalFarm.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [List](docs/List.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelApiResponse](docs/ModelApiResponse.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterBoolean](docs/OuterBoolean.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
- [OuterNumber](docs/OuterNumber.md)
|
||||
- [OuterString](docs/OuterString.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [User](docs/User.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
## api_key
|
||||
- **Type**: API key
|
||||
|
||||
Example
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
|
||||
Key: "APIKEY",
|
||||
Prefix: "Bearer", // Omit if not necessary.
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
## api_key_query
|
||||
- **Type**: API key
|
||||
|
||||
Example
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
|
||||
Key: "APIKEY",
|
||||
Prefix: "Bearer", // Omit if not necessary.
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
## http_basic_test
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
Example
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
|
||||
UserName: "username",
|
||||
Password: "password",
|
||||
})
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
## petstore_auth
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
Example
|
||||
```golang
|
||||
auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
Or via OAuth2 module to automatically refresh tokens and perform user authentication.
|
||||
```golang
|
||||
import "golang.org/x/oauth2"
|
||||
|
||||
/* Perform OAuth2 round trip request and obtain a token */
|
||||
|
||||
tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
|
||||
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
|
||||
r, err := client.Service.Operation(auth, args)
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
apiteam@swagger.io
|
||||
|
1538
samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml
Normal file
1538
samples/client/petstore/go/go-petstore-withXml/api/swagger.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"golang.org/x/net/context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type AnotherFakeApiService service
|
||||
|
||||
/* AnotherFakeApiService To test special tags
|
||||
To test special tags
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body client model
|
||||
@return Client*/
|
||||
func (a *AnotherFakeApiService) TestSpecialTags(ctx context.Context, body Client) (Client, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Patch")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload Client
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/another-fake/dummy"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
749
samples/client/petstore/go/go-petstore-withXml/api_fake.go
Normal file
749
samples/client/petstore/go/go-petstore-withXml/api_fake.go
Normal file
@ -0,0 +1,749 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"golang.org/x/net/context"
|
||||
"time"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type FakeApiService service
|
||||
|
||||
/* FakeApiService
|
||||
Test serialization of outer boolean types
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "body" (OuterBoolean) Input boolean as post body
|
||||
@return OuterBoolean*/
|
||||
func (a *FakeApiService) FakeOuterBooleanSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterBoolean, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload OuterBoolean
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake/outer/boolean"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterBoolean); localVarOk {
|
||||
localVarPostBody = &localVarTempParam
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService
|
||||
Test serialization of object with outer number type
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "body" (OuterComposite) Input composite as post body
|
||||
@return OuterComposite*/
|
||||
func (a *FakeApiService) FakeOuterCompositeSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterComposite, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload OuterComposite
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake/outer/composite"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterComposite); localVarOk {
|
||||
localVarPostBody = &localVarTempParam
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService
|
||||
Test serialization of outer number types
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "body" (OuterNumber) Input number as post body
|
||||
@return OuterNumber*/
|
||||
func (a *FakeApiService) FakeOuterNumberSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterNumber, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload OuterNumber
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake/outer/number"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterNumber); localVarOk {
|
||||
localVarPostBody = &localVarTempParam
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService
|
||||
Test serialization of outer string types
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "body" (OuterString) Input string as post body
|
||||
@return OuterString*/
|
||||
func (a *FakeApiService) FakeOuterStringSerialize(ctx context.Context, localVarOptionals map[string]interface{}) (OuterString, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload OuterString
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake/outer/string"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
if localVarTempParam, localVarOk := localVarOptionals["body"].(OuterString); localVarOk {
|
||||
localVarPostBody = &localVarTempParam
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService To test \"client\" model
|
||||
To test \"client\" model
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body client model
|
||||
@return Client*/
|
||||
func (a *FakeApiService) TestClientModel(ctx context.Context, body Client) (Client, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Patch")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload Client
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param number None
|
||||
@param double None
|
||||
@param patternWithoutDelimiter None
|
||||
@param byte_ None
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "integer" (int32) None
|
||||
@param "int32_" (int32) None
|
||||
@param "int64_" (int64) None
|
||||
@param "float" (float32) None
|
||||
@param "string_" (string) None
|
||||
@param "binary" (string) None
|
||||
@param "date" (string) None
|
||||
@param "dateTime" (time.Time) None
|
||||
@param "password" (string) None
|
||||
@param "callback" (string) None
|
||||
@return */
|
||||
func (a *FakeApiService) TestEndpointParameters(ctx context.Context, number float32, double float64, patternWithoutDelimiter string, byte_ string, localVarOptionals map[string]interface{}) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if number < 32.1 {
|
||||
return nil, reportError("number must be greater than 32.1")
|
||||
}
|
||||
if number > 543.2 {
|
||||
return nil, reportError("number must be less than 543.2")
|
||||
}
|
||||
if double < 67.8 {
|
||||
return nil, reportError("double must be greater than 67.8")
|
||||
}
|
||||
if double > 123.4 {
|
||||
return nil, reportError("double must be less than 123.4")
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["integer"], "int32", "integer"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["int32_"], "int32", "int32_"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["int64_"], "int64", "int64_"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["float"], "float32", "float"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["string_"], "string", "string_"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["binary"], "string", "binary"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["date"], "string", "date"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["dateTime"], "time.Time", "dateTime"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["password"], "string", "password"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["callback"], "string", "callback"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml; charset=utf-8", "application/json; charset=utf-8"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["integer"].(int32); localVarOk {
|
||||
localVarFormParams.Add("integer", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["int32_"].(int32); localVarOk {
|
||||
localVarFormParams.Add("int32", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["int64_"].(int64); localVarOk {
|
||||
localVarFormParams.Add("int64", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
localVarFormParams.Add("number", parameterToString(number, ""))
|
||||
if localVarTempParam, localVarOk := localVarOptionals["float"].(float32); localVarOk {
|
||||
localVarFormParams.Add("float", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
localVarFormParams.Add("double", parameterToString(double, ""))
|
||||
if localVarTempParam, localVarOk := localVarOptionals["string_"].(string); localVarOk {
|
||||
localVarFormParams.Add("string", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
localVarFormParams.Add("pattern_without_delimiter", parameterToString(patternWithoutDelimiter, ""))
|
||||
localVarFormParams.Add("byte", parameterToString(byte_, ""))
|
||||
if localVarTempParam, localVarOk := localVarOptionals["binary"].(string); localVarOk {
|
||||
localVarFormParams.Add("binary", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["date"].(string); localVarOk {
|
||||
localVarFormParams.Add("date", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["dateTime"].(time.Time); localVarOk {
|
||||
localVarFormParams.Add("dateTime", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["password"].(string); localVarOk {
|
||||
localVarFormParams.Add("password", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["callback"].(string); localVarOk {
|
||||
localVarFormParams.Add("callback", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService To test enum parameters
|
||||
To test enum parameters
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "enumFormStringArray" ([]string) Form parameter enum test (string array)
|
||||
@param "enumFormString" (string) Form parameter enum test (string)
|
||||
@param "enumHeaderStringArray" ([]string) Header parameter enum test (string array)
|
||||
@param "enumHeaderString" (string) Header parameter enum test (string)
|
||||
@param "enumQueryStringArray" ([]string) Query parameter enum test (string array)
|
||||
@param "enumQueryString" (string) Query parameter enum test (string)
|
||||
@param "enumQueryInteger" (int32) Query parameter enum test (double)
|
||||
@param "enumQueryDouble" (float64) Query parameter enum test (double)
|
||||
@return */
|
||||
func (a *FakeApiService) TestEnumParameters(ctx context.Context, localVarOptionals map[string]interface{}) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if err := typeCheckParameter(localVarOptionals["enumFormString"], "string", "enumFormString"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["enumHeaderString"], "string", "enumHeaderString"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["enumQueryString"], "string", "enumQueryString"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["enumQueryInteger"], "int32", "enumQueryInteger"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["enumQueryDouble"], "float64", "enumQueryDouble"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumQueryStringArray"].([]string); localVarOk {
|
||||
localVarQueryParams.Add("enum_query_string_array", parameterToString(localVarTempParam, "csv"))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumQueryString"].(string); localVarOk {
|
||||
localVarQueryParams.Add("enum_query_string", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumQueryInteger"].(int32); localVarOk {
|
||||
localVarQueryParams.Add("enum_query_integer", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"*/*"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"*/*"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumHeaderStringArray"].([]string); localVarOk {
|
||||
localVarHeaderParams["enum_header_string_array"] = parameterToString(localVarTempParam, "csv")
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumHeaderString"].(string); localVarOk {
|
||||
localVarHeaderParams["enum_header_string"] = parameterToString(localVarTempParam, "")
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumFormStringArray"].([]string); localVarOk {
|
||||
localVarFormParams.Add("enum_form_string_array", parameterToString(localVarTempParam, "csv"))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumFormString"].(string); localVarOk {
|
||||
localVarFormParams.Add("enum_form_string", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["enumQueryDouble"].(float64); localVarOk {
|
||||
localVarFormParams.Add("enum_query_double", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService test inline additionalProperties
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param param request body
|
||||
@return */
|
||||
func (a *FakeApiService) TestInlineAdditionalProperties(ctx context.Context, param interface{}) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake/inline-additionalProperties"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = ¶m
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* FakeApiService test json serialization of form data
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param param field1
|
||||
@param param2 field2
|
||||
@return */
|
||||
func (a *FakeApiService) TestJsonFormData(ctx context.Context, param string, param2 string) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake/jsonFormData"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
localVarFormParams.Add("param", parameterToString(param, ""))
|
||||
localVarFormParams.Add("param2", parameterToString(param2, ""))
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"golang.org/x/net/context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type FakeClassnameTags123ApiService service
|
||||
|
||||
/* FakeClassnameTags123ApiService To test class name in snake case
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body client model
|
||||
@return Client*/
|
||||
func (a *FakeClassnameTags123ApiService) TestClassname(ctx context.Context, body Client) (Client, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Patch")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload Client
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/fake_classname_test"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
if ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
|
||||
var key string
|
||||
if auth.Prefix != "" {
|
||||
key = auth.Prefix + " " + auth.Key
|
||||
} else {
|
||||
key = auth.Key
|
||||
}
|
||||
localVarQueryParams.Add("api_key_query", key)
|
||||
}
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
582
samples/client/petstore/go/go-petstore-withXml/api_pet.go
Normal file
582
samples/client/petstore/go/go-petstore-withXml/api_pet.go
Normal file
@ -0,0 +1,582 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"golang.org/x/net/context"
|
||||
"os"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type PetApiService service
|
||||
|
||||
/* PetApiService Add a new pet to the store
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body Pet object that needs to be added to the store
|
||||
@return */
|
||||
func (a *PetApiService) AddPet(ctx context.Context, body Pet) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json", "application/xml"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService Deletes a pet
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param petId Pet id to delete
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "apiKey" (string)
|
||||
@return */
|
||||
func (a *PetApiService) DeletePet(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Delete")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet/{petId}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if err := typeCheckParameter(localVarOptionals["apiKey"], "string", "apiKey"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["apiKey"].(string); localVarOk {
|
||||
localVarHeaderParams["api_key"] = parameterToString(localVarTempParam, "")
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService Finds Pets by status
|
||||
Multiple status values can be provided with comma separated strings
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param status Status values that need to be considered for filter
|
||||
@return []Pet*/
|
||||
func (a *PetApiService) FindPetsByStatus(ctx context.Context, status []string) ([]Pet, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload []Pet
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet/findByStatus"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
localVarQueryParams.Add("status", parameterToString(status, "csv"))
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService Finds Pets by tags
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param tags Tags to filter by
|
||||
@return []Pet*/
|
||||
func (a *PetApiService) FindPetsByTags(ctx context.Context, tags []string) ([]Pet, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload []Pet
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet/findByTags"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
localVarQueryParams.Add("tags", parameterToString(tags, "csv"))
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService Find pet by ID
|
||||
Returns a single pet
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param petId ID of pet to return
|
||||
@return Pet*/
|
||||
func (a *PetApiService) GetPetById(ctx context.Context, petId int64) (Pet, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload Pet
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet/{petId}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
|
||||
var key string
|
||||
if auth.Prefix != "" {
|
||||
key = auth.Prefix + " " + auth.Key
|
||||
} else {
|
||||
key = auth.Key
|
||||
}
|
||||
localVarHeaderParams["api_key"] = key
|
||||
}
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService Update an existing pet
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body Pet object that needs to be added to the store
|
||||
@return */
|
||||
func (a *PetApiService) UpdatePet(ctx context.Context, body Pet) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Put")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/json", "application/xml"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService Updates a pet in the store with form data
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param petId ID of pet that needs to be updated
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "name" (string) Updated name of the pet
|
||||
@param "status" (string) Updated status of the pet
|
||||
@return */
|
||||
func (a *PetApiService) UpdatePetWithForm(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet/{petId}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if err := typeCheckParameter(localVarOptionals["name"], "string", "name"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := typeCheckParameter(localVarOptionals["status"], "string", "status"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"application/x-www-form-urlencoded"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["name"].(string); localVarOk {
|
||||
localVarFormParams.Add("name", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["status"].(string); localVarOk {
|
||||
localVarFormParams.Add("status", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* PetApiService uploads an image
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param petId ID of pet to update
|
||||
@param optional (nil or map[string]interface{}) with one or more of:
|
||||
@param "additionalMetadata" (string) Additional data to pass to server
|
||||
@param "file" (*os.File) file to upload
|
||||
@return ModelApiResponse*/
|
||||
func (a *PetApiService) UploadFile(ctx context.Context, petId int64, localVarOptionals map[string]interface{}) (ModelApiResponse, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload ModelApiResponse
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/pet/{petId}/uploadImage"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"petId"+"}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if err := typeCheckParameter(localVarOptionals["additionalMetadata"], "string", "additionalMetadata"); err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{"multipart/form-data"}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if localVarTempParam, localVarOk := localVarOptionals["additionalMetadata"].(string); localVarOk {
|
||||
localVarFormParams.Add("additionalMetadata", parameterToString(localVarTempParam, ""))
|
||||
}
|
||||
var localVarFile (*os.File)
|
||||
if localVarTempParam, localVarOk := localVarOptionals["file"].(*os.File); localVarOk {
|
||||
localVarFile = localVarTempParam
|
||||
}
|
||||
if localVarFile != nil {
|
||||
fbs, _ := ioutil.ReadAll(localVarFile)
|
||||
localVarFileBytes = fbs
|
||||
localVarFileName = localVarFile.Name()
|
||||
localVarFile.Close()
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
308
samples/client/petstore/go/go-petstore-withXml/api_store.go
Normal file
308
samples/client/petstore/go/go-petstore-withXml/api_store.go
Normal file
@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"golang.org/x/net/context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type StoreApiService service
|
||||
|
||||
/* StoreApiService Delete purchase order by ID
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param orderId ID of the order that needs to be deleted
|
||||
@return */
|
||||
func (a *StoreApiService) DeleteOrder(ctx context.Context, orderId string) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Delete")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/store/order/{order_id}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* StoreApiService Returns pet inventories by status
|
||||
Returns a map of status codes to quantities
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@return map[string]int32*/
|
||||
func (a *StoreApiService) GetInventory(ctx context.Context) (map[string]int32, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload map[string]int32
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/store/inventory"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
if ctx != nil {
|
||||
// API Key Authentication
|
||||
if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok {
|
||||
var key string
|
||||
if auth.Prefix != "" {
|
||||
key = auth.Prefix + " " + auth.Key
|
||||
} else {
|
||||
key = auth.Key
|
||||
}
|
||||
localVarHeaderParams["api_key"] = key
|
||||
}
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* StoreApiService Find purchase order by ID
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param orderId ID of pet that needs to be fetched
|
||||
@return Order*/
|
||||
func (a *StoreApiService) GetOrderById(ctx context.Context, orderId int64) (Order, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload Order
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/store/order/{order_id}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"order_id"+"}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
if orderId < 1 {
|
||||
return successPayload, nil, reportError("orderId must be greater than 1")
|
||||
}
|
||||
if orderId > 5 {
|
||||
return successPayload, nil, reportError("orderId must be less than 5")
|
||||
}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* StoreApiService Place an order for a pet
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body order placed for purchasing the pet
|
||||
@return Order*/
|
||||
func (a *StoreApiService) PlaceOrder(ctx context.Context, body Order) (Order, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload Order
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/store/order"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
503
samples/client/petstore/go/go-petstore-withXml/api_user.go
Normal file
503
samples/client/petstore/go/go-petstore-withXml/api_user.go
Normal file
@ -0,0 +1,503 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"golang.org/x/net/context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Linger please
|
||||
var (
|
||||
_ context.Context
|
||||
)
|
||||
|
||||
type UserApiService service
|
||||
|
||||
/* UserApiService Create user
|
||||
This can only be done by the logged in user.
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body Created user object
|
||||
@return */
|
||||
func (a *UserApiService) CreateUser(ctx context.Context, body User) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Creates list of users with given input array
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body List of user object
|
||||
@return */
|
||||
func (a *UserApiService) CreateUsersWithArrayInput(ctx context.Context, body []User) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/createWithArray"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Creates list of users with given input array
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param body List of user object
|
||||
@return */
|
||||
func (a *UserApiService) CreateUsersWithListInput(ctx context.Context, body []User) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Post")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/createWithList"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Delete user
|
||||
This can only be done by the logged in user.
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param username The name that needs to be deleted
|
||||
@return */
|
||||
func (a *UserApiService) DeleteUser(ctx context.Context, username string) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Delete")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/{username}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Get user by user name
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param username The name that needs to be fetched. Use user1 for testing.
|
||||
@return User*/
|
||||
func (a *UserApiService) GetUserByName(ctx context.Context, username string) (User, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload User
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/{username}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Logs user into the system
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param username The user name for login
|
||||
@param password The password for login in clear text
|
||||
@return string*/
|
||||
func (a *UserApiService) LoginUser(ctx context.Context, username string, password string) (string, *http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
successPayload string
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/login"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
localVarQueryParams.Add("username", parameterToString(username, ""))
|
||||
localVarQueryParams.Add("password", parameterToString(password, ""))
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return successPayload, nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return successPayload, localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
contentType := localVarHttpResponse.Header.Get("content-type")
|
||||
if strings.Contains(contentType, "application/xml") {
|
||||
if err = xml.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
if err = json.NewDecoder(localVarHttpResponse.Body).Decode(&successPayload); err != nil {
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
return successPayload, localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Logs out current logged in user session
|
||||
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@return */
|
||||
func (a *UserApiService) LogoutUser(ctx context.Context) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Get")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/logout"
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
|
||||
/* UserApiService Updated user
|
||||
This can only be done by the logged in user.
|
||||
* @param ctx context.Context for authentication, logging, tracing, etc.
|
||||
@param username name that need to be deleted
|
||||
@param body Updated user object
|
||||
@return */
|
||||
func (a *UserApiService) UpdateUser(ctx context.Context, username string, body User) (*http.Response, error) {
|
||||
var (
|
||||
localVarHttpMethod = strings.ToUpper("Put")
|
||||
localVarPostBody interface{}
|
||||
localVarFileName string
|
||||
localVarFileBytes []byte
|
||||
)
|
||||
|
||||
// create path and map variables
|
||||
localVarPath := a.client.cfg.BasePath + "/user/{username}"
|
||||
localVarPath = strings.Replace(localVarPath, "{"+"username"+"}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
localVarHeaderParams := make(map[string]string)
|
||||
localVarQueryParams := url.Values{}
|
||||
localVarFormParams := url.Values{}
|
||||
|
||||
// to determine the Content-Type header
|
||||
localVarHttpContentTypes := []string{}
|
||||
|
||||
// set Content-Type header
|
||||
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||||
if localVarHttpContentType != "" {
|
||||
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||||
}
|
||||
|
||||
// to determine the Accept header
|
||||
localVarHttpHeaderAccepts := []string{"application/xml", "application/json"}
|
||||
|
||||
// set Accept header
|
||||
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||||
if localVarHttpHeaderAccept != "" {
|
||||
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||||
}
|
||||
// body params
|
||||
localVarPostBody = &body
|
||||
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localVarHttpResponse, err := a.client.callAPI(r)
|
||||
if err != nil || localVarHttpResponse == nil {
|
||||
return localVarHttpResponse, err
|
||||
}
|
||||
defer localVarHttpResponse.Body.Close()
|
||||
if localVarHttpResponse.StatusCode >= 300 {
|
||||
bodyBytes, _ := ioutil.ReadAll(localVarHttpResponse.Body)
|
||||
return localVarHttpResponse, reportError("Status: %v, Body: %s", localVarHttpResponse.Status, bodyBytes)
|
||||
}
|
||||
return localVarHttpResponse, err
|
||||
}
|
441
samples/client/petstore/go/go-petstore-withXml/client.go
Normal file
441
samples/client/petstore/go/go-petstore-withXml/client.go
Normal file
@ -0,0 +1,441 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
var (
|
||||
jsonCheck = regexp.MustCompile("(?i:[application|text]/json)")
|
||||
xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)")
|
||||
)
|
||||
|
||||
// APIClient manages communication with the Swagger Petstore API v1.0.0
|
||||
// In most cases there should be only one, shared, APIClient.
|
||||
type APIClient struct {
|
||||
cfg *Configuration
|
||||
common service // Reuse a single struct instead of allocating one for each service on the heap.
|
||||
|
||||
// API Services
|
||||
|
||||
AnotherFakeApi *AnotherFakeApiService
|
||||
|
||||
FakeApi *FakeApiService
|
||||
|
||||
FakeClassnameTags123Api *FakeClassnameTags123ApiService
|
||||
|
||||
PetApi *PetApiService
|
||||
|
||||
StoreApi *StoreApiService
|
||||
|
||||
UserApi *UserApiService
|
||||
}
|
||||
|
||||
type service struct {
|
||||
client *APIClient
|
||||
}
|
||||
|
||||
// NewAPIClient creates a new API client. Requires a userAgent string describing your application.
|
||||
// optionally a custom http.Client to allow for advanced features such as caching.
|
||||
func NewAPIClient(cfg *Configuration) *APIClient {
|
||||
if cfg.HTTPClient == nil {
|
||||
cfg.HTTPClient = http.DefaultClient
|
||||
}
|
||||
|
||||
c := &APIClient{}
|
||||
c.cfg = cfg
|
||||
c.common.client = c
|
||||
|
||||
// API Services
|
||||
c.AnotherFakeApi = (*AnotherFakeApiService)(&c.common)
|
||||
c.FakeApi = (*FakeApiService)(&c.common)
|
||||
c.FakeClassnameTags123Api = (*FakeClassnameTags123ApiService)(&c.common)
|
||||
c.PetApi = (*PetApiService)(&c.common)
|
||||
c.StoreApi = (*StoreApiService)(&c.common)
|
||||
c.UserApi = (*UserApiService)(&c.common)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func atoi(in string) (int, error) {
|
||||
return strconv.Atoi(in)
|
||||
}
|
||||
|
||||
// selectHeaderContentType select a content type from the available list.
|
||||
func selectHeaderContentType(contentTypes []string) string {
|
||||
if len(contentTypes) == 0 {
|
||||
return ""
|
||||
}
|
||||
if contains(contentTypes, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
return contentTypes[0] // use the first content type specified in 'consumes'
|
||||
}
|
||||
|
||||
// selectHeaderAccept join all accept types and return
|
||||
func selectHeaderAccept(accepts []string) string {
|
||||
if len(accepts) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
if contains(accepts, "application/json") {
|
||||
return "application/json"
|
||||
}
|
||||
|
||||
return strings.Join(accepts, ",")
|
||||
}
|
||||
|
||||
// contains is a case insenstive match, finding needle in a haystack
|
||||
func contains(haystack []string, needle string) bool {
|
||||
for _, a := range haystack {
|
||||
if strings.ToLower(a) == strings.ToLower(needle) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Verify optional parameters are of the correct type.
|
||||
func typeCheckParameter(obj interface{}, expected string, name string) error {
|
||||
// Make sure there is an object.
|
||||
if obj == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check the type is as expected.
|
||||
if reflect.TypeOf(obj).String() != expected {
|
||||
return fmt.Errorf("Expected %s to be of type %s but received %s.", name, expected, reflect.TypeOf(obj).String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// parameterToString convert interface{} parameters to string, using a delimiter if format is provided.
|
||||
func parameterToString(obj interface{}, collectionFormat string) string {
|
||||
var delimiter string
|
||||
|
||||
switch collectionFormat {
|
||||
case "pipes":
|
||||
delimiter = "|"
|
||||
case "ssv":
|
||||
delimiter = " "
|
||||
case "tsv":
|
||||
delimiter = "\t"
|
||||
case "csv":
|
||||
delimiter = ","
|
||||
}
|
||||
|
||||
if reflect.TypeOf(obj).Kind() == reflect.Slice {
|
||||
return strings.Trim(strings.Replace(fmt.Sprint(obj), " ", delimiter, -1), "[]")
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%v", obj)
|
||||
}
|
||||
|
||||
// callAPI do the request.
|
||||
func (c *APIClient) callAPI(request *http.Request) (*http.Response, error) {
|
||||
return c.cfg.HTTPClient.Do(request)
|
||||
}
|
||||
|
||||
// Change base path to allow switching to mocks
|
||||
func (c *APIClient) ChangeBasePath(path string) {
|
||||
c.cfg.BasePath = path
|
||||
}
|
||||
|
||||
// prepareRequest build the request
|
||||
func (c *APIClient) prepareRequest(
|
||||
ctx context.Context,
|
||||
path string, method string,
|
||||
postBody interface{},
|
||||
headerParams map[string]string,
|
||||
queryParams url.Values,
|
||||
formParams url.Values,
|
||||
fileName string,
|
||||
fileBytes []byte) (localVarRequest *http.Request, err error) {
|
||||
|
||||
var body *bytes.Buffer
|
||||
|
||||
// Detect postBody type and post.
|
||||
if postBody != nil {
|
||||
contentType := headerParams["Content-Type"]
|
||||
if contentType == "" {
|
||||
contentType = detectContentType(postBody)
|
||||
headerParams["Content-Type"] = contentType
|
||||
}
|
||||
|
||||
body, err = setBody(postBody, contentType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// add form parameters and file if available.
|
||||
if len(formParams) > 0 || (len(fileBytes) > 0 && fileName != "") {
|
||||
if body != nil {
|
||||
return nil, errors.New("Cannot specify postBody and multipart form at the same time.")
|
||||
}
|
||||
body = &bytes.Buffer{}
|
||||
w := multipart.NewWriter(body)
|
||||
|
||||
for k, v := range formParams {
|
||||
for _, iv := range v {
|
||||
if strings.HasPrefix(k, "@") { // file
|
||||
err = addFile(w, k[1:], iv)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else { // form value
|
||||
w.WriteField(k, iv)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(fileBytes) > 0 && fileName != "" {
|
||||
w.Boundary()
|
||||
//_, fileNm := filepath.Split(fileName)
|
||||
part, err := w.CreateFormFile("file", filepath.Base(fileName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = part.Write(fileBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Set the Boundary in the Content-Type
|
||||
headerParams["Content-Type"] = w.FormDataContentType()
|
||||
}
|
||||
|
||||
// Set Content-Length
|
||||
headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len())
|
||||
w.Close()
|
||||
}
|
||||
|
||||
// Setup path and query parameters
|
||||
url, err := url.Parse(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Adding Query Param
|
||||
query := url.Query()
|
||||
for k, v := range queryParams {
|
||||
for _, iv := range v {
|
||||
query.Add(k, iv)
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the parameters.
|
||||
url.RawQuery = query.Encode()
|
||||
|
||||
// Generate a new request
|
||||
if body != nil {
|
||||
localVarRequest, err = http.NewRequest(method, url.String(), body)
|
||||
} else {
|
||||
localVarRequest, err = http.NewRequest(method, url.String(), nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// add header parameters, if any
|
||||
if len(headerParams) > 0 {
|
||||
headers := http.Header{}
|
||||
for h, v := range headerParams {
|
||||
headers.Set(h, v)
|
||||
}
|
||||
localVarRequest.Header = headers
|
||||
}
|
||||
|
||||
// Override request host, if applicable
|
||||
if c.cfg.Host != "" {
|
||||
localVarRequest.Host = c.cfg.Host
|
||||
}
|
||||
|
||||
// Add the user agent to the request.
|
||||
localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent)
|
||||
|
||||
if ctx != nil {
|
||||
// add context to the request
|
||||
localVarRequest = localVarRequest.WithContext(ctx)
|
||||
|
||||
// Walk through any authentication.
|
||||
|
||||
// OAuth2 authentication
|
||||
if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok {
|
||||
// We were able to grab an oauth2 token from the context
|
||||
var latestToken *oauth2.Token
|
||||
if latestToken, err = tok.Token(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
latestToken.SetAuthHeader(localVarRequest)
|
||||
}
|
||||
|
||||
// Basic HTTP Authentication
|
||||
if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok {
|
||||
localVarRequest.SetBasicAuth(auth.UserName, auth.Password)
|
||||
}
|
||||
|
||||
// AccessToken Authentication
|
||||
if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
|
||||
localVarRequest.Header.Add("Authorization", "Bearer "+auth)
|
||||
}
|
||||
}
|
||||
|
||||
for header, value := range c.cfg.DefaultHeader {
|
||||
localVarRequest.Header.Add(header, value)
|
||||
}
|
||||
|
||||
return localVarRequest, nil
|
||||
}
|
||||
|
||||
// Add a file to the multipart request
|
||||
func addFile(w *multipart.Writer, fieldName, path string) error {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(part, file)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Prevent trying to import "fmt"
|
||||
func reportError(format string, a ...interface{}) error {
|
||||
return fmt.Errorf(format, a...)
|
||||
}
|
||||
|
||||
// Set request body from an interface{}
|
||||
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
|
||||
if bodyBuf == nil {
|
||||
bodyBuf = &bytes.Buffer{}
|
||||
}
|
||||
|
||||
if reader, ok := body.(io.Reader); ok {
|
||||
_, err = bodyBuf.ReadFrom(reader)
|
||||
} else if b, ok := body.([]byte); ok {
|
||||
_, err = bodyBuf.Write(b)
|
||||
} else if s, ok := body.(string); ok {
|
||||
_, err = bodyBuf.WriteString(s)
|
||||
} else if jsonCheck.MatchString(contentType) {
|
||||
err = json.NewEncoder(bodyBuf).Encode(body)
|
||||
} else if xmlCheck.MatchString(contentType) {
|
||||
xml.NewEncoder(bodyBuf).Encode(body)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if bodyBuf.Len() == 0 {
|
||||
err = fmt.Errorf("Invalid body type %s\n", contentType)
|
||||
return nil, err
|
||||
}
|
||||
return bodyBuf, nil
|
||||
}
|
||||
|
||||
// detectContentType method is used to figure out `Request.Body` content type for request header
|
||||
func detectContentType(body interface{}) string {
|
||||
contentType := "text/plain; charset=utf-8"
|
||||
kind := reflect.TypeOf(body).Kind()
|
||||
|
||||
switch kind {
|
||||
case reflect.Struct, reflect.Map, reflect.Ptr:
|
||||
contentType = "application/json; charset=utf-8"
|
||||
case reflect.String:
|
||||
contentType = "text/plain; charset=utf-8"
|
||||
default:
|
||||
if b, ok := body.([]byte); ok {
|
||||
contentType = http.DetectContentType(b)
|
||||
} else if kind == reflect.Slice {
|
||||
contentType = "application/json; charset=utf-8"
|
||||
}
|
||||
}
|
||||
|
||||
return contentType
|
||||
}
|
||||
|
||||
// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go
|
||||
type cacheControl map[string]string
|
||||
|
||||
func parseCacheControl(headers http.Header) cacheControl {
|
||||
cc := cacheControl{}
|
||||
ccHeader := headers.Get("Cache-Control")
|
||||
for _, part := range strings.Split(ccHeader, ",") {
|
||||
part = strings.Trim(part, " ")
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
if strings.ContainsRune(part, '=') {
|
||||
keyval := strings.Split(part, "=")
|
||||
cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",")
|
||||
} else {
|
||||
cc[part] = ""
|
||||
}
|
||||
}
|
||||
return cc
|
||||
}
|
||||
|
||||
// CacheExpires helper function to determine remaining time before repeating a request.
|
||||
func CacheExpires(r *http.Response) time.Time {
|
||||
// Figure out when the cache expires.
|
||||
var expires time.Time
|
||||
now, err := time.Parse(time.RFC1123, r.Header.Get("date"))
|
||||
if err != nil {
|
||||
return time.Now()
|
||||
}
|
||||
respCacheControl := parseCacheControl(r.Header)
|
||||
|
||||
if maxAge, ok := respCacheControl["max-age"]; ok {
|
||||
lifetime, err := time.ParseDuration(maxAge + "s")
|
||||
if err != nil {
|
||||
expires = now
|
||||
}
|
||||
expires = now.Add(lifetime)
|
||||
} else {
|
||||
expiresHeader := r.Header.Get("Expires")
|
||||
if expiresHeader != "" {
|
||||
expires, err = time.Parse(time.RFC1123, expiresHeader)
|
||||
if err != nil {
|
||||
expires = now
|
||||
}
|
||||
}
|
||||
}
|
||||
return expires
|
||||
}
|
||||
|
||||
func strlen(s string) int {
|
||||
return utf8.RuneCountInString(s)
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// contextKeys are used to identify the type of value in the context.
|
||||
// Since these are string, it is possible to get a short description of the
|
||||
// context key for logging and debugging using key.String().
|
||||
|
||||
type contextKey string
|
||||
|
||||
func (c contextKey) String() string {
|
||||
return "auth " + string(c)
|
||||
}
|
||||
|
||||
var (
|
||||
// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
|
||||
ContextOAuth2 = contextKey("token")
|
||||
|
||||
// ContextBasicAuth takes BasicAuth as authentication for the request.
|
||||
ContextBasicAuth = contextKey("basic")
|
||||
|
||||
// ContextAccessToken takes a string oauth2 access token as authentication for the request.
|
||||
ContextAccessToken = contextKey("accesstoken")
|
||||
|
||||
// ContextAPIKey takes an APIKey as authentication for the request
|
||||
ContextAPIKey = contextKey("apikey")
|
||||
)
|
||||
|
||||
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
|
||||
type BasicAuth struct {
|
||||
UserName string `json:"userName,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
// APIKey provides API key based authentication to a request passed via context using ContextAPIKey
|
||||
type APIKey struct {
|
||||
Key string
|
||||
Prefix string
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
BasePath string `json:"basePath,omitempty"`
|
||||
Host string `json:"host,omitempty"`
|
||||
Scheme string `json:"scheme,omitempty"`
|
||||
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
||||
UserAgent string `json:"userAgent,omitempty"`
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
func NewConfiguration() *Configuration {
|
||||
cfg := &Configuration{
|
||||
BasePath: "http://petstore.swagger.io:80/v2",
|
||||
DefaultHeader: make(map[string]string),
|
||||
UserAgent: "Swagger-Codegen/1.0.0/go",
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
||||
c.DefaultHeader[key] = value
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
# AdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MapProperty** | **map[string]string** | | [optional] [default to null]
|
||||
**MapOfMapProperty** | [**map[string]map[string]string**](map.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Animal
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ClassName** | **string** | | [default to null]
|
||||
**Color** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# AnimalFarm
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
# \AnotherFakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**TestSpecialTags**](AnotherFakeApi.md#TestSpecialTags) | **Patch** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
# **TestSpecialTags**
|
||||
> Client TestSpecialTags(ctx, body)
|
||||
To test special tags
|
||||
|
||||
To test special tags
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayArrayNumber** | [**[][]float32**](array.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayNumber** | **[]float32** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ArrayTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayOfString** | **[]string** | | [optional] [default to null]
|
||||
**ArrayArrayOfInteger** | [**[][]int64**](array.md) | | [optional] [default to null]
|
||||
**ArrayArrayOfModel** | [**[][]ReadOnlyFirst**](array.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
# Capitalization
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**SmallCamel** | **string** | | [optional] [default to null]
|
||||
**CapitalCamel** | **string** | | [optional] [default to null]
|
||||
**SmallSnake** | **string** | | [optional] [default to null]
|
||||
**CapitalSnake** | **string** | | [optional] [default to null]
|
||||
**SCAETHFlowPoints** | **string** | | [optional] [default to null]
|
||||
**ATT_NAME** | **string** | Name of the pet | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
12
samples/client/petstore/go/go-petstore-withXml/docs/Cat.md
Normal file
12
samples/client/petstore/go/go-petstore-withXml/docs/Cat.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Cat
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ClassName** | **string** | | [default to null]
|
||||
**Color** | **string** | | [optional] [default to null]
|
||||
**Declawed** | **bool** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Category
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id** | **int64** | | [optional] [default to null]
|
||||
**Name** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ClassModel
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Class** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# Client
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Client** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
12
samples/client/petstore/go/go-petstore-withXml/docs/Dog.md
Normal file
12
samples/client/petstore/go/go-petstore-withXml/docs/Dog.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Dog
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ClassName** | **string** | | [default to null]
|
||||
**Color** | **string** | | [optional] [default to null]
|
||||
**Breed** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# EnumArrays
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**JustSymbol** | **string** | | [optional] [default to null]
|
||||
**ArrayEnum** | **[]string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# EnumClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
# EnumTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**EnumString** | **string** | | [optional] [default to null]
|
||||
**EnumInteger** | **int32** | | [optional] [default to null]
|
||||
**EnumNumber** | **float64** | | [optional] [default to null]
|
||||
**OuterEnum** | [***OuterEnum**](OuterEnum.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
336
samples/client/petstore/go/go-petstore-withXml/docs/FakeApi.md
Normal file
336
samples/client/petstore/go/go-petstore-withXml/docs/FakeApi.md
Normal file
@ -0,0 +1,336 @@
|
||||
# \FakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**FakeOuterBooleanSerialize**](FakeApi.md#FakeOuterBooleanSerialize) | **Post** /fake/outer/boolean |
|
||||
[**FakeOuterCompositeSerialize**](FakeApi.md#FakeOuterCompositeSerialize) | **Post** /fake/outer/composite |
|
||||
[**FakeOuterNumberSerialize**](FakeApi.md#FakeOuterNumberSerialize) | **Post** /fake/outer/number |
|
||||
[**FakeOuterStringSerialize**](FakeApi.md#FakeOuterStringSerialize) | **Post** /fake/outer/string |
|
||||
[**TestClientModel**](FakeApi.md#TestClientModel) | **Patch** /fake | To test \"client\" model
|
||||
[**TestEndpointParameters**](FakeApi.md#TestEndpointParameters) | **Post** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
[**TestEnumParameters**](FakeApi.md#TestEnumParameters) | **Get** /fake | To test enum parameters
|
||||
[**TestInlineAdditionalProperties**](FakeApi.md#TestInlineAdditionalProperties) | **Post** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
[**TestJsonFormData**](FakeApi.md#TestJsonFormData) | **Get** /fake/jsonFormData | test json serialization of form data
|
||||
|
||||
|
||||
# **FakeOuterBooleanSerialize**
|
||||
> OuterBoolean FakeOuterBooleanSerialize(ctx, optional)
|
||||
|
||||
|
||||
Test serialization of outer boolean types
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterBoolean**](OuterBoolean.md)| Input boolean as post body |
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterBoolean**](OuterBoolean.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **FakeOuterCompositeSerialize**
|
||||
> OuterComposite FakeOuterCompositeSerialize(ctx, optional)
|
||||
|
||||
|
||||
Test serialization of object with outer number type
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body |
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterComposite**](OuterComposite.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **FakeOuterNumberSerialize**
|
||||
> OuterNumber FakeOuterNumberSerialize(ctx, optional)
|
||||
|
||||
|
||||
Test serialization of outer number types
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterNumber**](OuterNumber.md)| Input number as post body |
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterNumber**](OuterNumber.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **FakeOuterStringSerialize**
|
||||
> OuterString FakeOuterStringSerialize(ctx, optional)
|
||||
|
||||
|
||||
Test serialization of outer string types
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**OuterString**](OuterString.md)| Input string as post body |
|
||||
|
||||
### Return type
|
||||
|
||||
[**OuterString**](OuterString.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **TestClientModel**
|
||||
> Client TestClientModel(ctx, body)
|
||||
To test \"client\" model
|
||||
|
||||
To test \"client\" model
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **TestEndpointParameters**
|
||||
> TestEndpointParameters(ctx, number, double, patternWithoutDelimiter, byte_, optional)
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**number** | **float32**| None |
|
||||
**double** | **float64**| None |
|
||||
**patternWithoutDelimiter** | **string**| None |
|
||||
**byte_** | **string**| None |
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**number** | **float32**| None |
|
||||
**double** | **float64**| None |
|
||||
**patternWithoutDelimiter** | **string**| None |
|
||||
**byte_** | **string**| None |
|
||||
**integer** | **int32**| None |
|
||||
**int32_** | **int32**| None |
|
||||
**int64_** | **int64**| None |
|
||||
**float** | **float32**| None |
|
||||
**string_** | **string**| None |
|
||||
**binary** | **string**| None |
|
||||
**date** | **string**| None |
|
||||
**dateTime** | **time.Time**| None |
|
||||
**password** | **string**| None |
|
||||
**callback** | **string**| None |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[http_basic_test](../README.md#http_basic_test)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/xml; charset=utf-8, application/json; charset=utf-8
|
||||
- **Accept**: application/xml; charset=utf-8, application/json; charset=utf-8
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **TestEnumParameters**
|
||||
> TestEnumParameters(ctx, optional)
|
||||
To test enum parameters
|
||||
|
||||
To test enum parameters
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**enumFormStringArray** | [**[]string**](string.md)| Form parameter enum test (string array) |
|
||||
**enumFormString** | **string**| Form parameter enum test (string) | [default to -efg]
|
||||
**enumHeaderStringArray** | [**[]string**](string.md)| Header parameter enum test (string array) |
|
||||
**enumHeaderString** | **string**| Header parameter enum test (string) | [default to -efg]
|
||||
**enumQueryStringArray** | [**[]string**](string.md)| Query parameter enum test (string array) |
|
||||
**enumQueryString** | **string**| Query parameter enum test (string) | [default to -efg]
|
||||
**enumQueryInteger** | **int32**| Query parameter enum test (double) |
|
||||
**enumQueryDouble** | **float64**| Query parameter enum test (double) |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: */*
|
||||
- **Accept**: */*
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **TestInlineAdditionalProperties**
|
||||
> TestInlineAdditionalProperties(ctx, param)
|
||||
test inline additionalProperties
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**param** | [**interface{}**](interface{}.md)| request body |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **TestJsonFormData**
|
||||
> TestJsonFormData(ctx, param, param2)
|
||||
test json serialization of form data
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**param** | **string**| field1 |
|
||||
**param2** | **string**| field2 |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: Not defined
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,35 @@
|
||||
# \FakeClassnameTags123Api
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**TestClassname**](FakeClassnameTags123Api.md#TestClassname) | **Patch** /fake_classname_test | To test class name in snake case
|
||||
|
||||
|
||||
# **TestClassname**
|
||||
> Client TestClassname(ctx, body)
|
||||
To test class name in snake case
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**Client**](Client.md)| client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key_query](../README.md#api_key_query)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,22 @@
|
||||
# FormatTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Integer** | **int32** | | [optional] [default to null]
|
||||
**Int32_** | **int32** | | [optional] [default to null]
|
||||
**Int64_** | **int64** | | [optional] [default to null]
|
||||
**Number** | **float32** | | [default to null]
|
||||
**Float** | **float32** | | [optional] [default to null]
|
||||
**Double** | **float64** | | [optional] [default to null]
|
||||
**String_** | **string** | | [optional] [default to null]
|
||||
**Byte_** | **string** | | [default to null]
|
||||
**Binary** | **string** | | [optional] [default to null]
|
||||
**Date** | **string** | | [default to null]
|
||||
**DateTime** | [**time.Time**](time.Time.md) | | [optional] [default to null]
|
||||
**Uuid** | **string** | | [optional] [default to null]
|
||||
**Password** | **string** | | [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# HasOnlyReadOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Bar** | **string** | | [optional] [default to null]
|
||||
**Foo** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
10
samples/client/petstore/go/go-petstore-withXml/docs/List.md
Normal file
10
samples/client/petstore/go/go-petstore-withXml/docs/List.md
Normal file
@ -0,0 +1,10 @@
|
||||
# List
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Var123List** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# MapTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MapMapOfString** | [**map[string]map[string]string**](map.md) | | [optional] [default to null]
|
||||
**MapOfEnumString** | **map[string]string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# MixedPropertiesAndAdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Uuid** | **string** | | [optional] [default to null]
|
||||
**DateTime** | [**time.Time**](time.Time.md) | | [optional] [default to null]
|
||||
**Map_** | [**map[string]Animal**](Animal.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Model200Response
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | **int32** | | [optional] [default to null]
|
||||
**Class** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ModelApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Code** | **int32** | | [optional] [default to null]
|
||||
**Type_** | **string** | | [optional] [default to null]
|
||||
**Message** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ModelReturn
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Return_** | **int32** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
13
samples/client/petstore/go/go-petstore-withXml/docs/Name.md
Normal file
13
samples/client/petstore/go/go-petstore-withXml/docs/Name.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Name
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Name** | **int32** | | [default to null]
|
||||
**SnakeCase** | **int32** | | [optional] [default to null]
|
||||
**Property** | **string** | | [optional] [default to null]
|
||||
**Var123Number** | **int32** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# NumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**JustNumber** | **float32** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
15
samples/client/petstore/go/go-petstore-withXml/docs/Order.md
Normal file
15
samples/client/petstore/go/go-petstore-withXml/docs/Order.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Order
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id** | **int64** | | [optional] [default to null]
|
||||
**PetId** | **int64** | | [optional] [default to null]
|
||||
**Quantity** | **int32** | | [optional] [default to null]
|
||||
**ShipDate** | [**time.Time**](time.Time.md) | | [optional] [default to null]
|
||||
**Status** | **string** | Order Status | [optional] [default to null]
|
||||
**Complete** | **bool** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# OuterBoolean
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# OuterComposite
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**MyNumber** | [***OuterNumber**](OuterNumber.md) | | [optional] [default to null]
|
||||
**MyString** | [***OuterString**](OuterString.md) | | [optional] [default to null]
|
||||
**MyBoolean** | [***OuterBoolean**](OuterBoolean.md) | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# OuterEnum
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# OuterNumber
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# OuterString
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
15
samples/client/petstore/go/go-petstore-withXml/docs/Pet.md
Normal file
15
samples/client/petstore/go/go-petstore-withXml/docs/Pet.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Pet
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id** | **int64** | | [optional] [default to null]
|
||||
**Category** | [***Category**](Category.md) | | [optional] [default to null]
|
||||
**Name** | **string** | | [default to null]
|
||||
**PhotoUrls** | **[]string** | | [default to null]
|
||||
**Tags** | [**[]Tag**](Tag.md) | | [optional] [default to null]
|
||||
**Status** | **string** | pet status in the store | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
269
samples/client/petstore/go/go-petstore-withXml/docs/PetApi.md
Normal file
269
samples/client/petstore/go/go-petstore-withXml/docs/PetApi.md
Normal file
@ -0,0 +1,269 @@
|
||||
# \PetApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**AddPet**](PetApi.md#AddPet) | **Post** /pet | Add a new pet to the store
|
||||
[**DeletePet**](PetApi.md#DeletePet) | **Delete** /pet/{petId} | Deletes a pet
|
||||
[**FindPetsByStatus**](PetApi.md#FindPetsByStatus) | **Get** /pet/findByStatus | Finds Pets by status
|
||||
[**FindPetsByTags**](PetApi.md#FindPetsByTags) | **Get** /pet/findByTags | Finds Pets by tags
|
||||
[**GetPetById**](PetApi.md#GetPetById) | **Get** /pet/{petId} | Find pet by ID
|
||||
[**UpdatePet**](PetApi.md#UpdatePet) | **Put** /pet | Update an existing pet
|
||||
[**UpdatePetWithForm**](PetApi.md#UpdatePetWithForm) | **Post** /pet/{petId} | Updates a pet in the store with form data
|
||||
[**UploadFile**](PetApi.md#UploadFile) | **Post** /pet/{petId}/uploadImage | uploads an image
|
||||
|
||||
|
||||
# **AddPet**
|
||||
> AddPet(ctx, body)
|
||||
Add a new pet to the store
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **DeletePet**
|
||||
> DeletePet(ctx, petId, optional)
|
||||
Deletes a pet
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**petId** | **int64**| Pet id to delete |
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int64**| Pet id to delete |
|
||||
**apiKey** | **string**| |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **FindPetsByStatus**
|
||||
> []Pet FindPetsByStatus(ctx, status)
|
||||
Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**status** | [**[]string**](string.md)| Status values that need to be considered for filter |
|
||||
|
||||
### Return type
|
||||
|
||||
[**[]Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **FindPetsByTags**
|
||||
> []Pet FindPetsByTags(ctx, tags)
|
||||
Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**tags** | [**[]string**](string.md)| Tags to filter by |
|
||||
|
||||
### Return type
|
||||
|
||||
[**[]Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **GetPetById**
|
||||
> Pet GetPetById(ctx, petId)
|
||||
Find pet by ID
|
||||
|
||||
Returns a single pet
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**petId** | **int64**| ID of pet to return |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Pet**](Pet.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **UpdatePet**
|
||||
> UpdatePet(ctx, body)
|
||||
Update an existing pet
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json, application/xml
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **UpdatePetWithForm**
|
||||
> UpdatePetWithForm(ctx, petId, optional)
|
||||
Updates a pet in the store with form data
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**petId** | **int64**| ID of pet that needs to be updated |
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int64**| ID of pet that needs to be updated |
|
||||
**name** | **string**| Updated name of the pet |
|
||||
**status** | **string**| Updated status of the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/x-www-form-urlencoded
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **UploadFile**
|
||||
> ModelApiResponse UploadFile(ctx, petId, optional)
|
||||
uploads an image
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**petId** | **int64**| ID of pet to update |
|
||||
**optional** | **map[string]interface{}** | optional parameters | nil if no parameters
|
||||
|
||||
### Optional Parameters
|
||||
Optional parameters are passed through a map[string]interface{}.
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**petId** | **int64**| ID of pet to update |
|
||||
**additionalMetadata** | **string**| Additional data to pass to server |
|
||||
**file** | ***os.File**| file to upload |
|
||||
|
||||
### Return type
|
||||
|
||||
[**ModelApiResponse**](ApiResponse.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
[petstore_auth](../README.md#petstore_auth)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: multipart/form-data
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# ReadOnlyFirst
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Bar** | **string** | | [optional] [default to null]
|
||||
**Baz** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# SpecialModelName
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**SpecialPropertyName** | **int64** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
120
samples/client/petstore/go/go-petstore-withXml/docs/StoreApi.md
Normal file
120
samples/client/petstore/go/go-petstore-withXml/docs/StoreApi.md
Normal file
@ -0,0 +1,120 @@
|
||||
# \StoreApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**DeleteOrder**](StoreApi.md#DeleteOrder) | **Delete** /store/order/{order_id} | Delete purchase order by ID
|
||||
[**GetInventory**](StoreApi.md#GetInventory) | **Get** /store/inventory | Returns pet inventories by status
|
||||
[**GetOrderById**](StoreApi.md#GetOrderById) | **Get** /store/order/{order_id} | Find purchase order by ID
|
||||
[**PlaceOrder**](StoreApi.md#PlaceOrder) | **Post** /store/order | Place an order for a pet
|
||||
|
||||
|
||||
# **DeleteOrder**
|
||||
> DeleteOrder(ctx, orderId)
|
||||
Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**orderId** | **string**| ID of the order that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **GetInventory**
|
||||
> map[string]int32 GetInventory(ctx, )
|
||||
Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
### Required Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
**map[string]int32**
|
||||
|
||||
### Authorization
|
||||
|
||||
[api_key](../README.md#api_key)
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **GetOrderById**
|
||||
> Order GetOrderById(ctx, orderId)
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**orderId** | **int64**| ID of pet that needs to be fetched |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **PlaceOrder**
|
||||
> Order PlaceOrder(ctx, body)
|
||||
Place an order for a pet
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**Order**](Order.md)| order placed for purchasing the pet |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Order**](Order.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
11
samples/client/petstore/go/go-petstore-withXml/docs/Tag.md
Normal file
11
samples/client/petstore/go/go-petstore-withXml/docs/Tag.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Tag
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id** | **int64** | | [optional] [default to null]
|
||||
**Name** | **string** | | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
17
samples/client/petstore/go/go-petstore-withXml/docs/User.md
Normal file
17
samples/client/petstore/go/go-petstore-withXml/docs/User.md
Normal file
@ -0,0 +1,17 @@
|
||||
# User
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**Id** | **int64** | | [optional] [default to null]
|
||||
**Username** | **string** | | [optional] [default to null]
|
||||
**FirstName** | **string** | | [optional] [default to null]
|
||||
**LastName** | **string** | | [optional] [default to null]
|
||||
**Email** | **string** | | [optional] [default to null]
|
||||
**Password** | **string** | | [optional] [default to null]
|
||||
**Phone** | **string** | | [optional] [default to null]
|
||||
**UserStatus** | **int32** | User Status | [optional] [default to null]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
238
samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md
Normal file
238
samples/client/petstore/go/go-petstore-withXml/docs/UserApi.md
Normal file
@ -0,0 +1,238 @@
|
||||
# \UserApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**CreateUser**](UserApi.md#CreateUser) | **Post** /user | Create user
|
||||
[**CreateUsersWithArrayInput**](UserApi.md#CreateUsersWithArrayInput) | **Post** /user/createWithArray | Creates list of users with given input array
|
||||
[**CreateUsersWithListInput**](UserApi.md#CreateUsersWithListInput) | **Post** /user/createWithList | Creates list of users with given input array
|
||||
[**DeleteUser**](UserApi.md#DeleteUser) | **Delete** /user/{username} | Delete user
|
||||
[**GetUserByName**](UserApi.md#GetUserByName) | **Get** /user/{username} | Get user by user name
|
||||
[**LoginUser**](UserApi.md#LoginUser) | **Get** /user/login | Logs user into the system
|
||||
[**LogoutUser**](UserApi.md#LogoutUser) | **Get** /user/logout | Logs out current logged in user session
|
||||
[**UpdateUser**](UserApi.md#UpdateUser) | **Put** /user/{username} | Updated user
|
||||
|
||||
|
||||
# **CreateUser**
|
||||
> CreateUser(ctx, body)
|
||||
Create user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**User**](User.md)| Created user object |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **CreateUsersWithArrayInput**
|
||||
> CreateUsersWithArrayInput(ctx, body)
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**[]User**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **CreateUsersWithListInput**
|
||||
> CreateUsersWithListInput(ctx, body)
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**body** | [**[]User**](User.md)| List of user object |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **DeleteUser**
|
||||
> DeleteUser(ctx, username)
|
||||
Delete user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**username** | **string**| The name that needs to be deleted |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **GetUserByName**
|
||||
> User GetUserByName(ctx, username)
|
||||
Get user by user name
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**username** | **string**| The name that needs to be fetched. Use user1 for testing. |
|
||||
|
||||
### Return type
|
||||
|
||||
[**User**](User.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **LoginUser**
|
||||
> string LoginUser(ctx, username, password)
|
||||
Logs user into the system
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**username** | **string**| The user name for login |
|
||||
**password** | **string**| The password for login in clear text |
|
||||
|
||||
### Return type
|
||||
|
||||
**string**
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **LogoutUser**
|
||||
> LogoutUser(ctx, )
|
||||
Logs out current logged in user session
|
||||
|
||||
|
||||
|
||||
### Required Parameters
|
||||
This endpoint does not need any parameter.
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
||||
# **UpdateUser**
|
||||
> UpdateUser(ctx, username, body)
|
||||
Updated user
|
||||
|
||||
This can only be done by the logged in user.
|
||||
|
||||
### Required Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**ctx** | **context.Context** | context for logging, tracing, authentication, etc.
|
||||
**username** | **string**| name that need to be deleted |
|
||||
**body** | [**User**](User.md)| Updated user object |
|
||||
|
||||
### Return type
|
||||
|
||||
(empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
52
samples/client/petstore/go/go-petstore-withXml/git_push.sh
Normal file
52
samples/client/petstore/go/go-petstore-withXml/git_push.sh
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=`git remote`
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
// Model for testing model name starting with number
|
||||
type Model200Response struct {
|
||||
Name int32 `json:"name,omitempty" xml:"name"`
|
||||
|
||||
Class string `json:"class,omitempty" xml:"class"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type AdditionalPropertiesClass struct {
|
||||
MapProperty map[string]string `json:"map_property,omitempty" xml:"map_property"`
|
||||
|
||||
MapOfMapProperty map[string]map[string]string `json:"map_of_map_property,omitempty" xml:"map_of_map_property"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Animal struct {
|
||||
ClassName string `json:"className" xml:"className"`
|
||||
|
||||
Color string `json:"color,omitempty" xml:"color"`
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type AnimalFarm struct {
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type ModelApiResponse struct {
|
||||
Code int32 `json:"code,omitempty" xml:"code"`
|
||||
|
||||
Type_ string `json:"type,omitempty" xml:"type"`
|
||||
|
||||
Message string `json:"message,omitempty" xml:"message"`
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type ArrayOfArrayOfNumberOnly struct {
|
||||
ArrayArrayNumber [][]float32 `json:"ArrayArrayNumber,omitempty" xml:"ArrayArrayNumber"`
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type ArrayOfNumberOnly struct {
|
||||
ArrayNumber []float32 `json:"ArrayNumber,omitempty" xml:"ArrayNumber"`
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type ArrayTest struct {
|
||||
ArrayOfString []string `json:"array_of_string,omitempty" xml:"array_of_string"`
|
||||
|
||||
ArrayArrayOfInteger [][]int64 `json:"array_array_of_integer,omitempty" xml:"array_array_of_integer"`
|
||||
|
||||
ArrayArrayOfModel [][]ReadOnlyFirst `json:"array_array_of_model,omitempty" xml:"array_array_of_model"`
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Capitalization struct {
|
||||
SmallCamel string `json:"smallCamel,omitempty" xml:"smallCamel"`
|
||||
|
||||
CapitalCamel string `json:"CapitalCamel,omitempty" xml:"CapitalCamel"`
|
||||
|
||||
SmallSnake string `json:"small_Snake,omitempty" xml:"small_Snake"`
|
||||
|
||||
CapitalSnake string `json:"Capital_Snake,omitempty" xml:"Capital_Snake"`
|
||||
|
||||
SCAETHFlowPoints string `json:"SCA_ETH_Flow_Points,omitempty" xml:"SCA_ETH_Flow_Points"`
|
||||
|
||||
// Name of the pet
|
||||
ATT_NAME string `json:"ATT_NAME,omitempty" xml:"ATT_NAME"`
|
||||
}
|
19
samples/client/petstore/go/go-petstore-withXml/model_cat.go
Normal file
19
samples/client/petstore/go/go-petstore-withXml/model_cat.go
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Cat struct {
|
||||
ClassName string `json:"className" xml:"className"`
|
||||
|
||||
Color string `json:"color,omitempty" xml:"color"`
|
||||
|
||||
Declawed bool `json:"declawed,omitempty" xml:"declawed"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Category struct {
|
||||
Id int64 `json:"id,omitempty" xml:"id"`
|
||||
|
||||
Name string `json:"name,omitempty" xml:"name"`
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
// Model for testing model with \"_class\" property
|
||||
type ClassModel struct {
|
||||
Class string `json:"_class,omitempty" xml:"_class"`
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Client struct {
|
||||
Client string `json:"client,omitempty" xml:"client"`
|
||||
}
|
19
samples/client/petstore/go/go-petstore-withXml/model_dog.go
Normal file
19
samples/client/petstore/go/go-petstore-withXml/model_dog.go
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Dog struct {
|
||||
ClassName string `json:"className" xml:"className"`
|
||||
|
||||
Color string `json:"color,omitempty" xml:"color"`
|
||||
|
||||
Breed string `json:"breed,omitempty" xml:"breed"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type EnumArrays struct {
|
||||
JustSymbol string `json:"just_symbol,omitempty" xml:"just_symbol"`
|
||||
|
||||
ArrayEnum []string `json:"array_enum,omitempty" xml:"array_enum"`
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type EnumClass string
|
||||
|
||||
// List of EnumClass
|
||||
const (
|
||||
ABC EnumClass = "_abc"
|
||||
|
||||
EFG EnumClass = "-efg"
|
||||
|
||||
XYZ EnumClass = "(xyz)"
|
||||
)
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type EnumTest struct {
|
||||
EnumString string `json:"enum_string,omitempty" xml:"enum_string"`
|
||||
|
||||
EnumInteger int32 `json:"enum_integer,omitempty" xml:"enum_integer"`
|
||||
|
||||
EnumNumber float64 `json:"enum_number,omitempty" xml:"enum_number"`
|
||||
|
||||
OuterEnum *OuterEnum `json:"outerEnum,omitempty" xml:"outerEnum"`
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type FormatTest struct {
|
||||
Integer int32 `json:"integer,omitempty" xml:"integer"`
|
||||
|
||||
Int32_ int32 `json:"int32,omitempty" xml:"int32"`
|
||||
|
||||
Int64_ int64 `json:"int64,omitempty" xml:"int64"`
|
||||
|
||||
Number float32 `json:"number" xml:"number"`
|
||||
|
||||
Float float32 `json:"float,omitempty" xml:"float"`
|
||||
|
||||
Double float64 `json:"double,omitempty" xml:"double"`
|
||||
|
||||
String_ string `json:"string,omitempty" xml:"string"`
|
||||
|
||||
Byte_ string `json:"byte" xml:"byte"`
|
||||
|
||||
Binary string `json:"binary,omitempty" xml:"binary"`
|
||||
|
||||
Date string `json:"date" xml:"date"`
|
||||
|
||||
DateTime time.Time `json:"dateTime,omitempty" xml:"dateTime"`
|
||||
|
||||
Uuid string `json:"uuid,omitempty" xml:"uuid"`
|
||||
|
||||
Password string `json:"password" xml:"password"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type HasOnlyReadOnly struct {
|
||||
Bar string `json:"bar,omitempty" xml:"bar"`
|
||||
|
||||
Foo string `json:"foo,omitempty" xml:"foo"`
|
||||
}
|
15
samples/client/petstore/go/go-petstore-withXml/model_list.go
Normal file
15
samples/client/petstore/go/go-petstore-withXml/model_list.go
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type List struct {
|
||||
Var123List string `json:"123-list,omitempty" xml:"123-list"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type MapTest struct {
|
||||
MapMapOfString map[string]map[string]string `json:"map_map_of_string,omitempty" xml:"map_map_of_string"`
|
||||
|
||||
MapOfEnumString map[string]string `json:"map_of_enum_string,omitempty" xml:"map_of_enum_string"`
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type MixedPropertiesAndAdditionalPropertiesClass struct {
|
||||
Uuid string `json:"uuid,omitempty" xml:"uuid"`
|
||||
|
||||
DateTime time.Time `json:"dateTime,omitempty" xml:"dateTime"`
|
||||
|
||||
Map_ map[string]Animal `json:"map,omitempty" xml:"map"`
|
||||
}
|
22
samples/client/petstore/go/go-petstore-withXml/model_name.go
Normal file
22
samples/client/petstore/go/go-petstore-withXml/model_name.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
// Model for testing model name same as property name
|
||||
type Name struct {
|
||||
Name int32 `json:"name" xml:"name"`
|
||||
|
||||
SnakeCase int32 `json:"snake_case,omitempty" xml:"snake_case"`
|
||||
|
||||
Property string `json:"property,omitempty" xml:"property"`
|
||||
|
||||
Var123Number int32 `json:"123Number,omitempty" xml:"123Number"`
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type NumberOnly struct {
|
||||
JustNumber float32 `json:"JustNumber,omitempty" xml:"JustNumber"`
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
Id int64 `json:"id,omitempty" xml:"id"`
|
||||
|
||||
PetId int64 `json:"petId,omitempty" xml:"petId"`
|
||||
|
||||
Quantity int32 `json:"quantity,omitempty" xml:"quantity"`
|
||||
|
||||
ShipDate time.Time `json:"shipDate,omitempty" xml:"shipDate"`
|
||||
|
||||
// Order Status
|
||||
Status string `json:"status,omitempty" xml:"status"`
|
||||
|
||||
Complete bool `json:"complete,omitempty" xml:"complete"`
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterBoolean struct {
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterComposite struct {
|
||||
MyNumber *OuterNumber `json:"my_number,omitempty" xml:"my_number"`
|
||||
|
||||
MyString *OuterString `json:"my_string,omitempty" xml:"my_string"`
|
||||
|
||||
MyBoolean *OuterBoolean `json:"my_boolean,omitempty" xml:"my_boolean"`
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterEnum string
|
||||
|
||||
// List of OuterEnum
|
||||
const (
|
||||
PLACED OuterEnum = "placed"
|
||||
|
||||
APPROVED OuterEnum = "approved"
|
||||
|
||||
DELIVERED OuterEnum = "delivered"
|
||||
)
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterNumber struct {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type OuterString struct {
|
||||
}
|
26
samples/client/petstore/go/go-petstore-withXml/model_pet.go
Normal file
26
samples/client/petstore/go/go-petstore-withXml/model_pet.go
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Pet struct {
|
||||
Id int64 `json:"id,omitempty" xml:"id"`
|
||||
|
||||
Category *Category `json:"category,omitempty" xml:"category"`
|
||||
|
||||
Name string `json:"name" xml:"name"`
|
||||
|
||||
PhotoUrls []string `json:"photoUrls" xml:"photoUrls"`
|
||||
|
||||
Tags []Tag `json:"tags,omitempty" xml:"tags"`
|
||||
|
||||
// pet status in the store
|
||||
Status string `json:"status,omitempty" xml:"status"`
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type ReadOnlyFirst struct {
|
||||
Bar string `json:"bar,omitempty" xml:"bar"`
|
||||
|
||||
Baz string `json:"baz,omitempty" xml:"baz"`
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
// Model for testing reserved words
|
||||
type ModelReturn struct {
|
||||
Return_ int32 `json:"return,omitempty" xml:"return"`
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type SpecialModelName struct {
|
||||
SpecialPropertyName int64 `json:"$special[property.name],omitempty" xml:"$special[property.name]"`
|
||||
}
|
17
samples/client/petstore/go/go-petstore-withXml/model_tag.go
Normal file
17
samples/client/petstore/go/go-petstore-withXml/model_tag.go
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Swagger Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* API version: 1.0.0
|
||||
* Contact: apiteam@swagger.io
|
||||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||||
*/
|
||||
|
||||
package petstore
|
||||
|
||||
type Tag struct {
|
||||
Id int64 `json:"id,omitempty" xml:"id"`
|
||||
|
||||
Name string `json:"name,omitempty" xml:"name"`
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user