grpc-ecosystem/grpc-gateway

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

オープン

#3,059 opened on 2022/12/12

 (4 件のコメント) (0 件のリアクション) (0 人の担当者)Go (2,250 件のフォーク)batch import
bughelp wantedopenapi

Repository metrics

Stars
 (16,971 個のスター)
PR merge metrics
 (平均マージ 8d 23h) (30d で 147 merged PRs)

説明

🐛 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

コントリビューターガイド