diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-02-18 14:49:11 +0100 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-02-18 14:49:11 +0100 |
commit | d5edf22aadfb6a18268c5eb6e172c7bef55e240c (patch) | |
tree | a5221fd1a246122ff95182c9dc1d1fb115dfd483 /support/openapi/go/README.mustache | |
parent | 71e75ef27e8f993eaafc73896ac6f22fe91df64a (diff) | |
parent | 170cd639a7ed591184fde23968b2d24dac630e45 (diff) | |
download | PeerTube-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.mustache | 121 |
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 | |||
3 | This Python package is automatically generated from [PeerTube's REST API](https://docs.joinpeertube.org/api-rest-reference.html), | ||
4 | using 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}} | ||
14 | For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) | ||
15 | {{/infoUrl}} | ||
16 | |||
17 | ## Installation | ||
18 | |||
19 | Install the following dependencies: | ||
20 | |||
21 | ```shell | ||
22 | go get github.com/stretchr/testify/assert | ||
23 | go get golang.org/x/oauth2 | ||
24 | go get golang.org/x/net/context | ||
25 | go get github.com/antihax/optional | ||
26 | ``` | ||
27 | |||
28 | Put the package under your project folder and add the following in import: | ||
29 | |||
30 | ```golang | ||
31 | import "./{{packageName}}" | ||
32 | ``` | ||
33 | |||
34 | ## Documentation for API Endpoints | ||
35 | |||
36 | All URIs are relative to *{{basePath}}* | ||
37 | |||
38 | Class | 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 | |||
58 | Example | ||
59 | |||
60 | ```golang | ||
61 | auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{ | ||
62 | Key: "APIKEY", | ||
63 | Prefix: "Bearer", // Omit if not necessary. | ||
64 | }) | ||
65 | r, err := client.Service.Operation(auth, args) | ||
66 | ``` | ||
67 | |||
68 | {{/isApiKey}} | ||
69 | {{#isBasic}}- **Type**: HTTP basic authentication | ||
70 | |||
71 | Example | ||
72 | |||
73 | ```golang | ||
74 | auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{ | ||
75 | UserName: "username", | ||
76 | Password: "password", | ||
77 | }) | ||
78 | r, 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 | |||
91 | Example | ||
92 | |||
93 | ```golang | ||
94 | auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING") | ||
95 | r, err := client.Service.Operation(auth, args) | ||
96 | ``` | ||
97 | |||
98 | Or via OAuth2 module to automatically refresh tokens and perform user authentication. | ||
99 | |||
100 | ```golang | ||
101 | import "golang.org/x/oauth2" | ||
102 | |||
103 | /* Perform OAuth2 round trip request and obtain a token */ | ||
104 | |||
105 | tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) | ||
106 | auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource) | ||
107 | r, err := client.Service.Operation(auth, args) | ||
108 | ``` | ||
109 | |||
110 | {{/isOAuth}} | ||
111 | {{/authMethods}} | ||
112 | |||
113 | ## License | ||
114 | |||
115 | Copyright (C) 2015-2020 PeerTube Contributors | ||
116 | |||
117 | This 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 | |||
119 | This 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 | |||
121 | You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses. | ||