How to generate OpenAPI 3 documentation from protobuf files

Viewed 14295

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?

3 Answers

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.

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!

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.

Related