【问题标题】:Deploying Google Cloud Endpoints configuration fails Google API Linter recommendations部署 Google Cloud Endpoints 配置失败 Google API Linter 建议
【发布时间】:2020-05-16 18:00:56
【问题描述】:

关注Deploying the Endpoints configuration后,我已经成功部署了我编译好的.proto文件和gRPC API配置文件。

太好了。我决定做一个好公民,在我的.proto 上使用Google's API Linter

这导致了许多包含各种注释的建议。注释需要新的 proto 导入;

之前

syntax = "proto3";
package api.v1;

// Request message for Get method.
message GetFooRequest {
  // The field will contain name of the resource requested.
  string name = 1;
}

...blah,blah

之后

syntax = "proto3";
package api.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";

// Request message for Get method.
message GetFooRequest {
  // The field will contain name of the resource requested.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference).type = "api.v1.HelloWorld/Foo"
  ];
}
...blah,blah

注解需要导入四个新的 proto 文件:

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";

所有都是Google's Common API protos 的一部分,因此我将the repo 克隆到/Users/Jack/api-common-protos/ 中:

git clone https://github.com/googleapis/api-common-protos.git

...并在编译我的.proto 文件时包含它:

python3 -m grpc_tools.protoc --proto_path=api
                             --proto_path=/Users/Jack/api-common-protos/google
                             api/v1/foo.proto

没有错误。伟大的。最后我部署了 API:

gcloud endpoints services deploy api_descriptor.pb api-config.yaml

这就完成了。但是,开发者门户现在显示:

We encountered the following errors while processing this API specification:

API parse error: Error: ENOENT: no such file or directory, open '/tmp/google/api/client.proto'

Please correct these errors and try again.

Scrot:

如果我删除注释(和所需的导入),我的 API 的 Endpoints Developer Portal 工作正常。

【问题讨论】:

  • 似乎“protoc”正在寻找文件/tmp/google/api/client.proto,而您克隆的存储库中的该文件位于/Users/Jack/api-common-protos/google/api/client.proto

标签: google-cloud-platform protocol-buffers grpc google-cloud-endpoints google-api-linter


【解决方案1】:

这是开发者门户中的一个错误。我已将其报告给负责的团队。请参阅我发布到google-cloud-endpoints@googlegroups.comGoogle's API Linter suggestions with Google Cloud Endpoints?

【讨论】:

  • 作为一个有趣的说明,由于您添加了这些,您可以使用其他一些工具来自动生成客户端库:请参阅这些PythonRubyTypeScriptGo、和C#
  • @nareddyt,你有解决这个问题的办法吗?
  • @nareddyt 这有什么更新吗?鉴于端点门户在此问题修复之前仍然无法使用,我有点惊讶它不是更高的优先级。
  • 不,问题尚未解决。其他社区用户通过在部署到 Cloud Endpoints 之前使用脚本清除注释来解决此问题:groups.google.com/g/google-cloud-endpoints/c/gjvRGY2HU7M/m/…
  • 为什么还没有修复?
【解决方案2】:

暂时解决这个问题可能并不费力:

cp /Users/Jack/api-common-protos/google/api/client.proto /tmp/google/api/client.proto

然后文件将在预期的位置可用 - 尽管没有自动放置在那里。

【讨论】:

  • 不幸的是,这并不能解决我的问题。你还有这个问题吗?
猜你喜欢
  • 2019-10-27
  • 2021-09-25
  • 1970-01-01
  • 2020-06-02
  • 2020-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-22
相关资源
最近更新 更多