目錄結構
API 服務通常是使用 .proto
檔案來定義 API 介面,並使用 .yaml
檔案來設定 API 服務。每個 API 服務都必須在 API 存放區中設置一個 API 目錄。API 目錄應包含所有 API 定義檔案和建構指令碼。
每個 API 目錄都應具有以下標準配置:
API 目錄
存放區必要項目
BUILD
:建構檔案。
METADATA
:建構中繼資料檔案。
OWNERS
:API 目錄擁有者。
README.md
:API 服務的一般資訊。
設定檔
{service}.yaml
:基準服務設定檔,為採 YAML 表示法的 google.api.Service
proto 訊息。
prod.yaml
:實際工作環境 delta 服務設定檔。
staging.yaml
:測試環境 delta 服務設定檔。
test.yaml
:測試 delta 服務設定檔。
local.yaml
:本機 delta 服務設定檔。
說明文件檔案
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 存放區。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間: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"]],["上次更新時間: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,[]]