aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/openapi/go/README.mustache
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-02-18 14:49:11 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-02-18 14:49:11 +0100
commitd5edf22aadfb6a18268c5eb6e172c7bef55e240c (patch)
treea5221fd1a246122ff95182c9dc1d1fb115dfd483 /support/openapi/go/README.mustache
parent71e75ef27e8f993eaafc73896ac6f22fe91df64a (diff)
parent170cd639a7ed591184fde23968b2d24dac630e45 (diff)
downloadPeerTube-d5edf22aadfb6a18268c5eb6e172c7bef55e240c.tar.gz
PeerTube-d5edf22aadfb6a18268c5eb6e172c7bef55e240c.tar.zst
PeerTube-d5edf22aadfb6a18268c5eb6e172c7bef55e240c.zip
Merge branch 'feature/better-openapi-readmes' into 'develop'
See merge request framasoft/peertube/PeerTube!29
Diffstat (limited to 'support/openapi/go/README.mustache')
-rw-r--r--support/openapi/go/README.mustache121
1 files changed, 121 insertions, 0 deletions
diff --git a/support/openapi/go/README.mustache b/support/openapi/go/README.mustache
new file mode 100644
index 000000000..d0fc0fa33
--- /dev/null
+++ b/support/openapi/go/README.mustache
@@ -0,0 +1,121 @@
1# Go API client for {{appName}}
2
3This Python package is automatically generated from [PeerTube's REST API](https://docs.joinpeertube.org/api-rest-reference.html),
4using the [OpenAPI Generator](https://openapi-generator.tech) project:
5
6- API version: {{appVersion}}
7- Package version: {{packageVersion}}
8{{^hideGenerationTimestamp}}
9- Build date: {{generatedDate}}
10{{/hideGenerationTimestamp}}
11- Build package: {{generatorClass}}
12
13{{#infoUrl}}
14For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
15{{/infoUrl}}
16
17## Installation
18
19Install the following dependencies:
20
21```shell
22go get github.com/stretchr/testify/assert
23go get golang.org/x/oauth2
24go get golang.org/x/net/context
25go get github.com/antihax/optional
26```
27
28Put the package under your project folder and add the following in import:
29
30```golang
31import "./{{packageName}}"
32```
33
34## Documentation for API Endpoints
35
36All URIs are relative to *{{basePath}}*
37
38Class | Method | HTTP request | Description
39------------ | ------------- | ------------- | -------------
40{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
41{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
42
43## Documentation For Models
44
45{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
46{{/model}}{{/models}}
47
48## Documentation For Authorization
49
50{{^authMethods}} Endpoints do not require authorization.
51{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
52{{#authMethods}}
53
54## {{{name}}}
55
56{{#isApiKey}}- **Type**: API key
57
58Example
59
60```golang
61auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
62 Key: "APIKEY",
63 Prefix: "Bearer", // Omit if not necessary.
64})
65r, err := client.Service.Operation(auth, args)
66```
67
68{{/isApiKey}}
69{{#isBasic}}- **Type**: HTTP basic authentication
70
71Example
72
73```golang
74auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
75 UserName: "username",
76 Password: "password",
77})
78r, err := client.Service.Operation(auth, args)
79```
80
81{{/isBasic}}
82{{#isOAuth}}
83
84- **Type**: OAuth
85- **Flow**: {{{flow}}}
86- **Authorization URL**: {{{authorizationUrl}}}
87- **Scopes**: {{^scopes}}N/A{{/scopes}}
88{{#scopes}} - **{{{scope}}}**: {{{description}}}
89{{/scopes}}
90
91Example
92
93```golang
94auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
95r, err := client.Service.Operation(auth, args)
96```
97
98Or via OAuth2 module to automatically refresh tokens and perform user authentication.
99
100```golang
101import "golang.org/x/oauth2"
102
103/* Perform OAuth2 round trip request and obtain a token */
104
105tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
106auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
107r, err := client.Service.Operation(auth, args)
108```
109
110{{/isOAuth}}
111{{/authMethods}}
112
113## License
114
115Copyright (C) 2015-2020 PeerTube Contributors
116
117This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
118
119This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
120
121You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses.