prost
prost copied to clipboard
Usage of HTTP annotations and generation of OpenAPI
It seems that gRPC APIs have an extension (annotations added to .proto
files) that creates a JSON over HTTP APIs (REST) with control over path parameters and HTTP method, etc. that is supported by some .Net gRPC libraries that even implement OpenAPI as well.
I tried duplicate the .Net gRPC setup using Tonic, and I got gRPC, gRPC-Web, gRPC Reflection, but it didn't use the .proto
file's HTTP extensions, so it goes without saying that it didn't generate OpenAPI. However, there is another project called gRPC-Gateway (written in Go) that is a separate process, and must use protoc
to generate both OpenAPI (v2, not v3), a Go client, and JSON over HTTP API Go server. The client is used to talk to the Tonic based gRPC backend. This setup is the best of both worlds (REST with OpenAPI and gRPC with gRPC-Web and gRPC reflection), but it's not in 1 process, and it's not all in Rust. I'm guessing that prost would need to be extended to make something like this setup happen in a single process written in Rust, and with OpenAPI v3.
Please discuss.
To see what has to be done right now for OpenAPI and gRPC Reflection with Tonic, see the repo that I use currently to start new services.