数据 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"
]
}