grpc-ecosystem/grpc-gateway

protoc-gen-openapiv2: `go_package` option is required since version 2.0.1

Open

#2,127 建立於 2021年5月6日

在 GitHub 查看
 (15 留言) (4 反應) (0 負責人)Go (2,250 fork)batch import
bughelp wanted

倉庫指標

Star
 (16,971 star)
PR 合併指標
 (平均合併 1天 4小時) (30 天內合併 141 個 PR)

描述

🐛 Bug Report

Since version 2.0.1, the protobuf option go_package is required to generate the gateway or the OpenAPI schema.

To Reproduce

Using this .proto file:

syntax = "proto3";
package your.service.v1;

message StringMessage {
  string value = 1;
}

service YourService {
  rpc Echo(StringMessage) returns (StringMessage) {}
}

Running protoc like so:

protoc -I . --grpc-gateway_out ./output my_service.proto

The output is:

protoc-gen-grpc-gateway: unable to determine Go import path for "my_service.proto"

Please specify either:
	• a "go_package" option in the .proto source file, or
	• a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

(The problem is the same with protoc-gen-openapiv2)

Expected behavior

The go_package option shouldn't be require, at least to produce the OpenAPI output since this value has no meaning for this generator.

Ideally, it wouldn't be required for generating the gateway as well since the gateway is meant to be a runnable binary and not linked against as code.

Actual Behavior

protoc-gen-grpc-gateway: unable to determine Go import path for "my_service.proto"

Please specify either:
	• a "go_package" option in the .proto source file, or
	• a "M" argument on the command line.

See https://developers.google.com/protocol-buffers/docs/reference/go-generated#package for more information.

Your Environment

MacOS Catalina, gen-gateway and openapiv2 from 2.0.1 to 2.4.0 all exhibit the same behaviour

protoc --version
libprotoc 3.14.0

貢獻者指南