Declarative dashboard and theme schemas
DAC uses embedded, versioned JSON Schema contracts to give YAML dashboards and themes a stable shape. The contracts catch structural errors before a project is served or built, while later dashboard checks confirm that references and data rules make sense. See Interoperability and declarative contracts for the wider format model, Project import and export conversion for conversion between project and external formats, and Dashboard definition lifecycle for how definitions move through the system.
Schema contracts
The schema contract is identified by a stable URL. The URL names both the document kind and its contract version, so a project can pin the format it expects without depending on a local file path.
Version identifiers
DAC currently exposes one dashboard contract and one theme contract. The schema field is optional in an input document. When it is present, it must match the contract selected for that document; when it is absent, the YAML loaders treat the document as the current v1 format.
| Document | Contract identifier | Required document content |
|---|---|---|
| Dashboard | https://getbruin.com/schemas/dac/dashboard/v1 | A non-empty name and at least one rows entry |
| Theme | https://getbruin.com/schemas/dac/theme/v1 | A non-empty name and at least one tokens entry |
The contract files are part of the DAC binary. Validation does not need to fetch a schema from the identifier URL. A future contract can use a new version identifier instead of changing the meaning of an existing v1 contract. References: schemas/embed.go• L12-18, schemas/embed.go• L46-86, schemas/…/schema.json• L1-10, schemas/…/schema.json• L1-10
Dashboard documents
The dashboard contract describes the declarative content needed to present a dashboard. It covers the dashboard name and description, connection and semantic-model context, filters, named queries, notes, rows, and widgets. Filter definitions can also set a one-to-twelve-column layout span for the filter bar.
Rows provide the layout structure and must contain widgets. Widget data can come from named queries, inline result data, or SQL, while chart descriptions can use built-in encodings or a Vega-Lite specification. Widgets and tabs can also map result fields to dashboard filters so a user action can update another part of the dashboard through cross-filtering. The contract also covers chart display settings, reference marks and bands, confidence bounds, series and slice styles, table formatting, client-side pivot layout and value rules, and note links. Table columns may be hidden while remaining part of a named column group, so a grouped table can keep its group structure without showing every member. Display formats can now be expressed as a legacy string, one semantic format, or a field-specific map. Semantic formats can state a display type, an ISO currency code, and a decimal limit. These formats apply to chart axes and values, table numbers, and sparkline axes. References: schemas/…/schema.json• L11-59, schemas/…/schema.json• L123-134, schemas/…/schema.json• L192-526, schemas/…/schema.json• L528-663, schemas/…/schema.json• L681-858, schemas/…/schema.json• L1002-1139
Filter option sources support literal values, query-backed values, semantic dimensions, and metrics. The schema limits which sources can be combined: non-select filters cannot use dimension or metric sources, dimension sources cannot also use queries or values, and metric sources need a dimension or query without literal values. A query-backed metric uses a structured metric definition when it also carries display formatting. References: schemas/…/schema.json• L61-190
Note dimensions support select, date, number, boolean, and text context. If a note dimension omits type, the schema gives it the default select type. Boolean dimensions cannot use multiselect. References: schemas/…/schema.json• L681-735, schemas/schema_test.go• L47-71, schemas/schema_test.go• L290-399
Dashboard widgets can also be tab containers. The container owns only its layout and tab list. Each tab is a complete widget with its own type and data source, so tab fields are not inherited from the container and nested tabs are not accepted. Cross-filter mappings belong to the widget or tab that emits the interaction. References: schemas/…/schema.json• L238-263, schemas/…/schema.json• L299-301, schemas/…/schema.json• L528-663, schemas/…/schema.json• L575-576, pkg/…/model.go• L184-189, pkg/…/validator.go• L264-322
The schema checks shape rather than the truth of a reference. For example, it can require a widget name, require pivot settings for a pivot-table widget, require dimensions for a note, accept a query reference as a string, and accept a structured Vega-Lite specification. The dashboard validation step must still confirm that named queries or semantic fields exist. References: schemas/…/schema.json• L192-526, schemas/…/schema.json• L681-704, pkg/…/validator.go• L201-261
Theme documents
The theme contract describes a named set of design tokens for dashboard presentation. A theme may extend another theme, and its token map must contain at least one string value.
Theme validation keeps the contract open to named token values without prescribing a fixed token list. This lets a project define its visual language while keeping the document envelope stable. References: schemas/…/schema.json• L11-29, pkg/…/theme.go• L11-17
Validation boundary
Validation has two related jobs. JSON Schema protects the document boundary, while DAC’s dashboard rules protect relationships that cannot be judged from field types alone.
Structural validation
YAML is converted to a JSON-compatible value and checked against the selected embedded contract. This check covers required fields, value types, allowed enum values, array sizes, and unknown fields. Objects in the contract may carry extension fields whose names start with x-; other undeclared fields are rejected.
The dashboard and theme loaders apply this check before they create the in-memory document. A missing schema value is then recorded as the current v1 identifier. An explicit identifier from another version fails instead of being silently treated as v1. Schema failures can be formatted with readable field paths; unique named dashboard items use their names instead of only array indexes. References: schemas/embed.go• L26-43, schemas/embed.go• L89-112, schemas/format_errors.go• L18-61, schemas/format_errors.go• L64-109, pkg/…/loader.go• L103-118, pkg/…/theme.go• L19-38, schemas/…/schema.json• L56-59, schemas/…/schema.json• L26-29
Meaning validation
A structurally valid dashboard can still be unusable. DAC therefore performs a second check for dashboard meaning, including widget data sources, layout limits, semantic-model references, named query rules, and filter or chart behavior.
This boundary matters when a schema field contains a name that must match another project object. The schema confirms that the name has the right basic type. Dashboard validation confirms that the name resolves and that the combination of fields is allowed. References: pkg/…/validator.go• L37-160, pkg/…/validator.go• L175-229
Runtime filter values
Filter definitions in the dashboard schema describe the allowed filter shape. At request time, DAC turns supported date expressions, date-range presets, and echoed YAML defaults into canonical values, then rejects unknown names and values with the wrong type before query rendering. This runtime boundary is separate from JSON Schema validation because the values come from a client request rather than from the dashboard document. References: pkg/…/filter_values.go• L12-29, pkg/…/filter_values.go• L32-64, pkg/…/filter_values.go• L113-200, pkg/…/filter_values_test.go• L42-109
Validation flow
The following flow shows how YAML documents use the embedded contracts, while code dashboards enter the same dashboard model through a separate path.
flowchart LR
A[Dashboard YAML] --> C[Dashboard v1 schema]
B[Theme YAML] --> D[Theme v1 schema]
H[Dashboard TSX] --> I[Dashboard model]
C --> E[Dashboard meaning checks]
I --> E
D --> F[Theme document]
E --> G[Dashboard service or build]
The same structural checks support the validation-oriented CLI commands and the normal load paths. A .dashboard.tsx source does not use the YAML schema; its loader produces the dashboard model and then applies the shared post-processing and meaning checks. Query execution is a separate concern. Schema validation does not prove that a connection exists or that SQL returns the expected result. References: docs/…/validate.md• L32-55, docs/…/schemas.md• L56-60, pkg/…/loader.go• L14-56, pkg/…/jsloader.go• L23-57, pkg/…/jsloader.go• L382-456, pkg/…/theme.go• L19-38
Project format boundaries
The embedded contracts apply to declarative dashboard and theme assets, not to every YAML file in a project. Keeping these boundaries clear prevents a connection setting or a code-based dashboard from being mistaken for a schema-versioned document.
YAML project assets
Dashboard .yml and .yaml files are discovered in the project dashboard directory and checked against the dashboard v1 contract. Theme files are discovered in a project themes/ directory or in a dashboard-local themes/ directory and are checked against the theme v1 contract.
Semantic model files are also project assets, but they are loaded through the semantic model path and provide context for dashboard meaning checks. They are not selected from the dashboard or theme schema registry described on this page. References: pkg/…/loader.go• L14-56, pkg/…/project.go• L15-51, pkg/…/project.go• L60-75, schemas/embed.go• L46-54
Other accepted formats
DAC accepts more than schema-versioned YAML. A .dashboard.tsx file is a code-based dashboard source and follows its own load path. The loader converts its JSX tree into the same dashboard model used by declarative dashboards, but the source itself is not checked as a dashboard YAML document. The .bruin.yml file is project connection and environment configuration; it is parsed as operational configuration and does not use the dashboard or theme JSON schemas.
These formats can work in the same project, but they do not share the same contract. Import and export conversion can produce or consume external representations, while the resulting declarative YAML must still satisfy the DAC contract before normal use. See Interoperability and declarative contracts and Project import and export conversion. References: pkg/…/loader.go• L27-53, pkg/…/loader.go• L139-142, pkg/…/jsloader.go• L98-232, pkg/…/jsloader.go• L1086-1089, pkg/…/config.go• L11-43, pkg/…/config.go• L46-64
Change checklist
When these files or sections are changed, remember to consider these:
- Change the schema URL in the JSON document, the Go schema registry, the loader default, and the schema field constant as one versioned contract change.
- Add a dashboard field to the JSON schema and the dashboard model together. If the field names another object or changes a field combination, also extend dashboard meaning validation. Keep widget-type rules aligned with the schema conditions.
- Change dashboard note shape or widget note links together. Keep note dimensions and their selection rules aligned with the viewer behavior.
- Keep the default for an omitted note dimension type aligned with the dashboard model and semantic validation. An omitted type is a valid
selectdimension in v1. - Change filter option source rules with filter loading and option generation. Keep dimension, metric, query, and literal-value combinations aligned with the schema.
- Change filter layout fields and their limits together with the filter model and its layout validation. A schema range alone does not define how the filter bar uses the value.
- Change theme token rules with the theme loader and the code that maps tokens to the viewer’s visual settings.
- Change accepted dashboard or theme locations with project path resolution and the file-discovery rules. Otherwise a valid document can remain unseen.
- Keep imported dashboard output aligned with the active dashboard contract when schema fields or allowed values change.
- Keep dashboard schema filter definitions aligned with request normalization and value validation. Date expressions, date-range presets, and echoed YAML defaults must remain accepted in the same canonical form.
- Keep the tab-container schema, the dashboard model, and meaning validation aligned. Container-only fields must not become silently inherited by tabs.
- Keep schema error formatting aligned with schema error paths and the validation caller. A change in nested paths can turn useful item names into unclear array indexes or hide the intended failure.
- Keep the shared display-format contract aligned across chart encodings, table number formats, and sparkline axes. Preserve support for legacy string formats when changing semantic format fields.
- Keep cross-filter mappings aligned with the widget and tab models and with the interaction path. The schema must continue to require a non-empty source field and target filter for each mapping.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A document declares a dashboard or theme schema URL from another version | The document fails schema validation instead of being read as v1 | Use the matching v1 identifier or omit schema when the current default is intended |
| A dashboard omits its name or rows, or a row has no widgets | The dashboard cannot pass the structural contract | Keep the required document and layout levels present |
| A filter uses a column span outside 1 to 12 or uses a non-integer value | The dashboard fails structural validation | Use an integer col value from 1 through 12, or omit it for the default layout |
| A filter option mixes incompatible sources, or a non-select filter uses a dimension or metric source | The filter fails structural validation before option values can be used | Use one allowed source pattern. Use a structured metric when a query-backed metric needs display formatting |
| A note omits its dimensions, or a widget points to an undeclared note | The note fails schema validation, or later dashboard validation rejects the link | Give each note an id and dimensions, then use only defined note ids |
| A note dimension uses an empty, date-range, or unknown type | Structural validation rejects the note dimension | Omit type for the v1 select default or use a supported type |
A boolean note dimension uses multiselect | Structural validation rejects the note dimension | Keep multiselect false or omit it for boolean dimensions |
A note dimension uses unsupported options, default, or multiple fields | Structural validation rejects the note dimension | Use only the fields defined for note dimensions |
| A theme has no token entries | Theme loading fails before the theme can be used | Define at least one string token |
A document uses an undeclared field that does not start with x- | Structural validation rejects the document | Add a supported field or use an x- extension only for local metadata |
A widget declares pivot_table without pivot, or a different widget declares pivot | Structural validation rejects the widget | Keep the pivot settings only on a pivot-table widget and provide its required value definitions |
A pivot table uses an image column, or a table format uses pivot-only scaleBy settings | Structural validation rejects the widget settings | Keep image columns for plain tables and use scaleBy only in pivot value formatting |
| A dashboard has a valid field type but an unknown query, model, metric, or invalid layout relationship | Schema validation can pass, but dashboard validation fails | Run the dashboard validation path and resolve the referenced project objects |
| A request sends an unknown filter name or a value with the wrong type or range | The request is rejected before query rendering | Normalize supported client values, then validate against the dashboard’s filter definitions |
| A tabs widget puts a data or chart field on the container, nests another tabs widget, or omits a complete tab definition | The dashboard fails structural or meaning validation | Keep the container limited to layout fields and define each tab as a complete non-tab widget |
| A cross-filter mapping has an empty field or filter name, or uses an undeclared target filter | The mapping fails structural validation or cannot update the intended filter | Use non-empty names and resolve the target through the dashboard’s filter set |
| A display format uses an invalid semantic type, currency code, decimal range, or field map | Schema validation rejects the chart, table, or sparkline format | Use a legacy string, one valid semantic format, or a non-empty field map with valid semantic entries |
Key files
| File | Why to read it |
|---|---|
| schemas/embed.go | Defines the public schema identifiers, embeds the contracts, and provides the common YAML validation boundary. |
| schemas/…/schema.json | States the v1 dashboard document shape, filter option source rules, cross-filter mappings, and the allowed dashboard building blocks, chart, table, pivot-table, note, filter, tab, grouped-column, and display-format forms. |
| schemas/…/schema.json | States the v1 theme envelope, inheritance field, token requirement, and extension rule. |
| schemas/format_errors.go | Turns raw schema failures into concise paths that can use unique dashboard item names. |
| pkg/…/loader.go | Shows where dashboard YAML enters the system and where the dashboard contract is applied. |
| pkg/…/jsloader.go | Shows the separate code-dashboard path and its conversion into the shared dashboard model. |
| pkg/…/filter_values.go | Defines the request-time normalization and fail-closed checks that complement the document schema for filter values. |
| pkg/…/model.go | Defines the shared dashboard model and the accepted filter, widget, tab, and source concepts used by loaders and validators. |
| pkg/…/theme.go | Shows how theme files use the contract and receive the default v1 identifier. |
| pkg/…/validator.go | Shows the checks that follow structural schema validation and test dashboard meaning. |
| pkg/…/project.go | Shows how dashboard, semantic-model, and theme assets are grouped into a project. |
| pkg/…/config.go | Defines the separate .bruin.yml environment and connection configuration boundary. |
| pkg/…/definition_validation.go | Shows how schema failures from supplied semantic models are formatted and combined with dashboard validation. |
| schemas/schema_test.go | Demonstrates valid minimal documents, filter layout bounds, note defaults and constraints, filters, Vega-Lite charts, pivot tables, image and grouped columns, display formats, optional schema fields, version rejection, tabs, and repository fixture coverage. |