Commit b602c39
test: validate writer output against Vega-Lite v6 JSON Schema (#175)
* chore: add jsonschema dev-dependency for schema validation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore: vendor Vega-Lite v6 JSON Schema
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat: add assert_valid_vegalite() test helper with schema validation
- Add jsonschema = "0.44" to dev-dependencies in src/Cargo.toml
- Vendor the Vega-Lite v6 JSON Schema to src/writer/vegalite/schema/v6.json
- Add sanitize_vegalite_schema() to rename non-URI-safe definition keys
(angle brackets, parens, pipes, etc.) so jsonschema can compile the schema
- Add LazyLock<Validator> VL_SCHEMA and assert_valid_vegalite() helper
- Add test_schema_validation_catches_invalid_spec test that verifies a valid
spec passes and an invalid mark value fails validation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: validate all writer specs against Vega-Lite v6 schema
Add assert_valid_vegalite() calls to 14 writer tests that produce
full specs. 4 tests fail schema validation, revealing real writer bugs:
- 3 facet tests: "height":"container" invalid on FacetSpec in VL v6
- 1 legend test: "values" not a valid legend property in VL v6
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(vegalite): don't emit bin=\"binned\" for non-positional encodings
In VL v6, the \"binned\" string value for the `bin` property is only
valid for positional channels (x, y). Non-positional channels such as
color, size, and opacity only accept a boolean, a BinParams object, or
null. Emitting `\"bin\": \"binned\"` on a color encoding therefore fails
schema validation.
Fix: guard the `bin: \"binned\"` assignment with `!is_binned_legend` so
it is only added for positional aesthetics. Binned legend aesthetics
already get the correct treatment via a threshold scale type and do not
need the `bin` property at all.
Also remove a duplicate `jsonschema` entry in src/Cargo.toml that was
introduced while retrofitting existing tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* style: fix rustfmt formatting in sanitize_vegalite_schema
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* perf: only rewrite $ref strings when sanitizing VL schema
Replace map_strings (which allocated for every string in the 1.8MB
schema) with rewrite_refs that only visits $ref values in objects.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: extract VEGALITE_VERSION constant for schema URL
Add a VEGALITE_VERSION constant ("v6") used by the writer to construct
the $schema URL. The vendored schema file at schema/v6.json must match.
A test verifies the constant and writer URL stay in sync — when bumping
versions, update the constant, rename the vendored file, and update the
include_str! path.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* test: verify vendored schema matches upstream on each test run
Download the schema from the writer's $schema URL and compare it to
the vendored copy. Skips gracefully when offline. This catches drift
between the vendored file and upstream Vega-Lite releases.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: trim redundant comments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: use full URL constant VEGALITE_SCHEMA instead of version fragment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: use VEGALITE_SCHEMA constant directly in upstream check test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Run cargo fmt
* fix: close unclosed test function and add missing #[test] attribute
The test_vendored_schema_matches_upstream function was missing its
closing brace, and test_secondary_channels_have_no_disallowed_properties
was missing its #[test] attribute (since it was accidentally nested
inside the previous function).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 21786f4 commit b602c39
4 files changed
Lines changed: 32628 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
851 | | - | |
852 | | - | |
| 851 | + | |
| 852 | + | |
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
| 361 | + | |
| 362 | + | |
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
365 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
366 | 373 | | |
367 | 374 | | |
368 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
369 | 379 | | |
370 | | - | |
371 | 380 | | |
372 | | - | |
373 | | - | |
374 | 381 | | |
375 | 382 | | |
376 | 383 | | |
377 | 384 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | 385 | | |
382 | 386 | | |
383 | 387 | | |
| |||
406 | 410 | | |
407 | 411 | | |
408 | 412 | | |
409 | | - | |
| 413 | + | |
410 | 414 | | |
411 | 415 | | |
412 | 416 | | |
413 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
414 | 424 | | |
415 | 425 | | |
416 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
417 | 430 | | |
418 | | - | |
419 | 431 | | |
420 | | - | |
421 | | - | |
422 | 432 | | |
423 | 433 | | |
424 | 434 | | |
| |||
865 | 875 | | |
866 | 876 | | |
867 | 877 | | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
868 | 882 | | |
869 | 883 | | |
870 | 884 | | |
871 | 885 | | |
872 | | - | |
873 | 886 | | |
874 | 887 | | |
875 | 888 | | |
876 | 889 | | |
877 | | - | |
878 | 890 | | |
879 | 891 | | |
880 | | - | |
| 892 | + | |
881 | 893 | | |
882 | 894 | | |
883 | 895 | | |
| |||
1078 | 1090 | | |
1079 | 1091 | | |
1080 | 1092 | | |
| 1093 | + | |
1081 | 1094 | | |
| 1095 | + | |
1082 | 1096 | | |
1083 | 1097 | | |
1084 | 1098 | | |
1085 | 1099 | | |
1086 | 1100 | | |
1087 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1088 | 1188 | | |
1089 | 1189 | | |
1090 | 1190 | | |
| |||
1305 | 1405 | | |
1306 | 1406 | | |
1307 | 1407 | | |
| 1408 | + | |
1308 | 1409 | | |
1309 | 1410 | | |
1310 | 1411 | | |
| |||
1350 | 1451 | | |
1351 | 1452 | | |
1352 | 1453 | | |
| 1454 | + | |
1353 | 1455 | | |
1354 | 1456 | | |
1355 | 1457 | | |
| |||
1385 | 1487 | | |
1386 | 1488 | | |
1387 | 1489 | | |
| 1490 | + | |
1388 | 1491 | | |
1389 | 1492 | | |
1390 | 1493 | | |
| |||
1515 | 1618 | | |
1516 | 1619 | | |
1517 | 1620 | | |
| 1621 | + | |
1518 | 1622 | | |
1519 | 1623 | | |
1520 | 1624 | | |
| |||
1624 | 1728 | | |
1625 | 1729 | | |
1626 | 1730 | | |
| 1731 | + | |
1627 | 1732 | | |
1628 | 1733 | | |
1629 | 1734 | | |
| |||
1719 | 1824 | | |
1720 | 1825 | | |
1721 | 1826 | | |
| 1827 | + | |
1722 | 1828 | | |
1723 | 1829 | | |
1724 | 1830 | | |
| |||
1747 | 1853 | | |
1748 | 1854 | | |
1749 | 1855 | | |
| 1856 | + | |
1750 | 1857 | | |
1751 | 1858 | | |
1752 | 1859 | | |
| |||
1790 | 1897 | | |
1791 | 1898 | | |
1792 | 1899 | | |
| 1900 | + | |
1793 | 1901 | | |
1794 | 1902 | | |
1795 | 1903 | | |
| |||
1829 | 1937 | | |
1830 | 1938 | | |
1831 | 1939 | | |
| 1940 | + | |
1832 | 1941 | | |
1833 | 1942 | | |
1834 | 1943 | | |
| |||
1853 | 1962 | | |
1854 | 1963 | | |
1855 | 1964 | | |
| 1965 | + | |
1856 | 1966 | | |
1857 | 1967 | | |
1858 | 1968 | | |
| |||
1872 | 1982 | | |
1873 | 1983 | | |
1874 | 1984 | | |
| 1985 | + | |
1875 | 1986 | | |
1876 | 1987 | | |
1877 | 1988 | | |
| |||
2181 | 2292 | | |
2182 | 2293 | | |
2183 | 2294 | | |
| 2295 | + | |
2184 | 2296 | | |
2185 | 2297 | | |
2186 | 2298 | | |
| |||
2264 | 2376 | | |
2265 | 2377 | | |
2266 | 2378 | | |
| 2379 | + | |
2267 | 2380 | | |
2268 | 2381 | | |
2269 | 2382 | | |
| |||
2344 | 2457 | | |
2345 | 2458 | | |
2346 | 2459 | | |
| 2460 | + | |
2347 | 2461 | | |
2348 | 2462 | | |
2349 | 2463 | | |
| |||
2364 | 2478 | | |
2365 | 2479 | | |
2366 | 2480 | | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
2367 | 2515 | | |
2368 | 2516 | | |
2369 | 2517 | | |
| |||
0 commit comments