grpc-ecosystem/grpc-gateway

single file with grpc annotations for multiple services don't work

Open

#3059 opened on Dec 12, 2022

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Go (16,971 stars) (2,250 forks)batch import
bughelp wantedopenapi

Description

🐛 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

  1. Create multiple proto services
  2. Add yaml file with grpc configuration which contains selectors for this services
  3. 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

Contributor guide