Add JSON Schema generation for Flint ChartAssemblyInput - #83
Draft
yelper wants to merge 1 commit into
Draft
Conversation
Introduce scripts/gen-json-schema.ts that produces 5 JSON Schema files in docs/schema/: - flint-input.schema.json (universal — 18 chart types common to all backends) - flint-input-vegalite.schema.json (35 chart types) - flint-input-echarts.schema.json (37 chart types) - flint-input-chartjs.schema.json (21 chart types) - flint-input-plotly.schema.json (38 chart types) Each schema includes per-chart-type conditional sub-schemas (if/then) that constrain valid encoding channels and typed chartProperties. The schemas use Draft 2020-12 and allow a root \\\ property for standalone files. Run via: npm run gen:schema Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a generation script (
scripts/gen-json-schema.ts) that produces JSON Schema files describing the full permittedChartAssemblyInputshape. These schemas enable LLM structured-output validation, IDE autocomplete for JSON-based workflows, and runtime validation.This PR is just for feedback for the implementation; we'd need to wire it up to the build scripts and publicize it somewhere on the docs site.
If we actually wanted to do versioning (i.e., the $schema determines how Flint parses the given spec), then we'd need to publish these schemas in a well-known place. For Microsoft, this would be in the under the "http://developer.microsoft.com/json-schemas" URI, which is governed by https://github.com/microsoft/json-schemas/.
Output
Five schema files in
docs/schema/:flint-input.schema.jsonflint-input-vegalite.schema.jsonflint-input-echarts.schema.jsonflint-input-chartjs.schema.jsonflint-input-plotly.schema.jsonSchema features
ChartAssemblyInputstructure (data, semantic_types, chart_spec, options, field_display_names)chartTypeenum - precise per backend; universal schema only includes types common to all four backendsallOf+if/then) constraining valid encoding channel names and typedchartPropertiesAssembleOptionswith all layout tuning parameters fully typedSemanticAnnotationobject form$+schemaproperty allowed for standalone.jsonfilesUsage
npm run gen:schemaExample usage (by users)
Enables per-chart autocomplete suggestions / validation.
Open questions
gen:schemainto a pre-commit or CI check to keep schemas in sync?