-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
🐛 Bug Report
When I generate Open API definition with protoc-gen-openapiv2
, the definition for Location
message has an odd prefix.
I believe the prefix of definitions is the last part of package name but only for Location
message, it also contains the parent package name.
e.g. If package name is example.test
. Usual message definition's prefix is test
, but only for Location
, the prefix will be exampletest
.
To Reproduce
- Setup
grpc-gateway
according toREADME.md
'sInstallation
section - Clone
googleapis
$ git clone --depth 1 https://github.com/googleapis/googleapis.git
- Create the following proto file
syntax = "proto3"; package example.test; option go_package = "example/test"; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; service TestService { rpc Test(TestRequest) returns (google.protobuf.Empty) { option (google.api.http) = {}; } } message TestRequest { Location x = 1; NotLocation y = 2; } message Location { } message NotLocation { }
- Generate OpenAPI definitions
$ protoc -I googleapis -I . --openapiv2_out . test.proto
- Check
Location
's definition$ grep -i location test.swagger.json "exampletestLocation": { "testNotLocation": {
Expected behavior
All message definitions' prefix are the last part of the package name.
e.g. package is example.test
- Location -> testLocation
- AnyOther -> testAnyOther
Actual Behavior
e.g. package is example.test
- Location -> exampletestLocation
- AnyOther -> testAnyOther
Your Environment
- OS: Ubuntu 20.04 on Vagrant (box: generic/ubuntu2004).
- golang : go version go1.16.5 linux/amd64
- protoc: libprotoc 3.17.1
- protoc-gen-openapiv2: Version dev, commit unknown, built at unknown
- but I believe it is v2.4.0
- go.mod
module example.com/test go 1.16 require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.4.0 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 google.golang.org/protobuf v1.26.0 )