mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 15:51:38 +00:00
* Iniital docusaurus based site * Remove error about default local being used by String.format * Change pinned users to represent global presence rather than alphabetical order pinning * Include generator indexes in ensure-up-to-date (docusaurus site and /generators/README) * Add Font Awesome attribution footer * Remove feature callout until it is completed * Include NPM try it out section * Improve "Getting Started" type docs * Include new custom template documentation * Updating templating and customization docs * Add vendor extension docs * Cleanup templating page(s). * Move users to yaml file for easy edit. * travis configuration, and baseUrl mods to image URLs * [docs] Migrate FAQ, release summary from wiki FAQ has been split into multiple smaller documents to better categorize and allow users to find what they're looking for (in docs folder or in new website). Release summary information (versioning strategy and cadence) has been migrated from the Wiki and clarified a bit. Also adds copy button for all code snippets in website. * Copy current contributing/code of conduct to website * [docs] Creating a new generator
4.5 KiB
Executable File
4.5 KiB
Executable File
Go API client for openapi
This is a sample server Petstore server. For this sample, you can use the api key special-key to test the authorization filters.
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 "./openapi"
Documentation for API Endpoints
All URIs are relative to http://petstore.swagger.io/v2
| Class | Method | HTTP request | Description |
|---|---|---|---|
| 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 |
| StoreApi | DeleteOrder | Delete /store/order/{orderId} | Delete purchase order by ID |
| StoreApi | GetInventory | Get /store/inventory | Returns pet inventories by status |
| StoreApi | GetOrderById | Get /store/order/{orderId} | 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
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)
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)