grpc-gateway icon indicating copy to clipboard operation
grpc-gateway copied to clipboard

Create official grpc-gateway protobuf template on the Buf Schema Registry

Open rohilsurana opened this issue 3 years ago • 10 comments

🚀 Feature

Publishing the plugins protoc-gen-grpc-gateway and protoc-gen-openapiv2 would enable the ability to use these for remote generation of go packages on the Buf Schema registry, simplifying the development workflow.

Along with this we can also provide a template that the users can then directly use with their repos pushed on BSR with - go get go.buf.build/grpc-ecosystem/go-grpc-gateway/<username>/<repo>

rohilsurana avatar Aug 30 '21 17:08 rohilsurana

Hi, thanks for the issue! This could greatly simplify the simplest of use cases. Note that we already have an org and repository: https://buf.build/grpc-ecosystem/grpc-gateway. We would host these under the same parent org.

johanbrandhorst avatar Aug 30 '21 18:08 johanbrandhorst

Updated the go get command to use the existing org.

rohilsurana avatar Aug 30 '21 18:08 rohilsurana

Holding off on the template for now, but the grpc-gateway and openapiv2 plugins have been pushed. I will update the README once buf v0.55.0 is available as it allows users to select remote plugins for local generation.

johanbrandhorst avatar Sep 03 '21 02:09 johanbrandhorst

@johanbrandhorst we have buf 1.4.x now and remote plugins arrived. Any updates on this?

nightlyone avatar May 11 '22 17:05 nightlyone

The remote plugins are in place, are you talking about an official grpc-gateway template? I think we'd like to wait until remote generation is out of alpha, I know they're still making some tweaks to it.

johanbrandhorst avatar May 11 '22 18:05 johanbrandhorst

@johanbrandhorst Looks like the latest commit available on org/repo https://buf.build/grpc-ecosystem/grpc-gateway. from May 23rd. Is it possible to push the latest changes to the module to BSR ?

image

AbhinavkumarL avatar Jul 28 '22 18:07 AbhinavkumarL

Hi @AbhinavkumarL. Do you have a reason to believe that this is no longer the latest protobuf contents? The BSR won't create a new commit unless there are new files or changes to existing files. We also only run the proto_push workflow when there have been changes to one of the protobuf files: https://github.com/grpc-ecosystem/grpc-gateway/blob/1085fb38dc98034ae6a189b45b764fa1f3bef82a/.github/workflows/master.yml#L1-L6. The last push was https://github.com/grpc-ecosystem/grpc-gateway/actions/runs/2374364512.

johanbrandhorst avatar Jul 28 '22 18:07 johanbrandhorst

@johanbrandhorst I see the openapiv2 plugin is up-to-date with reference v2.11.0-1. However, the commits published on the module is older. Looks like there is some inconsistency. I keep running in to the below error when i try to use buf generate to generate the protobuf from my proto files.

Failure: plugin openapiv2: repeated field not allowed in field path

I see this issue is recently fixed on the plugin in (https://github.com/grpc-ecosystem/grpc-gateway/pull/2813).

I checked with the buf build support. They mentioned the upstream maintainers need to push latest protos to BSR.

AbhinavkumarL avatar Jul 28 '22 19:07 AbhinavkumarL

I see the confusion. The problem is that the fix that you are relying on is not yet in a published release. If you want to use remote plugins, you'll need to keep the old option around for now:

version: v1
plugins:
  - remote: buf.build/grpc-ecosystem/plugins/openapiv2
    out: .
    opt:
      - allow_repeated_fields_in_body=true

Also, don't confuse plugin versioning for the versioning of the protobuf files. The protobuf files change very rarely. Everything on the BSR is up to date.

johanbrandhorst avatar Jul 28 '22 20:07 johanbrandhorst

okay got it, Appreciate your time.

AbhinavkumarL avatar Jul 28 '22 20:07 AbhinavkumarL