From c514e2ed8c5993565909d350e3f65d5a6c640277 Mon Sep 17 00:00:00 2001 From: Oleh Omelchenko Date: Sun, 19 Jan 2025 16:49:58 +0200 Subject: [PATCH] feat: add JSON schema validation for Vega and Vega-Lite in the editor --- src/main.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main.js b/src/main.js index 878a572..8e2e4fd 100644 --- a/src/main.js +++ b/src/main.js @@ -17,6 +17,27 @@ require(['vs/editor/editor.main'], async function () { formatOnType: true }); + // Fetch JSON schemas + const vegaSchema = await fetch('https://vega.github.io/schema/vega/v5.json').then(response => response.json()); + const vegaLiteSchema = await fetch('https://vega.github.io/schema/vega-lite/v5.json').then(response => response.json()); + + // Configure JSON schema + monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ + validate: true, + schemas: [ + { + uri: "https://vega.github.io/schema/vega/v5.json", + fileMatch: ["*"], + schema: vegaSchema + }, + { + uri: "https://vega.github.io/schema/vega-lite/v5.json", + fileMatch: ["*"], + schema: vegaLiteSchema + } + ] + }); + const resizer = new PanelResizer(snippetManager); window.editor = editor;