a2ui-project / a2ui-project/a2ui
Add `catalogFromJsonSchema()` utility to convert JSON Schema catalogs to Zod
- Vorherrschende Sprache
- TypeScript
- Sterne
- 16.4k
- Forks
- 1.3k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 134
Beschreibung
JSON Schema catalog definitions (`basic_catalog.json`) and the Zod component schemas in `basic_components.ts` are currently maintained independently by hand. This has already caused drift — see #1384.
It would be useful to have a utility in `@a2ui/web_core/v0_9` that converts a JSON Schema catalog into a `Catalog` instance with proper Zod schemas, mapping `$ref`s (e.g. `common_types.json#/$defs/DynamicString`) to the real common-type Zod schemas so `GenericBinder` classifies props correctly.
This would:
- Let catalog authors work in JSON Schema (the canonical A2UI format) while renderers get Zod automatically
- Enable catalog parity tests extending the `verify-schema.test.ts` pattern to catch drift like #1384
- Benefit all downstream renderers (React, Angular, Lit) facing the same duplication
Given that Zod v3 will remain in use for some time (see #1263 re: CSP constraints blocking v4 adoption), this would work with the current Zod v3 codebase and wouldn't depend on the v4 migration timeline.
Happy to contribute a PR.
Beitragsleitfaden
Rechercherichtung
Look at the existing JSON Schema catalog file (`basic_catalog.json`) and the corresponding Zod component schemas in `basic_components.ts`. Study the `verify-schema.test.ts` pattern to understand how schema parity is currently checked. The utility should be added to `@a2ui/web_core/v0_9`, mapping `$ref`s to the real common-type Zod schemas. Start by examining how `GenericBinder` classifies props to understand the required output format. 'Done' means the utility successfully converts a JSON Schema catalog to a `Catalog` instance with proper Zod schemas, enabling automated parity tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- json, typescript
- Bereich
- backend-api-design, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100