aboutsummaryrefslogtreecommitdiffhomepage
path: root/support/openapi/go
diff options
context:
space:
mode:
Diffstat (limited to 'support/openapi/go')
-rw-r--r--support/openapi/go/README.mustache121
-rw-r--r--support/openapi/go/def.yaml3
2 files changed, 124 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.
diff --git a/support/openapi/go/def.yaml b/support/openapi/go/def.yaml
new file mode 100644
index 000000000..7136da912
--- /dev/null
+++ b/support/openapi/go/def.yaml
@@ -0,0 +1,3 @@
1# https://openapi-generator.tech/docs/generators/go
2
3packageName: peertube