-
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
Proto enums can produce invalid yaml in swagger files #2745
Comments
Oh dear! That definitely looks like a bug. The YAML format is a reasonably new addition, so it's not surprising that there are some kinks to work out. It was contributed by @hedhyw in #2579. I wonder if this is a problem with our YAML library? Would you be interested in helping contribute a fix for this? Thanks for the excellent bug report, by the way! |
Try the version
|
It seems it was broken in #2729 |
The problem is with I've just tried it in the playground: https://go.dev/play/p/tTc7F_T86vF We can solve it as:
|
Yes, that seems to work for me! Sorry for not including my grpc-gateway version in the original bug report - silly oversight. |
I suspected it might be the version upgrade, thanks a lot for digging into it @hedhyw! Since the original reason for upgrading to v3 was "just because", I'm leaning towards just reverting for now. @sousandrei @hedhyw @ianrose14 would one of you be interested in taking charge of reverting the other change to fix this? |
@johanbrandhorst As I see it makes sense to revert only a part of |
I created a fix for the YAML library: go-yaml/yaml#864, we can wait until it will be merged if it will be. |
That's even better, thank you! |
It seems like go-yaml/yaml#864 is not going to be merged (go-yaml/yaml#643), so let's decide:
|
Hm, sounds to me like we should just revert back to v2 until there is any movement merging of the v3 fix. What do you think? |
🐛 Bug Report
If an input proto file contains an enum where some of the individual enum values have comments, the yaml produced by the
protoc-gen-openapiv2
plugin can be invalid.To Reproduce
repro.proto
and save it in a directory namedrepro
along with the usual annotations.proto and http.proto files.repro.swagger.yaml
) is invalid. You can verify this with various online yaml parsers or with a small Go program like this:For convenience, here's the bit of the yaml that comes out broken:
Expected behavior
The swagger file produced should be valid yaml.
Actual Behavior
The swagger file is invalid yaml.
Your Environment
Darwin MacBook-Pro 21.5.0
macOS v12.5
protoc --version
-->libprotoc 3.19.4
go version
-->go version go1.18.3 darwin/arm64
The text was updated successfully, but these errors were encountered: