如何部署转码后的gRPC API,以使生成的REST文档没有错误

时间:2019-07-15 11:41:52

标签: rest documentation gcloud grpc transcode

我在Google Kubernetes Engine中有一个gRPC API。我使用Google的可扩展服务代理对REST客户端的API进行代码转换。 REST路径在.proto文件中进行了注释。

当我部署API时,Google的云会在我的开发人员门户中慷慨地生成一些关于API的精彩文档。

文档的gRPC部分很好,但是REST方面有很多缺陷。对于开发人员而言,似乎没有迹象表明何时需要使用JSON中的数组,或者何时需要使用单个值。此外,某些地方的文档中缺少一些对象的属性,而其他地方则没有。

这是我编译.proto文件的方式:

grpc_tools_ruby_protoc \
    --include_imports \
    --include_source_info \
    -I app/grpc/protos \
    -I ../api-common-protos \
    --ruby_out=app/rpc \
    --grpc_out=app/rpc \
    --descriptor_set_out=deploy/api_descriptor.pb \
    app/grpc/protos/*.proto

这就是我(从api_descriptor.pb所在的目录)部署到Google Endpoints Services的方式

gcloud endpoints services deploy api_descriptor.pb api_config.yaml

这是我的api_config.yaml

# The configuration schema is defined by service.proto file
# https://github.com/googleapis/googleapis/blob/master/google/api/service.proto
type: google.api.Service
config_version: 3

#
# Name of the service configuration.
#
name: rev79.endpoints.rev79-232812.cloud.goog

#
# API title to appear in the user interface (Google Cloud Console).
#
title: Rev79 gRPC API
apis:
- name: grpc.health.v1.Health
- name: sil.rev79.Admin
- name: sil.rev79.Programs
- name: sil.rev79.Languages
- name: sil.rev79.Markers
- name: sil.rev79.I18n
- name: sil.rev79.Products
- name: sil.rev79.Users

usage:
  rules:
    # Health Check method can be called without an API Key.
  - selector: grpc.health.v1.Health.Check
    allow_unregistered_calls: true

如果我做错了什么,我应该改变什么?

如果这是Google用于生成文档的服务中的错误,那么我应该在哪里报告该错误?

这里是Google's docs on this topic 以及包含how to use the transcoding feature

上更多文档的文件

0 个答案:

没有答案