數據 API 產生器需要至少一個組態檔才能執行。 此 JSON 型檔案會定義您的 API 設定,從環境設定到實體定義。 其開頭為 $schema 屬性,其會啟用檔案其餘部分的架構驗證。
Top-level properties
| Property | Description |
|---|---|
| $schema | 此組態的 JSON 架構 URI。 |
| data-source | 包含資料庫連線設定的物件。 |
| data-source-files | 其他組態檔路徑的陣列。 |
| runtime | 物件設定運行時間行為。 |
| entities | 對象,定義透過 REST 或 GraphQL 公開的所有實體。 |
Data-source properties
| Property | Description |
|---|---|
| data-source | 包含資料庫連線設定的物件。 |
| data-source.database-type | 後端中使用的資料庫類型(mssql、postgresql、mysql、cosmosdb_nosql、cosmosdb_postgresql)。 |
| data-source.connection-string | 所選資料庫類型的連接字串。 |
| data-source.options | 資料庫特定的選項和進階設定。 |
| data-source.health | 數據源的健康情況檢查組態。 |
| data-source-files | 其他組態檔路徑的陣列。 |
Runtime properties
| Property | Description |
|---|---|
| runtime | 物件設定運行時間行為。 |
| runtime.pagination | API 回應的分頁設定。 |
| runtime.rest | REST API 全域設定。 |
| runtime.graphql | GraphQL API 全域設定。 |
| runtime.cache | 全域回應快取設定。 |
| runtime.telemetry | 遙測、記錄和監視設定。 |
| runtime.health | 全域健康情況檢查組態。 |
Entities properties
| Property | Description |
|---|---|
| entities | 對象,定義透過 REST 或 GraphQL 公開的所有實體。 |
| entities.entity-name.source | 實體的資料庫來源詳細數據。 |
| entities.entity-name.rest | 實體的 REST API 組態。 |
| entities.entity-name.graphql | 實體的 GraphQL API 組態。 |
| entities.entity-name.permissions | 實體的許可權和訪問控制。 |
| entities.entity-name.relationships | 與其他實體的關聯性。 |
| entities.entity-name.cache | 實體層級快取組態。 |
| entities.entity-name.health | 實體層級健康情況檢查組態。 |
Schema
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
$root |
$schema |
字串 | ✔️ Yes | None |
Each configuration file begins with a $schema property, specifying the JSON schema for validation.
Format
{
"$schema": <string>
}
Example
{
"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json"
}
Tip
最新的架構一律可在 取得 https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json。
Versioning
特定 URL 提供架構檔案,以確保您可以使用正確的版本或最新的可用架構。
https://github.com/Azure/data-api-builder/releases/download/<VERSION>-<suffix>/dab.draft.schema.json
將 VERSION-suffix 取代為您想要的版本。
https://github.com/Azure/data-api-builder/releases/download/v0.3.7-alpha/dab.draft.schema.json
數據源檔案
| Parent | Property | 類型 | Required | Default |
|---|---|---|---|---|
$root |
data-source-files |
string array | ❌ 否 | None |
數據 API 產生器支援多個組態檔,其中一個設定指定為管理設定的最上層檔案 runtime 。 所有組態都會共用相同的 JSON 架構,允許 runtime 任何或每個檔案中的設定沒有錯誤。 分割實體以取得更佳的組織。
Format
{
"data-source-files": [ "<string>" ]
}
多個組態規則
- 每個組態檔都必須包含
data-source屬性。 - 每個組態檔都必須包含
entities屬性。 - 最上層組態必須包含
runtime。 - 子組態可以包含
runtime,但會被忽略。 - 子組態檔可以包含自己的子檔案。
- 組態檔可以組織成子資料夾。
- 實體名稱在所有組態檔中都必須是唯一的。
- 不支援不同組態檔中的實體之間的關聯性。
Examples
{
"data-source-files": [
"dab-config-2.json",
"my-folder/dab-config-3.json",
"my-folder/my-other-folder/dab-config-4.json"
]
}