Azure / Azure/data-api-builder

🥕[Bug]: JSON Schema: Inaccurate Required/Not-Required constraints

Open
#2,519 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.5k
Forks
370
Avg merge
3d 17h
Merged PRs (30d)
8

Description

Discrepancies exist between the official Data API Builder documentation and the JSON schema regarding the required status of certain properties. The documentation is correct and highlights where the schema needs to be adjusted.

## Required Properties NOT Required in Schema

1. **`data-source.options.database`** (for `cosmosdb_nosql`)
- **Docs:** Required when `database-type` is `cosmosdb_nosql`.
- **Schema:** Not marked as required.

2. **`data-source.options.schema`** (for `cosmosdb_nosql`)
- **Docs:** Required when `database-type` is `cosmosdb_nosql`.
- **Schema:** Not marked as required.

3. **`entities..source.key-fields`**
- **Docs:** Required **only** when `type` is `view`.
- **Schema:** Not conditionally marked as required.

4. **`entities..permissions`**
- **Docs:** Required for defining access controls for the entity.
- **Schema:** Not marked as required.

## Not-Required Properties REQUIRED in Schema

1. **`runtime.rest.enabled`**
- **Docs:** Optional; defaults to `true`.
- **Schema:** Marked as required.

2. **`runtime.graphql.enabled`**
- **Docs:** Optional; defaults to `true`.
- **Schema:** Marked as required.

## Suggested Fix

1. **For `cosmosdb_nosql` Configuration:**

```json
{
"if": {
"properties": { "database-type": { "const": "cosmosdb_nosql" } }
},
"then": {
"properties": {
"options": {
"required": ["database", "schema"]
}
}
}
}
```

2. **For Entity Definitions:**

```json
{
"patternProperties": {
"^[a-zA-Z0-9_-]+$": {
"properties": {
"source": {
"properties": {
"type": { "type": "string" },
"key-fields": { "type": "array" }
},
"required": ["type"],
"allOf": [
{
"if": {
"properties": { "type": { "const": "view" } }
},
"then": { "required": ["key-fields"] }
}
]
},
"permissions": { "type": "array" }
},
"required": ["source", "permissions"]
}
}
}
```

3. **For Runtime Configuration:**

```json
{
"properties": {
"runtime": {
"properties": {
"rest": {
"properties": {
"enabled": { "type": "boolean", "default": true }
}
},
"graphql": {
"properties": {
"enabled": { "type": "boolean", "default": true }
}
}
}
}
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.