Skip to content

Commit 8e327fc

Browse files
committed
generate OpenAPI docs
1 parent 2f0fe3e commit 8e327fc

File tree

5 files changed

+67
-25
lines changed

5 files changed

+67
-25
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ on:
1818
- "synchronize"
1919
- "reopened"
2020

21-
2221
jobs:
2322
lint:
2423
name: "Lint & Publish Draft/Branch"
@@ -30,3 +29,6 @@ jobs:
3029
with:
3130
token: "${{ secrets.BUF_REGISTRY_TOKEN }}"
3231
breaking_against: "https://github.com/authzed/api.git#branch=main"
32+
- uses: "swaggerexpert/swagger-editor-validate@264fd875d3c6e1bf65da1f0a63e095cbe41ffef3" # v1.5.1
33+
with:
34+
definition-file: "./docs/apidocs.swagger.json"

CONTRIBUTING.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,5 @@ If you have already authored a commit that is missing the signed-off, you can am
6565

6666
[DCO]: /DCO
6767

68-
## Common tasks
6968

70-
### Linting Protobuf Definitions
7169

72-
All [Protobuf] code is managed using [buf].
73-
You can lint the definitions by executing:
74-
75-
```sh
76-
buf build && buf lint
77-
```
78-
79-
[Protobuf]: https://developers.google.com/protocol-buffers/
80-
[buf]: https://docs.buf.build/installation
81-
82-
## ⚠️ Warnings ⚠️
83-
84-
- The `version` field found in various buf YAML configuration is actually schema of the YAML of the file and is not related to the version of the definitions.
85-
- `buf build` and `buf generate` do entirely different things.
86-
Building compiles definitions and ensures semantic validity.
87-
Generate builds and then produces actual source code according to `buf.gen.yaml`.

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
help: ## Show this help
2+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
3+
4+
install: ## Install dependencies
5+
pre-commit install
6+
7+
buf-gen: ## Generate API docs
8+
./buf.gen.yaml
9+
10+
lint: buf-gen ## Run linting
11+
buf format -w
12+
pre-commit run --all-files

README.md

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Authzed API
22

33
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg "Apache 2.0 License")](https://www.apache.org/licenses/LICENSE-2.0.html)
4-
[![Docs](https://img.shields.io/badge/docs-authzed.com-%234B4B6C "Authzed Documentation")](https://docs.authzed.com)
4+
[![Docs](https://img.shields.io/badge/docs-authzed.com-%234B4B6C "Authzed Documentation")](https://authzed.com/docs)
55
[![Build Status](https://github.com/authzed/api/workflows/Lint/badge.svg "GitHub Actions")](https://github.com/authzed/api/actions)
66
[![Discord Server](https://img.shields.io/discord/844600078504951838?color=7289da&logo=discord "Discord Server")](https://authzed.com/discord)
77
[![Twitter](https://img.shields.io/twitter/follow/authzed?color=%23179CF0&logo=twitter&style=flat-square "@authzed on Twitter")](https://twitter.com/authzed)
@@ -10,16 +10,45 @@ This project contains the definitions of [Protocol Buffers] used by Authzed.
1010

1111
[Buf] is used to distribute these definitions and generate source code from them.
1212

13-
You can find more info on [authentication], [HTTP/JSON API usage], and the [versioning and deprecation policy] in the [Authzed Docs].
13+
You can find more info on [authentication] and [HTTP API usage] in the [Authzed Docs].
1414

1515
See [CONTRIBUTING.md] for instructions on how to contribute and perform common tasks like building the project and running tests.
1616

1717
[Protocol Buffers]: https://developers.google.com/protocol-buffers/
1818
[Buf]: https://github.com/bufbuild/buf
1919
[authentication]: https://docs.authzed.com/reference/api#authentication
20-
[HTTP/JSON API usage]: https://docs.authzed.com/reference/api#alternative-httpjson-api
21-
[versioning and deprecation policy]: https://docs.authzed.com/reference/api#versioning--deprecation-policy
22-
[Authzed Docs]: https://docs.authzed.com
23-
[Authzed API Reference documentation]: https://docs.authzed.com/reference/api
20+
[HTTP API usage]: https://authzed.com/docs/spicedb/getting-started/client-libraries#http-clients
21+
[Authzed Docs]: https://authzed.com/docs
2422
[Buf Registry Authzed API repository]: https://buf.build/authzed/api/docs/main
2523
[CONTRIBUTING.md]: https://github.com/authzed/api/blob/main/CONTRIBUTING.md
24+
25+
## Common tasks
26+
27+
Pre-requisite: Have `buf` installed.
28+
29+
### Linting Protobuf Definitions
30+
31+
All [Protobuf] code is managed using [buf].
32+
You can lint the definitions by executing:
33+
34+
```sh
35+
buf build && buf lint
36+
```
37+
38+
[Protobuf]: https://developers.google.com/protocol-buffers/
39+
[buf]: https://docs.buf.build/installation
40+
41+
### ⚠️ Warnings ⚠️
42+
43+
- The `version` field found in various buf YAML configuration is actually schema of the YAML of the file and is not related to the version of the definitions.
44+
- `buf build` and `buf generate` do entirely different things.
45+
Building compiles definitions and ensures semantic validity.
46+
Generate builds and then produces actual source code according to `buf.gen.yaml`.
47+
48+
### Generating OpenAPI Documentation
49+
50+
Run:
51+
52+
```bash
53+
./buf.gen.yaml
54+
```

buf.gen.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env -S buf generate --template
2+
---
3+
version: "v1"
4+
managed:
5+
enabled: true
6+
go_package_prefix:
7+
default: "github.com/authzed/api/proto"
8+
except:
9+
- "buf.build/googleapis/googleapis"
10+
- "buf.build/envoyproxy/protoc-gen-validate"
11+
- "buf.build/grpc-ecosystem/grpc-gateway"
12+
plugins:
13+
- plugin: "buf.build/grpc-ecosystem/openapiv2:v2.26.3"
14+
out: "docs"
15+
opt:
16+
- "openapi_naming_strategy=simple"
17+
- "allow_merge=true"

0 commit comments

Comments
 (0)