Skip to content
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

Support 'optional' fields in proto3 #20

Closed
huan opened this issue Mar 24, 2021 · 8 comments · Fixed by #34
Closed

Support 'optional' fields in proto3 #20

huan opened this issue Mar 24, 2021 · 8 comments · Fixed by #34

Comments

@huan
Copy link

huan commented Mar 24, 2021

Since [email protected], it started to support optional field. It would be nice if the protoc-gen-ts plugin supports it. Could you please work on it? Thanks.

Here is the reference about how to implement.

copy/pasted, credit improbable-eng/ts-protoc-gen#263

This is a blocker for my project wechaty/grpc#109

@ckaznocha
Copy link
Owner

Thanks for letting me know! I'll look into this when I have some time but I can't promise when that will be.

@ckaznocha
Copy link
Owner

Hey @huan I just gave this a try and it looks like optional works fine with proto3. Tested with libprotoc 3.15.8. Do you have any more info on what the issue you're hitting is?

@huan
Copy link
Author

huan commented May 23, 2021

@ckaznocha Thanks for replying to my issue!

I'll check for it later this month and come back to you, appreciate your great project, it's very helpful to my project. 👍

@tobias-
Copy link

tobias- commented Aug 11, 2021

@ckaznocha Even if @huan hasn't replied yet, could you please make a release so that M1 will work for us?

We're currently blocked from using M1 arch until it's released and would really prefer not to release ourselves.

@ckaznocha
Copy link
Owner

Oh yes, for sure!

@ckaznocha
Copy link
Owner

@tobias- I've changed the way I build releases and don't have an M1 mac to test on but https://github.com/ckaznocha/protoc-gen-lint/releases/download/v0.2.3/protoc-gen-lint_darwin_arm64.zip should work. I'd like to keep the M1 support at #24, If the arm64 doesn't work for you please comment over there and I'll re-open it.

@huan
Copy link
Author

huan commented Oct 4, 2021

@ckaznocha I have tried the [email protected] with [email protected] but it does not work in my Ubuntu Linux:

$ protoc --version
libprotoc 3.18.0
$ go install github.com/ckaznocha/[email protected]
$ protoc -I third-party -I proto --lint_out=. $(find proto/ -type f -name *.proto)
wechaty/puppet/friendship.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-lint hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--lint_out: 

My friendship.proto:

message FriendshipAddRequest {
  string contact_id = 1;
  optional string hello = 2;
  optional string source_room_id = 3;
  optional string source_contact_id = 4;
}

You can reproduce the above problem with my working PR at wechaty/grpc#125

$ git clone [email protected]:wechaty/grpc.git
$ cd grpc/
$ git checkout optional
Branch 'optional' set up to track remote branch 'optional' from 'origin'.
Switched to a new branch 'optional'
$ ./scripts/install-protoc.sh 
install skipped: protoc exists
protoc version check: v3.18.0 OK
$ protoc -I third-party -I proto --lint_out=. $(find proto/ -type f -name *.proto)
wechaty/puppet/friendship.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-lint hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--lint_out: 

@huan
Copy link
Author

huan commented Oct 11, 2021

ping @ckaznocha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants