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

Add optional fields support #21

Open
vgarvardt opened this issue Jun 15, 2021 · 8 comments
Open

Add optional fields support #21

vgarvardt opened this issue Jun 15, 2021 · 8 comments

Comments

@vgarvardt
Copy link

As of protobuf 3.15 optional fields are available, but they are not supported by the generator:

test/optional/v1/has_optional_field.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-grpc-gateway-ts hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--grpc-gateway-ts_out:

test/optional/v1/has_optional_field.proto contents:

syntax = "proto3";

package test.optional.v1;

message HasOptionalField {
  string not_optional = 1;
  optional string not_required = 2;
}
@lyonlai
Copy link
Collaborator

lyonlai commented Jun 16, 2021

haven't run into this before. let me have a look and get back to you later.

@lyonlai
Copy link
Collaborator

lyonlai commented Jun 18, 2021

👋 @vgarvardt getting around the error itself is simple. But that doesn't mean the output code will have full support of the optional semantic in proto3. So I don't think it's the right thing to do.

The current situation is that the support of proto2 optional/require is not properly implemented in this generator. To achieve the real support of optional field in proto3, might as well solve the proto2 problem at the same time. So there will be quite a bit of work needs to be done.

@vgarvardt
Copy link
Author

I'm still very interested in this and may spend some time helping with the implementation, but I'll need your guidance. Maybe you can describe the job that needs to be done for a proper implementation, or at least the first steps so I could try to work on it and let you review PRs if you do not have to work on it.

@yinheli
Copy link

yinheli commented Aug 12, 2021

@vgarvardt I just let optional enable to generate, but not implements, refer: yinheli@bb766c2

@lyonlai
Copy link
Collaborator

lyonlai commented Aug 15, 2021

yup, what @yinheli suggested will unblock you for now. @vgarvardt. I was gonna start working on it but got distracted to other priorities. Free free to start thinking about it before the implementation. I'll guide you through

@ergoz
Copy link

ergoz commented Jun 19, 2022

any updates? It will make usable this generator. It is really sucks to use grpc-web instead....

@theartofdevel
Copy link

any updates?

1 similar comment
@KubeKyrie
Copy link

any updates?

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

No branches or pull requests

6 participants