You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current usage of protoc-gen-openapiv2 plugin is not consistent with protoc-gen-grpc-gateway due to lack of -module flag, in this case, if you use both of plugins you'll getting generated files file.pb.gw.go and file.swagger.json in different directories within a project if input proto file has go_package option.
And it looks not so great IMO and requires additional invokes of mv command from a user.
Support of the -module option for the protoc-gen-openapiv2 plugin should mitigate this problem and all files after generation will be in the same directory.
If I'm correct, protoc-gen-openapiv2 should use the google.golang.org/protobuf/compiler/protogen package as it's already done in protoc-gen-grpc-gateway's code.
The text was updated successfully, but these errors were encountered:
Hi Mihail. I would actually push back a little bit on the premise here that protoc-gen-openapiv2 should behave like the Go generator. protoc-gen-openapiv2 is not a go generator, and it should not care about the go_package option in the protofile. The only job of the protoc-gen-openapiv2 generator is to translate the http.proto and our custom annotations into a OpenAPIv2 compatible JSON file.
Given that, I would also challenge the suggestion that the generator should be rewritten with the new Go proto generator framework in mind. That framework is great for writing plugins that generate Go code, since it deals with imports and common flags for you. However, this is not the job of protoc-gen-openapiv2.
As such, I don't think this is a use case we want to support. I hope you understand and that you can adjust your workflow accordingly. I will close this issue, but please let me know if you still think there's a good reason for us to add this flag and I will reopen the discussion.
🚀 Feature
Current usage of
protoc-gen-openapiv2
plugin is not consistent withprotoc-gen-grpc-gateway
due to lack of-module
flag, in this case, if you use both of plugins you'll getting generated filesfile.pb.gw.go
andfile.swagger.json
in different directories within a project if input proto file hasgo_package
option.E.g. the following simple command:
With
file.proto
havingoption go_package = "github.com/user/repo/some_pkg_dir;some_pkg_name";
Produces the next structure:
And it looks not so great IMO and requires additional invokes of
mv
command from a user.Support of the
-module
option for theprotoc-gen-openapiv2
plugin should mitigate this problem and all files after generation will be in the same directory.If I'm correct,
protoc-gen-openapiv2
should use thegoogle.golang.org/protobuf/compiler/protogen
package as it's already done inprotoc-gen-grpc-gateway
's code.The text was updated successfully, but these errors were encountered: