fix(docs): correct invalid allOf catalog composition examples (#2219) - #2288
fix(docs): correct invalid allOf catalog composition examples (#2219)#2288sanjayrohith wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the documentation in docs/public/concepts/catalogs.md and tools/build_catalog/README.md to reflect the transition from the Node.js register-catalogs.js script to the Python-based assemble_catalog.py tool. It also updates the JSON schema composition examples to use direct component keys instead of allOf. The reviewer suggested using a relative path instead of an absolute GitHub URL for the tool's documentation link to ensure it remains functional across forks and branches.
| While the final catalog must be freestanding, you may still author your catalogs modularly using JSON Schema `$ref` pointing to external documents during local development. | ||
|
|
||
| To automate bundling and registering these external file references, this catalog registration process is called **"Linking"** and is consolidated under a single, multi-platform Node.js script (**`register-catalogs.js`**). | ||
| To automate bundling and registering these external file references, this catalog registration process is called **"Linking"** and is performed by [`tools/build_catalog/assemble_catalog.py`](https://github.com/a2ui-project/a2ui/blob/main/tools/build_catalog/README.md). It resolves local and remote `$ref`s, merges multiple input catalogs, and emits a single freestanding catalog: |
There was a problem hiding this comment.
To maintain consistency with other links in this document and to ensure the link remains functional across forks or branches, please use a relative path instead of an absolute GitHub URL.
| To automate bundling and registering these external file references, this catalog registration process is called **"Linking"** and is performed by [`tools/build_catalog/assemble_catalog.py`](https://github.com/a2ui-project/a2ui/blob/main/tools/build_catalog/README.md). It resolves local and remote `$ref`s, merges multiple input catalogs, and emits a single freestanding catalog: | |
| To automate bundling and registering these external file references, this catalog registration process is called **"Linking"** and is performed by [`tools/build_catalog/assemble_catalog.py`](../../../tools/build_catalog/README.md). It resolves local and remote `$ref`s, merges multiple input catalogs, and emits a single freestanding catalog: |
|
@jacobsimionato , would you mind to review? |
Fixes #2219
Problem
docs/public/concepts/catalogs.mddocuments catalog composition with anallOfarray placed directly undercomponents:Per
specification/v1_0/json/catalog_definition.json,componentsis an object whoseadditionalPropertiesmust each be aComponentDefinition(a JSON Schema).allOfis therefore read as a component namedallOfwhose schema is an array — which is not a valid schema.This is not just cosmetically wrong. Running the documented input through the repo's own linker,
tools/build_catalog/assemble_catalog.py, produces a broken catalog:Neither
TextnorPopupsurvives. The assembler's_merge_categoriescopiessource["components"]keys verbatim, soallOfbecomes the only "component" in the output andanyComponentpoints at an array.Two secondary issues in the same examples:
The cherry-picking example referenced
catalogs/basic/catalog.json#/components/Text._process_refspecial-cases any ref whose filename iscatalog.jsonand rewrites it to the assembled catalog root, so this collapses to a self-referential{"$ref": "#/components/Text"}instead of importing the Basic Catalog'sText. Verified:The name the assembler actually intercepts is
basic_catalog.json(seeINTERCEPT_MAP).The surrounding "Catalog Linking" section pointed readers at a Node.js script,
register-catalogs.js, wrapped in Xcode Build Phases / Gradle tasks. That script does not exist anywhere in the repository —register-catalogsappears only in this one doc file. The tool that actually performs linking istools/build_catalog/assemble_catalog.py.Changes
docs/public/concepts/catalogs.mdcomponentssyntax.componentsmap, so the example now declares only the new component and pulls in the Basic Catalog at link time via--extend-basic-catalog.$refs keyed under each component's own name, and the ref target isbasic_catalog.json#/components/Text.assemble_catalog.pyinvocation under each example, replacing theregister-catalogs.jsinstruction lines.tools/build_catalog/README.mdallOf-under-componentsexample. Corrected it to the same valid form and added the requiredcatalogId.Verification
Both corrected forms were run through
assemble_catalog.py:The corrected examples also validate against the
componentsshape defined inspecification/v1_0/json/catalog_definition.json, while the previous ones do not.npx prettier --checkpasses on both edited files.Note for reviewers
Item 2 above (
register-catalogs.js→assemble_catalog.py) is adjacent to the filed issue. I included it because those instruction lines are attached directly to the two examples being fixed, and leaving them would have pointed readers at a nonexistent tool for making the corrected examples work. Happy to split it into a separate PR if you'd prefer to keep this one strictly scoped.