http:正文字段路径'foo'必须是非重复的消息。

问题描述 投票:0回答:1

我正在尝试使用gcloud端点上的gRPC helloworld示例为gRPC设置转码HTTP / JSON。我对helloworld.proto文件的注释是:

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/hello"
      body: "name"
    };
  }
}

我的服务配置是:

http:
  rules:

  - selector: helloworld.Greeter.SayHello
    post: /v1/hello
    body: name

生成api_descriptor.pb文件后,我执行:

gcloud endpoints services deploy api_descriptor.pb api_config.yaml

我得到:

ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot convert to service config. 
'ERROR: helloworld/helloworld.proto:43:3: http: body field path 'foo' must be a non-repeated message.'

任何帮助将不胜感激。 :)

google-cloud-endpoints grpc
1个回答
1
投票

显然,身体不能是基础类型。在消息中包装名称似乎有效:

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/hello"
      body: "person"
    };
  }
}

message Person {
  string name = 1;
}

// The request message containing the user's name.
message HelloRequest {
  Person person = 1;
}
© www.soinside.com 2019 - 2024. All rights reserved.