openapi-generator/samples/client/petstore-security-test/go
Matthias Ramsauer 6acf45a108 x-www-form-urlencoded-body-fix (#1187)
* [go] x-www-form-urlencoded-body-fix

* [go] run scripts in bin and bin/security
2018-10-10 12:24:15 +08:00
..
.openapi-generator x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
api x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
docs x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
.gitignore Add more security samples (#3344) 2016-07-12 19:51:28 +08:00
.openapi-generator-ignore Regenerate samples (#367) 2018-05-08 16:44:51 +08:00
.travis.yml Add more security samples (#3344) 2016-07-12 19:51:28 +08:00
api_client.go [go] Fix go client formatting (#7283) 2018-01-07 11:53:55 +08:00
api_fake.go x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
api_response.go [go] Fix go client formatting (#7283) 2018-01-07 11:53:55 +08:00
client.go x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
configuration.go x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
fake_api.go [go] Fix go client formatting (#7283) 2018-01-07 11:53:55 +08:00
git_push.sh Regenerate samples (#367) 2018-05-08 16:44:51 +08:00
LICENSE Add more security samples (#3344) 2016-07-12 19:51:28 +08:00
model_return.go Regenerate samples (#367) 2018-05-08 16:44:51 +08:00
README.md x-www-form-urlencoded-body-fix (#1187) 2018-10-10 12:24:15 +08:00
response.go Regenerate samples (#367) 2018-05-08 16:44:51 +08:00

Go API client for openapi

This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: " \ *_/ ' " =end --

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 *_/ ' " =end -- \r\n \n \r
  • 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 / ' " =end -- \r\n \n \r/v2 */ ' " =end -- \r\n \n \r

Class Method HTTP request Description
FakeApi TestCodeInjectEndRnNR Put /fake To test code injection *_/ ' " =end -- \r\n \n \r

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 *_/ ' " =end -- \r\n \n \r
  • read:pets: read your pets *_/ ' " =end -- \r\n \n \r

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

something@something.abc *_/ ' " =end -- \r\n \n \r