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:
dbt_project.yml
)packages.yml
)selectors.yml
)models/whatever.yml
).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/latest/dbt_yml_files-latest.json": [
"/**/*.yml",
"!profiles.yml",
"!dbt_project.yml",
"!packages.yml",
"!selectors.yml",
"!profile_template.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_project-latest.json": [
"dbt_project.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/selectors-latest.json": [
"selectors.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/packages-latest.json": [
"packages.yml"
]
},
}
.vscode/extensions.json
file containing the following data inside of your dbt project's directory:
{
"recommendations": [
"redhat.vscode-yaml"
]
}
:CocInstall coc-yaml
coc-settings.json
using :CocConfig
works):
{
"yaml.schemas": {
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_yml_files-latest.json": [
"/**/*.yml",
"!profiles.yml",
"!dbt_project.yml",
"!packages.yml",
"!selectors.yml",
"!profile_template.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_project-latest.json": [
"dbt_project.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/selectors-latest.json": [
"selectors.yml"
],
"https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/packages-latest.json": [
"packages.yml"
]
},
}
IDEs by JetBrains like PyCharm and IntelliJ enable us to use the JSON Schema, using the JSON schema mapping feature.
There is no way to add the preferences with a configuration file like VS Code. As we have to manually configure them one by one, we just describe values of the configurations below. If you want to know the details, the dbt YAML validator in JetBrains article describes how to configure the JSON schema mapping in details.
https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_project-latest.json
dbt_project.yml
https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/packages-latest.json
packages.yml
https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/selectors-latest.json
selectors.yml
https://raw.githubusercontent.com/dbt-labs/dbt-jsonschema/main/schemas/latest/dbt_yml_files-latest.json
models/**/*.yml
, analysis/**/*.yml
, snapshots/**/*.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
.