Skip to content

fix: label array items by type instead of "any" in schema reference#552

Open
sakinaroufid wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
sakinaroufid:fix/totals-array-item-label
Open

fix: label array items by type instead of "any" in schema reference#552
sakinaroufid wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
sakinaroufid:fix/totals-array-item-label

Conversation

@sakinaroufid

Copy link
Copy Markdown
Contributor

Description

The reference tables show Array[any] in the Type column for some array fields, even though those same fields render with a real type elsewhere on the site.

Why it matters: the Type column is where a reader checks what a field holds. For totals on every extension capability (AP2 Mandate, Buyer Consent, Discount, Fulfillment, Split Payments) it shows Array[any], and for products in catalog lookup it shows Array[any]. Those same fields render correctly as Array[Total] and Array[Product] in the base schemas, and none of the extensions change the field, so a reader gets a worse, blank answer in exactly the places that build on the base.

Cause: the table generator labels an array from items.$ref or a plain items.type. When the item is defined through allOf, or its $ref was inlined while the schema was resolved, neither is present, so it fell back to any. The base tables keep the $ref, which is why they render fine.

Fix: when the simple cases do not apply, recover the item label from the item type, a $ref link, or a title (including titles on allOf branches), and fall back to object rather than any.

Category (Required)

  • Core Protocol: Changes to the base communication layer, global context, or breaking refactors. (Requires Technical Council approval)
  • Governance/Contributing: Updates to GOVERNANCE.md, CONTRIBUTING.md, or CODEOWNERS. (Requires Governance Council approval)
  • Capability: New schemas (Discovery, Cart, etc.) or extensions. (Requires Maintainer approval)
  • Documentation: Updates to README, or documentations regarding schema or capabilities. (Requires Maintainer approval)
  • Infrastructure: CI/CD, Linters, or build scripts. (Requires DevOps Maintainer approval)
  • Maintenance: Version bumps, lockfile updates, or minor bug fixes. (Requires DevOps Maintainer approval)
  • SDK: Language-specific SDK updates and releases. (Requires DevOps Maintainer approval)
  • Samples / Conformance: Maintaining samples and the conformance suite. (Requires Maintainer approval)
  • UCP Schema: Changes to the ucp-schema tool (resolver, linter, validator). (Requires Maintainer approval)
  • Community Health (.github): Updates to templates, workflows, or org-level configs. (Requires DevOps Maintainer approval)

Related Issues

None.

Checklist

  • I have followed the Contributing Guide (including Conventional Commits title requirements and ! for breaking changes).
  • I have updated the documentation (if applicable). Not applicable: this changes how the reference renders, with no separate doc content to edit.
  • My changes pass all local linting and formatting checks.
  • I have added tests that prove my fix is effective or that my feature works. main.py has no test harness in the repo; verified by rebuilding the spec and diffing every rendered Type cell before and after (1900 cells, 11 changed, 0 regressions). Happy to add a harness if maintainers want one.
  • New and existing unit tests pass locally with my changes.
  • (For Core/Capability) I have included/updated the relevant JSON schemas. Not applicable.
  • I have regenerated Python Pydantic models by running generate_models.sh under python_sdk. Not applicable: no schema change.

Screenshots / Logs (if applicable)

Rendered Type cells before and after, from a full rebuild of the spec.

Before:

Field Section Type
totals Checkout with Split Payments Array[any]
totals Checkout with AP2 Mandate Array[any]
products Catalog Lookup (lookup_catalog) Array[any]

After:

Field Section Type
totals Checkout with Split Payments Array[Total]
totals Checkout with AP2 Mandate Array[Total]
products Catalog Lookup (lookup_catalog) Array[Product]

A diff of every rendered Type cell across the whole spec confirms exactly 11 cells changed, all Array[any] to Array[Total] or Array[Product], with no other cell affected.

When an array property's items were defined via allOf, or had their $ref
inlined during schema resolution, the reference table generator could not
read a simple item type and rendered the cell as "Array[any]". This was
live for totals in every extension capability table (AP2, buyer consent,
discount, fulfillment, split payments) and for products in catalog lookup,
even though those fields are unchanged from the base schemas, where they
render correctly as Array[Total] and Array[Product].

Recover the item label from the item type, a $ref link, or a title (also
checking allOf branches), falling back to object. After rebuilding the
spec, all 11 affected cells render Array[Total] or Array[Product], and a
full before/after diff of every rendered type cell shows no other change.
@sakinaroufid sakinaroufid marked this pull request as ready for review June 26, 2026 13:34
@sakinaroufid sakinaroufid requested review from a team as code owners June 26, 2026 13:34

@damaz91 damaz91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sakinaroufid - LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants