feat: support round-tripping v1.0 catalog schemas with custom $defs (#2724)
Author: jacobsimionatoCreated Oct 1, 2026Updated Oct 1, 2026
LabelsP2type: feature/enhancement
Problem Statement
Currently, when a catalog document containing local $defs (such as reusable leaf schemas, shared enums, or catalog component mixins following #2724) is parsed into an in-memory Catalog, local references are inlined into component schemas. Consequently, when serializing the catalog back to JSON (toJson / catalogSchema), the inlined structures remain embedded directly within each component rather than being preserved as modular $defs with $ref: "#/$defs/..." pointers.
Proposed Solution
Support preserving and round-tripping v1.0 schemas that define custom $defs following the rules in #2724.
One potential approach:
- Attach in-memory metadata to schema nodes resolved from local
$defs(e.g. an internal description marker or metadata tag recording the catalog ID and$defname, similar to theREF:approach). - When serializing via
catalog.toJson()/catalog.catalogSchema, inspect this metadata to "uninline" shared definitions back into the document's top-level$defsand re-emit the corresponding$refpointers. - Establish conformance tests verifying that schemas with valid leaf
$defscan round-trip throughCatalog.fromJson/catalog.toJson()with their definitions intact.
Source: a2ui-project/a2ui