protoc-gen-{grpc-gateway,openapiv2}: add optional support#1834
protoc-gen-{grpc-gateway,openapiv2}: add optional support#1834glerchundi wants to merge 1 commit intogrpc-ecosystem:masterfrom
Conversation
f65aedf to
7da15d6
Compare
johanbrandhorst
left a comment
There was a problem hiding this comment.
Thanks for this Gorka. I'm a little worried about just adding "support" for this without thinking about what that should mean. The grpc-gateway isn't responsible for generating any types, so we don't need to worry about generating pointers to primitive fields, but I think we should at least have a think about what this could mean for the generator. Do you have any optional fields you can test this PR on? It's not clear to me exactly what we would need to change, if anything, so it'd be good to have some practical experience.
|
I couldn't agree more. I think next steps here are to create a test case that falls without this patch applied and then we can discuss what is the best course forward. Thanks so much for contributing, this is a really important emerging feature in the proto3 ecosystem and I'm sorry I don't know enough about the interactions of everything to be able to definitively say much about it. |
|
Thanks for your time @johanbrandhorst & @achew22. I have been thinking on how to prepare the current code to achieve testing over the final generator/executable and my impression is that the quantity of work it requires it's not worth it. Even so, if you consider it is, sadly I won't be able to work on this as my time currently is very limited. I tried to find examples of other generators to see how they approach the very same problem we've here. Fortunately I found the I don't know if it's enough for you, but I empirically tested and it worked. This is what the generator says if we have a message with a field which has an "optional" and without applying these changes: WDYT? |
|
@glerchundi, looks very promising to me. Could I have you add a testcase into our repo that uses optional so that we are sure we don't regress. The real test of this case will be, if the lines you have in the current PR are commented out, will this test case fail. @johanbrandhorst am I way off base here? Is there more that you think we would need? |
|
That would work and it's trivial, at least for the optional part. I'm not quite sure how difficult would be to include the experimental and global parameter when executing the |
e3adf58 to
a1324c6
Compare
For this sort of test, we'll probably add a new file with some optionals set at various levels and just add the flags to the generation step in the
The only thing I can think of is that we could potentially use these annotations in the openapiv2 generator, but not in the gateway generator. |
f60d750 to
82320ea
Compare
|
I must admit that I'm having a really hard time trying to figure out how to solve bazel issues. I tested that the absence of the
But now it's failing due to this: It seems like I don't know how to proceed, would you mind guiding me in the right direction? |
johanbrandhorst
left a comment
There was a problem hiding this comment.
I can try and take a look at the bazel errors tomorrow, or maybe Andrew will find some time later today ;). Thanks for your efforts so far.
|
Thanks for the review @johanbrandhorst I'm not quite sure, but as we're using buildifier which is built using Go and uses Just a supposition as I don't have the needed knowledge around Bazel. |
Let `protoc` know that these generators support optional keywords. This is by no means an implementation in `grpc-gateway` of the optional aware generated code, it's just shielding of being considered as blockers in code generation workflows. Closes grpc-ecosystem#1278
82320ea to
ea0d26f
Compare
|
Yeah I suspected we might be at the mercy of rules_go as is often the case 😬. |
|
I'm going to close this for now, sorry for the hassle @glerchundi. I'd be happy to reopen this once there is support in the Go Bazel toolchain. |
|
No worries, I'll keep an eye in those two issues. |


Let
protocknow that these generators support optional keywords. Thisis by no means an implementation in
grpc-gatewayof the optional awaregenerated code, it's just shielding of being considered as blockers in
code generation workflows.
Closes #1278