Skip to content

fix: preserve top-level required properties on allOf schemas - #89

Closed
aksharprabhudesai wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
aksharprabhudesai:fix/allof-required-properties
Closed

aksharprabhudesai wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
aksharprabhudesai:fix/allof-required-properties

Conversation

@aksharprabhudesai

Copy link
Copy Markdown

Description

In scripts/project-current-ucp-schemas.mjs, schema nodes are traversed and projected for quicktype. Previously, required was only processed when inspecting key === "properties", while all other occurrences were unconditionally skipped with if (key === "required") continue;.

For schema nodes that declare required at the top level while composing their properties inside allOf (such as common/types/daily_hour.json requiring ["day", "opens", "closes"] and common/types/exception_hour.json requiring ["valid_from", "valid_through"]), key === "properties" never matches, so output.required was dropped from the projected schema. As a result, quicktype emitted these fields as optional in the generated Zod models.

This preserves output.required when node.properties is absent or not an object, and regenerates models against the pinned 2026-08-25 spec:

  • DailyHourElementSchema: day, opens, and closes are now required (DailyHourElementSchema also stays a plain z.object because the dependentRequired rule on opens/closes becomes vacuous).
  • ExceptionHourElementSchema: valid_from and valid_through are now required.

Adds projection and Zod validation regression tests in tests/allof-required.test.js, and updates tests/dependent-required.test.js.

@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Oct 17, 2026
@damaz91

damaz91 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@aksharprabhudesai thanks for working on this. We are currently close to land a different approach on generating SDKs entirely (see #87 for reference) and that would make this PR obsolete, so I'll go ahead and close this. Please stay tuned as we are will want to get as much feedback as possible on the new SDKs once they come to life!

@damaz91 damaz91 closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Signal that the PR is ready for human triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants