data-api-builder
data-api-builder copied to clipboard
🥕[Bug]: JSON Schema: Inaccurate Required/Not-Required constraints
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
-
data-source.options.database(forcosmosdb_nosql)-
Docs: Required when
database-typeiscosmosdb_nosql. - Schema: Not marked as required.
-
Docs: Required when
-
data-source.options.schema(forcosmosdb_nosql)-
Docs: Required when
database-typeiscosmosdb_nosql. - Schema: Not marked as required.
-
Docs: Required when
-
entities.<entity>.source.key-fields-
Docs: Required only when
typeisview. - Schema: Not conditionally marked as required.
-
Docs: Required only when
-
entities.<entity>.permissions- Docs: Required for defining access controls for the entity.
- Schema: Not marked as required.
Not-Required Properties REQUIRED in Schema
-
runtime.rest.enabled-
Docs: Optional; defaults to
true. - Schema: Marked as required.
-
Docs: Optional; defaults to
-
runtime.graphql.enabled-
Docs: Optional; defaults to
true. - Schema: Marked as required.
-
Docs: Optional; defaults to
Suggested Fix
-
For
cosmosdb_nosqlConfiguration:
{
"if": {
"properties": { "database-type": { "const": "cosmosdb_nosql" } }
},
"then": {
"properties": {
"options": {
"required": ["database", "schema"]
}
}
}
}
- For Entity Definitions:
{
"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"]
}
}
}
- For Runtime Configuration:
{
"properties": {
"runtime": {
"properties": {
"rest": {
"properties": {
"enabled": { "type": "boolean", "default": true }
}
},
"graphql": {
"properties": {
"enabled": { "type": "boolean", "default": true }
}
}
}
}
}
}
I think dab validate should dynamically be driven from the schema.