【问题标题】:http: body field path 'foo' must be a non-repeated message.'http:正文字段路径“foo”必须是非重复消息。
【发布时间】:2017-12-16 15:04:36
【问题描述】:

我正在尝试使用 gcloud 端点上的 gRPC helloworld 示例将 HTTP/JSON 转码为 gRPC。我对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】:

    显然,body 不能是基本类型。将名称包含在消息中似乎可行:

    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;
    }
    

    【讨论】:

    猜你喜欢
    • 2021-08-18
    • 1970-01-01
    • 2016-10-30
    • 1970-01-01
    • 2017-04-23
    • 2022-08-03
    • 2018-12-08
    • 1970-01-01
    • 2017-02-23
    相关资源
    最近更新 更多