K-Phoen / grabana

User-friendly Go library for building Grafana dashboards
MIT License
680 stars 69 forks source link

Yaml Schema for Validation #253

Closed emouawad closed 7 months ago

emouawad commented 7 months ago

Note sure if it exists - but a yaml schema for validation would be useful for writing dashboards / alerts easily for new users. That way in editors such as vscode one would get intellisense and errors when the yaml doesn't match the schema.

for reference vscode can pick up the schmea using smthg like:

# yaml-language-server: $schema=https://raw.githubusercontent.com/K-Phoen/grabana/schemas/schema.json
K-Phoen commented 7 months ago

Hey there!

I generated a JSON Schema for dashboards (see #254). Haven't spent too much time verifying that the schema is 100% accurate though, but it's probably still better than nothing (I actually expect it not to be completely accurate, especially when it comes to required/non-required fields and oneOf declarations)

You should be able to use it in vscode with:

# yaml-language-server: $schema=https://raw.githubusercontent.com/K-Phoen/grabana/master/schemas/dashboard.json
emouawad commented 7 months ago

Thanks I really appreciate the work that has been put into this - would it be possible also to generate a schema for DARK as well?