目录结构
API 服务通常使用 .proto
文件来定义 API 接口,并使用 .yaml
文件来配置 API 服务。每个 API 服务必须在 API 代码库中有一个 API 目录。API 目录应该包含所有 API 定义文件和构建脚本。
每个 API 目录应该具有以下标准布局:
API 目录
代码库必要条件
BUILD
:构建文件。
METADATA
:构建元数据文件。
OWNERS
:API 目录所有者。
README.md
:有关 API 服务的常规信息。
配置文件
{service}.yaml
:基准服务配置文件,google.api.Service
proto 消息的 YAML 表示法。
prod.yaml
:生产环境增量服务配置文件。
staging.yaml
:模拟环境增量服务配置文件。
test.yaml
:测试环境增量服务配置文件。
local.yaml
:本地环境增量服务配置文件。
文档文件
doc/*
:技术文档文件。它们应采用 Markdown 格式。
接口定义
v[0-9]*/*
:每个这样的目录都包含 API 的主要版本,主要是 proto 文件和构建脚本。
{subapi}/v[0-9]*/*
:每个 {subapi}
目录都包含子 API 的接口定义。每个子 API 可以有自己的独立主要版本。
type/*
:proto 文件,包含在不同 API 之间、同一 API 的不同版本之间或 API 与服务实现之间共享的类型。type/*
下的类型定义一旦发布就不应该有破坏性更改。
公共 Google API 定义在 GitHub 上发布,请参阅 Google API 代码库。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-11。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-11。"],[[["\u003cp\u003eAPI services utilize \u003ccode\u003e.proto\u003c/code\u003e files for API definition and \u003ccode\u003e.yaml\u003c/code\u003e files for service configuration.\u003c/p\u003e\n"],["\u003cp\u003eEach API service must reside in an API directory within an API repository, containing all definition files and build scripts.\u003c/p\u003e\n"],["\u003cp\u003eAn API directory should follow a standard layout including repository prerequisites, configuration files, documentation files, and interface definitions, like versioned sub-API directories, and type files for shared proto files.\u003c/p\u003e\n"],["\u003cp\u003ePublic Google API definitions are available on the \u003ca href=\"https://github.com/googleapis/googleapis\"\u003eGoogle APIs\u003c/a\u003e GitHub repository, as seen with the \u003ca href=\"https://github.com/googleapis/googleapis/tree/master/google/example/endpointsapis\"\u003eService Infrastructure Example API\u003c/a\u003e.\u003c/p\u003e\n"]]],[],null,[]]