-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
protoc-gen-openapiv2: go_package
option is required since version 2.0.1
#2127
Comments
Hm, yes, the openapiv2 behaviour is definitely incorrect, that shouldn't require any go specific settings at all. The |
go_package
option is required since version 2.0.1go_package
option is required since version 2.0.1
@johanbrandhorst I understand that a lot of protobuf users are on the Go stack, but requiring the A workaround is to use the More importantly though, the package that is declared using this workaround has absolutely no impact on the resulting gateway binary. One can specify any (valid go package) value for the package and the resulting binary would work the same regardless. As such, it's questionable for it to be required, i.e.: as a user, I shouldn't be required to specify something that has no visible impact. IMO this only introduces friction for no user benefit. If
Then do one of:
|
I don't agree with the premise of your argument - the grpc-gateway generator generates a library, it is absolutely tied to the Go ecosystem. I don't know how you're using it which makes you think it generates a binary, because the gateway output is not buildable on its own.
This is specific to your own use case and is not generally true. The It's definitely correct to say that it's supposed to be accessible to users from other ecosystems, as a simple proxy in front of your gRPC server, but it's wrong to assume it's not tied to the Go dependency ecosystem. Again, for Sidenote: I work at Buf and we're working on making the |
@johanbrandhorst I have to admit that I was assuming a few things here, namely, that the output is Go code that compiles to a binary. For some reason, I had a vague memory of this being the case. The documentation clearly states that you need to roll your own Indeed, considering that the output is a library, it does make sense that Presumably, the generator could be renamed to something like In any case, the actual issue I have is with the Sidenote: we're (partial) users of |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Leaving |
Agreed, it should not be there for |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi, we have run into this error when building with Bazel now many times since upgrading to Is there any workaround here?
|
Not sure why stalebot closed this, I marked it as a bug 🤔. I think we use the protoc-gen-openapiv2 rules in this repository in our own tests but I'm actually not much of a bazel expert. Maybe @achew22 can weigh in on the particulars of our rules. |
Sorry! I did some research about it, and completely forgot to update 🤦♂️ It's been a while, so I might be wrong here, but from what I gathered - What I did back at the day to "quickly hack it", was to use an older Go Protobuf version. In the past, this has been a warning, and not an error. I didn't mind using an older version, but if you do - the only possible solution I can think of, is to use @achew22 should have a 2nd look, but I think this is not something |
Hi just my 2 cents..... if you are using buf to generate the code, then you can "bypass" this by setting: - file_option: go_package
value: special/value/package/v1 in version: v2
managed:
enabled: true
override:
- file_option: java_package_prefix
value: ""
- file_option: go_package
value: special/value/package/v1
plugins:
.... it will get rid of the error |
We're importing an external proto into our own where we don't control the proto's rules_go does this to always supply a |
Unsure if it's possible to override this with an option, sorry. |
I ended up writing another bazel rule to pass in |
🐛 Bug Report
Since version
2.0.1
, the protobuf optiongo_package
is required to generate the gateway or the OpenAPI schema.To Reproduce
Using this
.proto
file:Running protoc like so:
The output is:
(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
Your Environment
MacOS Catalina, gen-gateway and openapiv2 from 2.0.1 to 2.4.0 all exhibit the same behaviour
The text was updated successfully, but these errors were encountered: