0

How do you use oneof fields in a grpc node? I am using dynamic code generation. I tried to modify the quickstart with

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
  rpc SayHelloOneOf (OneOfRequest) returns (HelloReply) {}
}

message OneOfRequest {
  oneof nameOneof {
    string name = 1;
  }
}

However I do not know how to set the name in the request in the client. Thank you

4

1 回答 1

1

a 中的字段oneof仍然是消息的直接部分,因此您仍然可以使用如下对象表示该消息:

{
  name: 'test name'
}

您还可以将字段设置nameOneof为值"name"以指示oneof您正在使用的字段。

于 2020-07-20T16:46:43.137 回答