JSON schemas

#41 · open · 1 comments

View on GitHub ↗

slundi

Hello To validate configuration and theme we could use JSON schemas. It allows to: * check validity * create documentation * IDE can offer code completion with it I've begun there: https://github.com/Beastwick18/nyaa/compare/main...slundi:nyaa:json-schemas (I've tried IA to generate them... I need to check them now) ## How to use it Using relative path: ```toml #:schema ./foo-schema.json # ^---- Using relative path $schema = "https://raw.github.com/Beastwick18/nyaa/theme.schema.json" # ^---- If we import it from an URL foo = "bar" ``` ## Ressources * https://taplo.tamasfe.dev/configuration/using-schemas.html * https://www.schemastore.org/json/ * https://json-schema.org/

Comments

slundi

I've done a lot of stuff today it needs further testing: If you get the schema from my branch, you can check with: ```shell # install taplo with one of those commands cargo install taplo nix-shell -p taplo # add on top of your toml # "$schema" = "https://github.com/slundi/nyaa/blob/json-schemas/config.schema.json" # for the config # "$schema" = "https://raw.githubusercontent.com/slundi/nyaa/refs/heads/json-schemas/theme.schema.json" # for a theme file # check any file taplo check /path/to/my/congig.toml ```