KHilse
KHilse

Reputation: 331

How to generate OpenAPI 3 documentation from protobuf files

I have an API generated from protobuf, and I would like to generate documentation conforming to the OpenAPI 3 spec. I've looked at a number of utilities but I haven't found a combination that works.

Does anyone know of a path from protobuf to OpenAPI 3 that I can follow?

Upvotes: 33

Views: 36951

Answers (4)

e_z
e_z

Reputation: 70

We are using buf and options to customize final openapi artefact:

The plugin to build final yamls:

To manage plugins we are using bingo:

Upvotes: 1

ubombi
ubombi

Reputation: 1174

Looks like protoc-gen-openapi app, from gnostic, is what you were looking for. But it seems abandoned and not working.

Have no idea if it works.

Upvotes: 5

NamND
NamND

Reputation: 61

I searched for the answer recently and found this package: protobuf2swagger It can be run in CLI with a js config file required. This packaged solved my problem.

Upvotes: 6

Krishna Birla
Krishna Birla

Reputation: 358

Google has a repository on GitHub to do exactly that. It contains examples for OpenAPI v3 (and v2) on how the equivalent protobuf code should look like.

Here is a medium article that explains end to end gRPC + HTTP (using protobuf and swagger respectively) server implementation and documentation, in a step by step fashion. It is an OpenAPI v2 example, but similar concepts apply to OpenAPI v3.

There are other repositories that can do the same, but I would recommend to use the source code that is actually coming from the very source. :)

Hope this helps!

Upvotes: 3

Related Questions