hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.87k stars 1.01k forks source link

OpenAPI (Swagger) #758

Open Type1J opened 3 years ago

Type1J commented 3 years ago

Feature Request

Autogenerated OpenAPI

Motivation

The C# implementation has (in addition to existing Tonic features for a JSON API) an autogenerated OpenAPI spec that can be consumed by Swagger UI to generate a grpcui like test console that runs in a browser (not electron) for the JSON API.

Proposal

This should probably be implemented in a way similar to gRPC Reflection: as a service.

Alternatives

Currently, there's not any good alternatives. There may be a way to generate OpenAPI with gRPC-Gateway, but that's redundant with Tonic's JSON API. The information is already present.

Type1J commented 3 years ago

I just had to do a project in C# since gRPC, gRPC-Web and a JSON over HTTP with OpenAPI and Swagger UI were all requirements.

I could have done it with the Go based gRPC Gateway generated from the .proto file, and although that would go into a single k8s pod, they didn't like having 2 containers.

Is any work being done in this area?

davidpdrsn commented 3 years ago

I don't know of anyone working on this.

Is it something that could be explored in standalone crate?

Type1J commented 3 years ago

Maybe. I don't have time to deep dive into Tonic to find out, right now. I'll post here if I start working on it.

Type1J commented 2 years ago

I think that it might be best to look at Prost first. Because REST can be HTTP 1 as well, there may need to be some Hyper and/or Axum parts to make all of it work, but first, I'll look at Prost, since the code generated by it seems to be a big part of Tonic. https://github.com/tokio-rs/prost/issues/592