|
| 1 | +# Go API client for {{packageName}} |
| 2 | + |
| 3 | +{{#appDescription}} |
| 4 | +{{{appDescription}}} |
| 5 | +{{/appDescription}} |
| 6 | + |
| 7 | +## Overview |
| 8 | +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. |
| 9 | + |
| 10 | +- API version: {{appVersion}} |
| 11 | +- Package version: {{packageVersion}} |
| 12 | +{{^hideGenerationTimestamp}} |
| 13 | +- Build date: {{generatedDate}} |
| 14 | +{{/hideGenerationTimestamp}} |
| 15 | +- Build package: {{generatorClass}} |
| 16 | +{{#infoUrl}} |
| 17 | +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) |
| 18 | +{{/infoUrl}} |
| 19 | + |
| 20 | +## Installation |
| 21 | + |
| 22 | +Install the following dependencies: |
| 23 | + |
| 24 | +```shell |
| 25 | +go get github.com/stretchr/testify/assert |
| 26 | +go get golang.org/x/oauth2 |
| 27 | +go get golang.org/x/net/context |
| 28 | +go get github.com/antihax/optional |
| 29 | +``` |
| 30 | + |
| 31 | +Put the package under your project folder and add the following in import: |
| 32 | + |
| 33 | +```golang |
| 34 | +import "./{{packageName}}" |
| 35 | +``` |
| 36 | + |
| 37 | +## Documentation for API Endpoints |
| 38 | + |
| 39 | +All URIs are relative to *{{basePath}}* |
| 40 | + |
| 41 | +Class | Method | HTTP request | Description |
| 42 | +------------ | ------------- | ------------- | ------------- |
| 43 | +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} |
| 44 | +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} |
| 45 | + |
| 46 | +## Documentation For Models |
| 47 | + |
| 48 | +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) |
| 49 | +{{/model}}{{/models}} |
| 50 | + |
| 51 | +## Documentation For Authorization |
| 52 | + |
| 53 | +{{^authMethods}} Endpoints do not require authorization. |
| 54 | +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} |
| 55 | +{{#authMethods}} |
| 56 | + |
| 57 | +## {{{name}}} |
| 58 | + |
| 59 | +{{#isApiKey}}- **Type**: API key |
| 60 | + |
| 61 | +Example |
| 62 | + |
| 63 | +```golang |
| 64 | +auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ |
| 65 | + Key: "APIKEY", |
| 66 | + Prefix: "Bearer", // Omit if not necessary. |
| 67 | +}) |
| 68 | +r, err := client.Service.Operation(auth, args) |
| 69 | +``` |
| 70 | + |
| 71 | +{{/isApiKey}} |
| 72 | +{{#isBasic}}- **Type**: HTTP basic authentication |
| 73 | + |
| 74 | +Example |
| 75 | + |
| 76 | +```golang |
| 77 | +auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{ |
| 78 | + UserName: "username", |
| 79 | + Password: "password", |
| 80 | +}) |
| 81 | +r, err := client.Service.Operation(auth, args) |
| 82 | +``` |
| 83 | + |
| 84 | +{{/isBasic}} |
| 85 | +{{#isOAuth}} |
| 86 | + |
| 87 | +- **Type**: OAuth |
| 88 | +- **Flow**: {{{flow}}} |
| 89 | +- **Authorization URL**: {{{authorizationUrl}}} |
| 90 | +- **Scopes**: {{^scopes}}N/A{{/scopes}} |
| 91 | +{{#scopes}} - **{{{scope}}}**: {{{description}}} |
| 92 | +{{/scopes}} |
| 93 | + |
| 94 | +Example |
| 95 | + |
| 96 | +```golang |
| 97 | +auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING") |
| 98 | +r, err := client.Service.Operation(auth, args) |
| 99 | +``` |
| 100 | + |
| 101 | +Or via OAuth2 module to automatically refresh tokens and perform user authentication. |
| 102 | + |
| 103 | +```golang |
| 104 | +import "golang.org/x/oauth2" |
| 105 | + |
| 106 | +/* Perform OAuth2 round trip request and obtain a token */ |
| 107 | + |
| 108 | +tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) |
| 109 | +auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource) |
| 110 | +r, err := client.Service.Operation(auth, args) |
| 111 | +``` |
| 112 | + |
| 113 | +{{/isOAuth}} |
| 114 | +{{/authMethods}} |
| 115 | + |
| 116 | +## Author |
| 117 | + |
| 118 | +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} |
| 119 | +{{/hasMore}}{{/apis}}{{/apiInfo}} |
0 commit comments