Update: Cloud Endpoints Portal is being deprecated and will no longer be available after 21 March 2023.
After following Deploying the Endpoints configuration I have successfully deployed my compiled .proto
file and gRPC API configuration file.
Great. I decided to be be a good citizen and use Google's API Linter on my .proto
.
This resulted in a number of recommendations to include various annotations. The annotations required new proto
imports;
Before
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
After
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
The annotations require four new proto files to be imported:
import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
All are part of Google's Common API protos, therefore I cloned the repo into /Users/Jack/api-common-protos/
with:
git clone https://github.com/googleapis/api-common-protos.git
...and include it when compiling my .proto
file:
python3 -m grpc_tools.protoc --proto_path=api
--proto_path=/Users/Jack/api-common-protos/google
api/v1/foo.proto
No errors. Great. Finally I deploy the API:
gcloud endpoints services deploy api_descriptor.pb api-config.yaml
This completes. However, the Developer Portal now shows:
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:
If I remove the annotation (and required imports), the Endpoints Developer Portal for my API works fine.
This is a bug in the developer portal. I have reported it to the team responsible. See Google's API Linter suggestions with Google Cloud Endpoints? which I posted to [email protected]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With