目录结构
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
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 代码库。如需详细了解目录结构,请参阅 Service Infrastructure 示例 API。
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-02-18 UTC.
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"很难理解"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"信息或示例代码不正确"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"没有我需要的信息/示例"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]