JSON Schema is a way to define the expected shape of JSON (or YAML) documents. This enables live checking of your files, as well as Intellisense/autocomplete as you type.
This repository contains schemata for:
- Project definition files (
dbt_project.yml
) - Package files (
packages.yml
) - Selectors files (
selectors.yml
) - Property files (
models/whatever.yml
)
- Install the VSCode-YAML extension
- Inside of your dbt project's directory, create a
.vscode/settings.json
file containing the following data. This is what tells the extension which schema to associate with each file.
{
"yaml.schemas": {
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/dbt_yml_files.json": [
"/**/*.yml",
"!profiles.yml",
"!dbt_project.yml",
"!packages.yml",
"!selectors.yml",
"!profile_template.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/dbt_project.json": [
"dbt_project.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/selectors.json": [
"selectors.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/packages.json": [
"packages.yml"
]
},
}
- To prompt other users to install the YAML extension, create a
.vscode/extensions.json
file containing the following data inside of your dbt project's directory:
{
"recommendations": [
"redhat.vscode-yaml"
]
}
- Install the coc.nvim plugin
- Install coc-yaml:
:CocInstall coc-yaml
- Add JSON Schema (there might be a better way to do this, but adding directly to
coc-settings.json
using:CocConfig
works):
{
"yaml.schemas": {
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/dbt_yml_files.json": [
"/**/*.yml",
"!profiles.yml",
"!dbt_project.yml",
"!packages.yml",
"!selectors.yml",
"!profile_template.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/dbt_project.json": [
"dbt_project.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/selectors.json": [
"selectors.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/packages.json": [
"packages.yml"
]
},
}
Do you use a different IDE which also supports JSON Schema? Please open a PR with setup instructions and links to any extensions!
PRs that improve these schemata are welcome!
Please ensure that JSON keys are sorted by vscode-sort-json according to the rules in .vscode/settings
.