Skip to content

Commit 3c3b820

Browse files
authored
docs: buf plugin example (#103)
I wanted to make it easier for people to understand how to use the api-linter as a buf plugin, so I created an example project using the bookstore example.proto (Which embarrassingly fails linting) and added an explanation to the docs. I also updated some stale references and text in the docs which still referred to AIP pages.
1 parent 596d890 commit 3c3b820

File tree

6 files changed

+641
-17
lines changed

6 files changed

+641
-17
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Google API Linter
22

33
[![ci](https://github.com/aep-dev/api-linter/actions/workflows/ci.yaml/badge.svg)](https://github.com/aep-dev/api-linter/actions/workflows/ci.yaml)
4-
![latest release](https://img.shields.io/github/v/release/googleapis/api-linter)
5-
![go version](https://img.shields.io/github/go-mod/go-version/googleapis/api-linter)
4+
![latest release](https://img.shields.io/github/v/release/aep-dev/api-linter)
5+
![go version](https://img.shields.io/github/go-mod/go-version/aep-dev/api-linter)
66

7-
The API linter provides real-time checks for compliance with many of Google's
8-
API standards, documented using [API Improvement Proposals][]. It operates on
9-
API surfaces defined in [protocol buffers][].
7+
The API linter provides real-time checks for compliance with many of the API
8+
standards, documented using [API Enhancement Proposals][]. It operates on API
9+
surfaces defined in [protocol buffers][]. For APIs defined in
10+
[OpenAPI specification][] an equivalent [OpenAPI specification linter][] is
11+
available.
1012

1113
It identifies common mistakes and inconsistencies in API surfaces:
1214

@@ -20,11 +22,11 @@ message GetBookRequest {
2022

2123
When able, it also offers a suggestion for the correct fix.
2224

23-
[_Read more ≫_](https://linter.aip.dev/)
25+
[_Read more ≫_](docs/index.md)
2426

2527
## Versioning
2628

27-
The Google API linter does **not** follow semantic versioning. Semantic
29+
The AEP API linter does **not** follow semantic versioning. Semantic
2830
versioning is challenging for a tool like a linter because the addition or
2931
correction of virtually any rule is "breaking" (in the sense that a file that
3032
previously reported no problems may now do so).
@@ -45,7 +47,7 @@ being useful.
4547

4648
## Contributing
4749

48-
If you are interested in contributing to the API linter, please review the [contributing guide](https://linter.aip.dev/contributing) to learn more.
50+
If you are interested in contributing to the API linter, please review the [contributing guide](https://aep.dev/contributing/) to learn more.
4951

5052
## License
5153

@@ -54,4 +56,5 @@ This software is made available under the [Apache 2.0][] license.
5456
[apache 2.0]: https://www.apache.org/licenses/LICENSE-2.0
5557
[api improvement proposals]: https://aip.dev/
5658
[protocol buffers]: https://developers.google.com/protocol-buffers
57-
[rule documentation]: ./rules/index.md
59+
[OpenAPI specification]: https://www.openapis.org/
60+
[OpenAPI specification linter]: https://github.com/aep-dev/aep-openapi-linter

docs/index.md

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
22
---
33

4-
# Google API Linter
4+
# AEP API Linter
55

66
![ci](https://github.com/aep-dev/api-linter/workflows/ci/badge.svg)
77
![latest release](https://img.shields.io/github/v/release/googleapis/api-linter)
88
![go version](https://img.shields.io/github/go-mod/go-version/googleapis/api-linter)
99

10-
The API linter provides real-time checks for compliance with many of Google's
11-
API standards, documented using [API Improvement Proposals][]. It operates on
12-
API surfaces defined in [protocol buffers][].
10+
The API linter provides real-time checks for compliance with many of the API
11+
standards, documented using [API Enhancement Proposals][]. It operates on API
12+
surfaces defined in [protocol buffers][]. For APIs defined in
13+
[OpenAPI specification][] an equivalent [OpenAPI specification linter][] is
14+
available.
1315

1416
It identifies common mistakes and inconsistencies in API surfaces:
1517

@@ -43,9 +45,6 @@ It will install `api-linter` into your local Go binary directory
4345
`$HOME/go/bin`. Ensure that your operating system's `PATH` contains the Go
4446
binary directory.
4547

46-
**Note:** For working in Google-internal source control, you should use the
47-
released binary `/google/bin/releases/api-linter/api-linter`.
48-
4948
## Usage
5049

5150
```sh
@@ -80,12 +79,51 @@ Usage of api-linter:
8079
--version Print version and exit.
8180
```
8281

82+
### Usage with Buf
83+
84+
[Buf][] builds tooling to make schema-driven, Protobuf-based API development
85+
reliable and user-friendly for service producers and consumers.
86+
This includes the `buf lint` command, which can be used to lint Protobuf files.
87+
The API linter can be used as a plugin for `buf lint`.
88+
89+
To install the plugin, run:
90+
91+
```sh
92+
go install github.com/aep-dev/api-linter/cmd/buf-plugin-aep@latest
93+
```
94+
95+
It will install `buf-plugin-aep` into your local Go binary directory
96+
`$HOME/go/bin`. Ensure that your operating system's `PATH` contains the Go
97+
binary directory.
98+
99+
Then, integrate the following into your `buf.yaml` file:
100+
101+
```yaml
102+
lint:
103+
use:
104+
- AEP
105+
plugins:
106+
- plugin: buf-plugin-aep
107+
```
108+
109+
Now, you can run `buf lint` to lint your Protobuf files against the AEP rules.
110+
111+
An example of building and linting with Buf can be found in the
112+
[example](./example) directory.
113+
114+
More information on using Buf to lint Protobuf files can be found in the
115+
[Buf lint documentation][].
116+
83117
## License
84118

85119
This software is made available under the [Apache 2.0][] license.
86120

87121
[apache 2.0]: https://www.apache.org/licenses/LICENSE-2.0
88-
[api improvement proposals]: https://aep.dev/
122+
[API Enhancement Proposals]: https://aep.dev/
89123
[configuration]: ./configuration.md
90124
[protocol buffers]: https://developers.google.com/protocol-buffers
91125
[rule documentation]: ./rules/index.md
126+
[OpenAPI specification]: https://www.openapis.org/
127+
[OpenAPI specification linter]: https://github.com/aep-dev/aep-openapi-linter
128+
[Buf]: https://buf.build/
129+
[Buf lint documentation]: https://buf.build/docs/lint/overview/

example/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Buf
2+
buf.lock
3+
4+
# Generated code
5+
gen/

example/buf.gen.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: v2
2+
managed:
3+
enabled: true
4+
plugins:
5+
- remote: buf.build/grpc/java:v1.69.0
6+
out: gen
7+
# dependencies
8+
- remote: buf.build/protocolbuffers/java:v29.1
9+
out: gen
10+
inputs:
11+
- directory: proto

example/buf.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# For details on buf.yaml configuration, visit https://buf.build/docs/configuration/v2/buf-yaml
2+
version: v2
3+
modules:
4+
- path: proto
5+
deps:
6+
- buf.build/googleapis/googleapis
7+
lint:
8+
use:
9+
- AEP
10+
plugins:
11+
- plugin: buf-plugin-aep
12+

0 commit comments

Comments
 (0)