grpc-gateway
grpc-gateway copied to clipboard
single file with grpc annotations for multiple services don't work
π Bug Report
If you have yaml file with grpc annotations which contains selectors for multiple services, it'll raise an error if you try to generate code.
Previously discussed at slack: https://gophers.slack.com/archives/CBATURP1D/p1670838671867599
File structure scheme:
project
ββββproto
ββββapi
ββββfirst_svc
β ββββv1
β ββββfirst_svc.proto
ββββsecond_svc
β ββββv1
β ββββsecond_svc.proto
β
β
ββββ grpc_annotations.yaml
grpc_annotations.yaml content:
type: google.api.Service
config_version: 3
http:
rules:
### First service ###
- selector: api.first_svc.v1.FirstService.Get
get: /api/v1/first/get
### Second service ###
- selector: api.second_svc.v1.SecondService.Get
get: /api/v2/second/get
To Reproduce
- Create multiple proto services
- Add yaml file with grpc configuration which contains selectors for this services
- Try to generate (I'm using buf)
Expected behavior
I'm expecting to see generated code without errors
Actual Behavior
I'm getting error:
Failure: plugin grpc-gateway: HTTP rules without a matching selector:
But If there will be single service and file with annotations will be located at the same path - everything will be okay
Your Environment
instrument | version |
---|---|
OS | macOS 12 |
Go | 1.19.3 darwin/arm64 |
protoc-gen-grpc-gateway | v2.16.0 |
protoc-gen-openapiv2 | v2.16.0 |
buf | v1.9.0 |
Thanks for the issue. As discussed on Slack, I would expect our generator to be able to find the messages you are trying to select, since the selectors are using the global namespace. Would you be interested in fixing this? I think the first step would be to create a reproduction scenario in our examples protos. We already have an example file for external API configuration, maybe we could extend that? Or maybe a whole new folder would make sense.
@johanbrandhorst yeah, I'm interested in contributing to open source :)
I've created MR which contains reproducible example