package
4.0.0-beta2+incompatible
Repository: https://github.com/volatiletech/openapi-generator.git
Documentation: pkg.go.dev

# README

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

ClassMethodHTTP requestDescription
AnotherFakeApiCall123TestSpecialTagsPatch /another-fake/dummyTo test special tags
FakeApiCreateXmlItemPost /fake/create_xml_itemcreates an XmlItem
FakeApiFakeOuterBooleanSerializePost /fake/outer/boolean
FakeApiFakeOuterCompositeSerializePost /fake/outer/composite
FakeApiFakeOuterNumberSerializePost /fake/outer/number
FakeApiFakeOuterStringSerializePost /fake/outer/string
FakeApiTestBodyWithFileSchemaPut /fake/body-with-file-schema
FakeApiTestBodyWithQueryParamsPut /fake/body-with-query-params
FakeApiTestClientModelPatch /fakeTo test "client" model
FakeApiTestEndpointParametersPost /fakeFake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
FakeApiTestEnumParametersGet /fakeTo test enum parameters
FakeApiTestGroupParametersDelete /fakeFake endpoint to test group parameters (optional)
FakeApiTestInlineAdditionalPropertiesPost /fake/inline-additionalPropertiestest inline additionalProperties
FakeApiTestJsonFormDataGet /fake/jsonFormDatatest json serialization of form data
FakeClassnameTags123ApiTestClassnamePatch /fake_classname_testTo test class name in snake case
PetApiAddPetPost /petAdd a new pet to the store
PetApiDeletePetDelete /pet/{petId}Deletes a pet
PetApiFindPetsByStatusGet /pet/findByStatusFinds Pets by status
PetApiFindPetsByTagsGet /pet/findByTagsFinds Pets by tags
PetApiGetPetByIdGet /pet/{petId}Find pet by ID
PetApiUpdatePetPut /petUpdate an existing pet
PetApiUpdatePetWithFormPost /pet/{petId}Updates a pet in the store with form data
PetApiUploadFilePost /pet/{petId}/uploadImageuploads an image
PetApiUploadFileWithRequiredFilePost /fake/{petId}/uploadImageWithRequiredFileuploads an image (required)
StoreApiDeleteOrderDelete /store/order/{order_id}Delete purchase order by ID
StoreApiGetInventoryGet /store/inventoryReturns pet inventories by status
StoreApiGetOrderByIdGet /store/order/{order_id}Find purchase order by ID
StoreApiPlaceOrderPost /store/orderPlace an order for a pet
UserApiCreateUserPost /userCreate user
UserApiCreateUsersWithArrayInputPost /user/createWithArrayCreates list of users with given input array
UserApiCreateUsersWithListInputPost /user/createWithListCreates list of users with given input array
UserApiDeleteUserDelete /user/{username}Delete user
UserApiGetUserByNameGet /user/{username}Get user by user name
UserApiLoginUserGet /user/loginLogs user into the system
UserApiLogoutUserGet /user/logoutLogs out current logged in user session
UserApiUpdateUserPut /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)

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

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)

Author