部署 Google Cloud Endpoints 配置未通过 Google API Linter 建议

Jac*_*ack 5 protocol-buffers google-cloud-endpoints google-cloud-platform grpc google-api-linter

更新: Cloud Endpoints Portal 已被弃用,2023 年 3 月 21 日后将不再可用。


按照部署端点配置后,我已成功部署编译.proto文件和 gRPC API 配置文件。

伟大的。我决定做一个好公民,并在我.proto.

这导致了许多包含各种注释的建议。注释需要新的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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

注释需要导入四个新的原型文件:

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
Run Code Online (Sandbox Code Playgroud)

所有这些都是Google 通用 API原型的一部分,因此我将存储库克隆/Users/Jack/api-common-protos/

git clone https://github.com/googleapis/api-common-protos.git
Run Code Online (Sandbox Code Playgroud)

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

python3 -m grpc_tools.protoc --proto_path=api
                             --proto_path=/Users/Jack/api-common-protos/google
                             api/v1/foo.proto
Run Code Online (Sandbox Code Playgroud)

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

gcloud endpoints services deploy api_descriptor.pb api-config.yaml
Run Code Online (Sandbox Code Playgroud)

这样就完成了。然而,开发者门户现在显示:

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.
Run Code Online (Sandbox Code Playgroud)

斯克罗特:

在此输入图像描述

如果我删除注释(和所需的导入),我的 API 的端点开发人员门户可以正常工作。

nar*_*dyt 2

这是开发者门户中的一个错误。我已将此事报告给相关团队。查看Google 针对 Google Cloud Endpoints 的 API Linter 建议?我发布到google-cloud-endpoints@googlegroups.com.