grpc-ecosystem/grpc-gateway

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

Open

#2127 aperta il 6 mag 2021

Vedi su GitHub
 (15 commenti) (4 reazioni) (0 assegnatari)Go (2250 fork)batch import
bughelp wanted

Metriche repository

Star
 (16.971 star)
Metriche merge PR
 (Merge medio 1g 4h) (141 PR mergiate in 30 g)

Descrizione

🐛 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

Guida contributor