google / google/gnostic

Create a Buf plugin for `protoc-gen-openapi`

Open
#365 14 comments 8 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

It would be really nice to have a remote plugin uploaded to Buf's BSR for `protoc-gen-openapi`, so that we can build our OpenAPI 3 schemas from our protobuf schemas using Buf in smaller Docker containers.

The `buf.gen.yaml` would essentially look like this:

```yml
---
version: v1
plugins:
- remote: buf.build/protocolbuffers/plugins/go:v1.28.1-1
out: gen/go
opt:
- paths=source_relative

# ...

- remote: buf.build/gnostic/plugins/protoc-gen-openapi:-
out: gen/oapi3
opt:
- title=OpenAPI v3
```

Then, we can just run `buf generate` to spit out all of this stuff from a pretty tiny Docker build step.

```dockerfile
FROM bufbuild/buf:1.7.0 AS buf

WORKDIR /src

COPY buf.yaml buf.yaml
COPY buf.gen.yaml buf.gen.yaml
COPY proto/ proto/

RUN buf generate
```

Like this one.

I'd love to be able to get this one built, it would be a really big help to people like me who are trying to stick to Buf for all their protobuf needs, and using remote plugins reduces the number of required tools to install locally versus using `protoc` locally, and having to install all the relevant `protoc` extensions with it.

Thanks! :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.