private/apigen: Add list of endpoints with links

This change makes it easier for someone reading the documentation to see
a full list of supported endpoints, and have direct links to the
details.

Change-Id: I46e2f809cfa2760845898eaa3d99db9066d435ef
This commit is contained in:
Moby von Briesen 2023-08-23 13:21:54 -04:00 committed by Storj Robot
parent a0c69568b5
commit 7fbabbcf16
2 changed files with 41 additions and 11 deletions

View File

@ -4,6 +4,8 @@
package apigen
import (
"crypto/md5"
"encoding/hex"
"fmt"
"os"
"reflect"
@ -37,9 +39,22 @@ func (api *API) generateDocumentation() string {
wf("**Description:** %s\n\n", api.Description)
wf("**Version:** `%s`\n\n", api.Version)
wf("**List of endpoints:**\n")
getEndpointLink := func(group, endpoint string) string {
hash := md5.Sum([]byte(group + endpoint))
return "e-" + hex.EncodeToString(hash[:])
}
for _, group := range api.EndpointGroups {
wf("* %s\n", group.Name)
for _, endpoint := range group.endpoints {
wf(" * [%s](#%s)\n", endpoint.Name, getEndpointLink(group.Name, endpoint.Name))
}
}
wf("\n")
for _, group := range api.EndpointGroups {
for _, endpoint := range group.endpoints {
wf("## %s\n\n", endpoint.Name)
wf("<h2 id='%s'>%s</h2>\n\n", getEndpointLink(group.Name, endpoint.Name), endpoint.Name)
wf("%s\n\n", endpoint.Description)
wf("`%s /%s%s`\n\n", endpoint.Method, group.Prefix, endpoint.Path)

View File

@ -4,7 +4,22 @@
**Version:** `v0`
## Create new Project
**List of endpoints:**
* ProjectManagement
* [Create new Project](#e-530e988a949a9982f67b860e2581db77)
* [Update Project](#e-4c85eac5d7ee95019c2749891fb6b6fb)
* [Delete Project](#e-e490e9360a328ecb5ec9eaf60d410904)
* [Get Projects](#e-e920a99c4ea7ec5ef4a43c6d2408a118)
* [Get Project's Single Bucket Usage](#e-ca2c2de1415034f3a51eeb756b8fce9f)
* [Get Project's All Buckets Usage](#e-bed3c2be3abb8400f944adf3a8f2624c)
* [Get Project's API Keys](#e-954acbeb1e1a1fff8d97908ef9232ddc)
* APIKeyManagement
* [Create new macaroon API key](#e-fa1da2b3de26abd107d6aecf6eb39aee)
* [Delete API Key](#e-bf858e3fbef055f83e996a7f6889eac5)
* UserManagement
* [Get User](#e-490618f71b154e91e7e446ae28c2d004)
<h2 id='e-530e988a949a9982f67b860e2581db77'>Create new Project</h2>
Creates new Project with given info
@ -29,7 +44,7 @@ Creates new Project with given info
unknown
```
## Update Project
<h2 id='e-4c85eac5d7ee95019c2749891fb6b6fb'>Update Project</h2>
Updates project with given info
@ -79,7 +94,7 @@ Updates project with given info
```
## Delete Project
<h2 id='e-e490e9360a328ecb5ec9eaf60d410904'>Delete Project</h2>
Deletes project by id
@ -91,7 +106,7 @@ Deletes project by id
|---|---|---|
| `id` | `string` | UUID formatted as `00000000-0000-0000-0000-000000000000` |
## Get Projects
<h2 id='e-e920a99c4ea7ec5ef4a43c6d2408a118'>Get Projects</h2>
Gets all projects user has
@ -125,7 +140,7 @@ Gets all projects user has
```
## Get Project's Single Bucket Usage
<h2 id='e-ca2c2de1415034f3a51eeb756b8fce9f'>Get Project's Single Bucket Usage</h2>
Gets project's single bucket usage by bucket ID
@ -159,7 +174,7 @@ Gets project's single bucket usage by bucket ID
```
## Get Project's All Buckets Usage
<h2 id='e-bed3c2be3abb8400f944adf3a8f2624c'>Get Project's All Buckets Usage</h2>
Gets project's all buckets usage
@ -195,7 +210,7 @@ Gets project's all buckets usage
```
## Get Project's API Keys
<h2 id='e-954acbeb1e1a1fff8d97908ef9232ddc'>Get Project's API Keys</h2>
Gets API keys by project ID
@ -245,7 +260,7 @@ Gets API keys by project ID
```
## Create new macaroon API key
<h2 id='e-fa1da2b3de26abd107d6aecf6eb39aee'>Create new macaroon API key</h2>
Creates new macaroon API key with given info
@ -271,7 +286,7 @@ Creates new macaroon API key with given info
```
## Delete API Key
<h2 id='e-bf858e3fbef055f83e996a7f6889eac5'>Delete API Key</h2>
Deletes macaroon API key by id
@ -283,7 +298,7 @@ Deletes macaroon API key by id
|---|---|---|
| `id` | `string` | UUID formatted as `00000000-0000-0000-0000-000000000000` |
## Get User
<h2 id='e-490618f71b154e91e7e446ae28c2d004'>Get User</h2>
Gets User by request context