Editor schemas (autocomplete for lab.json & settings.toml)¶
otto can generate JSON Schema for the files you edit
by hand — lab.json, settings.toml, and the reservations JSON — so your
editor offers field autocomplete and flags typos. The schemas are generated from
the pydantic models inside the otto you have installed, so they always match your
version. There is nothing to download and nothing that can go stale.
Generate the schemas¶
otto schema export --out schemas
This writes (into schemas/):
File |
Describes |
|---|---|
|
the whole |
|
a single entry in the |
|
a single host of one type |
|
|
|
the reservations JSON file |
|
the monitor dashboard’s internal chart/tab-layout model — not a file you edit, and not served at any endpoint; it drives the generated TypeScript types the web dashboard builds against ( |
Run it again after upgrading otto to pick up new fields. Custom host classes
registered via an init module in .otto/settings.toml are included
automatically — each gets its own <type>-host.schema.json and an entry in
lab.schema.json. Pass --builtins-only to emit just the built-in types
(unix, embedded, zephyr), excluding any custom ones.
VS Code¶
lab.json and the reservations JSON are covered by the built-in JSON
language server. Add to your workspace .vscode/settings.json:
{
"json.schemas": [
{ "fileMatch": ["**/lab.json"], "url": "./schemas/lab.schema.json" },
{ "fileMatch": ["**/reservations.json"], "url": "./schemas/reservations.schema.json" }
]
}
For settings.toml, install the
Even Better TOML
extension and add:
{
"evenBetterToml.schema.associations": {
".*/settings\\.toml$": "./schemas/settings.schema.json"
}
}
Neovim¶
With the JSON language server (jsonls, from vscode-json-languageserver) via
nvim-lspconfig:
require('lspconfig').jsonls.setup({
settings = {
json = {
schemas = {
{ fileMatch = { 'lab.json' }, url = './schemas/lab.schema.json' },
{ fileMatch = { 'reservations.json' }, url = './schemas/reservations.schema.json' },
},
},
},
})
For settings.toml, the taplo language server
honours schema directives. Either add a directive at the top of the file:
#:schema ./schemas/settings.schema.json
or associate it in the taplo config (.taplo.toml):
[[rule]]
include = ["settings.toml"]
[rule.schema]
path = "schemas/settings.schema.json"
Note on drift¶
The schemas reflect the otto version that generated them. There is no committed
copy in the otto repo — regenerate with otto schema export whenever you
upgrade so the fields stay in sync with your installed models.