forked from loafle/openapi-generator-original
[core] Initial FeatureSet structures and definitions Add default feature set to DefaultCodegen Initial FeatureSet definitions for: * ada * android * apache2 * asciidoc * aspnetcore * avro * bash * c * clojure * cpp-pistache-server * cpp-qt5-client * cpp-qt5-qhttpengine-server * cpp-restbed-server * cpp-restsdk * cpp-tizen * csharp * csharp-nancyfx * csharp-netcore * cwiki * dart * eiffel * elixir * elm * erlang * flash * fsharp-functions * go Client/Server * graphql-nodejs-express-server * graphql-schema * groovy * haskell * haskell-http-client * java * jmeter * kotlin * kotlin vertx * kotlin-server * kotlin-spring * lua * mysql * nim * nodejs * nodejs-express * objc * ocaml * openapi * openapi-yaml * perl * php * php-laravel * php-lumen * php-silex * php-slim * php-symfony * php-ze-ph * powershell * protobuf * protobuf-schema * python * python-aiohttp * python-blueplanet * python-experimental * r * ror * ruby * ruby * ruby-sinatra * rust * scala-akka * scala-finch * scala-gatling * scala-http-client * scala-lagom * scala-play * scalatra * scalaz * spring * static docs * swift * typescript
9.2 KiB
9.2 KiB
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 OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
go get github.com/antihax/optional
Put the package under your project folder and add the following in import:
import "./petstore"
Documentation for API Endpoints
All URIs are relative to http://petstore.swagger.io:80/v2
Class | Method | HTTP request | Description |
---|---|---|---|
AnotherFakeApi | Call123TestSpecialTags | Patch /another-fake/dummy | To test special tags |
FakeApi | CreateXmlItem | Post /fake/create_xml_item | creates an XmlItem |
FakeApi | FakeOuterBooleanSerialize | Post /fake/outer/boolean | |
FakeApi | FakeOuterCompositeSerialize | Post /fake/outer/composite | |
FakeApi | FakeOuterNumberSerialize | Post /fake/outer/number | |
FakeApi | FakeOuterStringSerialize | Post /fake/outer/string | |
FakeApi | TestBodyWithFileSchema | Put /fake/body-with-file-schema | |
FakeApi | TestBodyWithQueryParams | Put /fake/body-with-query-params | |
FakeApi | TestClientModel | Patch /fake | To test "client" model |
FakeApi | TestEndpointParameters | Post /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 |
FakeApi | TestEnumParameters | Get /fake | To test enum parameters |
FakeApi | TestGroupParameters | Delete /fake | Fake endpoint to test group parameters (optional) |
FakeApi | TestInlineAdditionalProperties | Post /fake/inline-additionalProperties | test inline additionalProperties |
FakeApi | TestJsonFormData | Get /fake/jsonFormData | test json serialization of form data |
FakeApi | TestQueryParameterCollectionFormat | Put /fake/test-query-paramters | |
FakeClassnameTags123Api | TestClassname | Patch /fake_classname_test | To test class name in snake case |
PetApi | AddPet | Post /pet | Add a new pet to the store |
PetApi | DeletePet | Delete /pet/{petId} | Deletes a pet |
PetApi | FindPetsByStatus | Get /pet/findByStatus | Finds Pets by status |
PetApi | FindPetsByTags | Get /pet/findByTags | Finds Pets by tags |
PetApi | GetPetById | Get /pet/{petId} | Find pet by ID |
PetApi | UpdatePet | Put /pet | Update an existing pet |
PetApi | UpdatePetWithForm | Post /pet/{petId} | Updates a pet in the store with form data |
PetApi | UploadFile | Post /pet/{petId}/uploadImage | uploads an image |
PetApi | UploadFileWithRequiredFile | Post /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required) |
StoreApi | DeleteOrder | Delete /store/order/{order_id} | Delete purchase order by ID |
StoreApi | GetInventory | Get /store/inventory | Returns pet inventories by status |
StoreApi | GetOrderById | Get /store/order/{order_id} | Find purchase order by ID |
StoreApi | PlaceOrder | Post /store/order | Place an order for a pet |
UserApi | CreateUser | Post /user | Create user |
UserApi | CreateUsersWithArrayInput | Post /user/createWithArray | Creates list of users with given input array |
UserApi | CreateUsersWithListInput | Post /user/createWithList | Creates list of users with given input array |
UserApi | DeleteUser | Delete /user/{username} | Delete user |
UserApi | GetUserByName | Get /user/{username} | Get user by user name |
UserApi | LoginUser | Get /user/login | Logs user into the system |
UserApi | LogoutUser | Get /user/logout | Logs out current logged in user session |
UserApi | UpdateUser | Put /user/{username} | Updated user |
Documentation For Models
- AdditionalPropertiesAnyType
- AdditionalPropertiesArray
- AdditionalPropertiesBoolean
- AdditionalPropertiesClass
- AdditionalPropertiesInteger
- AdditionalPropertiesNumber
- AdditionalPropertiesObject
- AdditionalPropertiesString
- Animal
- ApiResponse
- ArrayOfArrayOfNumberOnly
- ArrayOfNumberOnly
- ArrayTest
- BigCat
- BigCatAllOf
- Capitalization
- Cat
- CatAllOf
- Category
- ClassModel
- Client
- Dog
- DogAllOf
- EnumArrays
- EnumClass
- EnumTest
- File
- FileSchemaTestClass
- FormatTest
- HasOnlyReadOnly
- List
- MapTest
- MixedPropertiesAndAdditionalPropertiesClass
- Model200Response
- Name
- NumberOnly
- Order
- OuterComposite
- OuterEnum
- Pet
- ReadOnlyFirst
- Return
- SpecialModelName
- Tag
- TypeHolderDefault
- TypeHolderExample
- User
- XmlItem
Documentation For Authorization
api_key
- Type: API key
Example
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
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
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
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.
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)