Skip to content

fix(generator): preserve owner assertions when deduplicating allOf unions - #107

Merged
lightsofapollo merged 6 commits into
mainfrom
fix/allof-restated-union-owner-fields
Oct 17, 2026
Merged

lightsofapollo merged 6 commits into
mainfrom
fix/allof-restated-union-owner-fields

Conversation

@lightsofapollo

@lightsofapollo lightsofapollo commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cloudflare's Workers Observability schemas repeat the same union in allOf, once by reference and once inline with descriptions. Resolve those restatements instead of rejecting the whole spec, while preserving fields and required names declared beside allOf.

This continues Giles Westwood's (@gilesw) work in #104. His three original commits are retained unchanged, including the fixes for assertion data and mixed object/scalar unions. The follow-up commits keep owners with assertion siblings on the normal merge path instead of taking an alias or single-member shortcut that drops their object shape or fields.

Generated compatibility

  • Repeated equivalent unions now generate successfully. Root fields keep their declared types and required status when the repeated members collapse.
  • Unions with different assertions still report the multiple-union diagnostic; dependentRequired data and nonredundant object-type constraints are preserved.
  • No generated dependencies, feature defaults, or configuration changes.
  • The pinned corpus generates identical output to main; tests/corpus-manifest.txt is unchanged (56 specs, 224 files).

Validation

  • Confirmed the new owner-field regression fails before the follow-up fix and passes afterward.
  • Added 28 analyzer cases covering anyOf/oneOf, reference/inline member ordering, optional declared fields, required-only fields, and object/scalar unions constrained by the owner.
  • Extended the compiled fixture to round-trip recursive filters and owner fields, reject missing required fields, and reject scalars excluded by owner type: object or not assertions.
  • Focused object-union and scalar-carrier tests, cargo fmt --check, cargo clippy --all-features -- -D warnings, doctests, and rustdoc with warnings denied pass.
  • cargo nextest run --profile ci --all-features passed in CI at the final commit: 743 passed, 7 skipped. Doctests and conformance-report verification also pass.
  • Full corpus diff and manifest checks pass at the final commit. The focused object-union tests include independent JSON Schema witnesses for excluded scalar values.
  • scripts/spec-compile.sh anthropic openai: both generated crates compile and pass schema round trips (1,333 component schemas, 4,984 samples; 64 schema skips).

Notes for reviewers

The follow-up change is in analyze_allof_composition; compositions reduced by union deduplication bypass the collapse shortcuts unless the owner has only annotations beside allOf. Existing scalar/array recovery is unchanged.

Use a merge commit when landing to retain Giles's original commit identities and attribution.

gilesw and others added 5 commits October 12, 2026 18:17
An allOf whose members are the same union, once annotations are
ignored, failed with "intersects multiple union members". The current
Cloudflare spec types its Workers Observability query filters as
allOf: [$ref filter_node, anyOf: [group, leaf]], where the inline anyOf
repeats filter_node's branches with added descriptions. That error
stopped the whole spec from generating.

Repeated union members are now dropped before composition, comparing
assertions only: annotation keywords are stripped recursively, member
names under properties are kept, and `type: object` on the named union
is ignored. A restatement next to a single $ref becomes an alias of
that schema. Unions that differ still report the diagnostic.

The pinned corpus has no such schema, so its output is unchanged.
Keep deduplicated allOf compositions with owner properties or required names on the merge path instead of returning a bare alias. Add an anyOf/oneOf member-order matrix and generated recursive-filter round trips with missing-required rejection.

Continues Giles Westwood’s work in PR #104; his original commits remain in the branch history.
@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openapi-to-rust Ready Ready Preview Oct 17, 2026 3:03am UTC

Request Review

@lightsofapollo
lightsofapollo marked this pull request as ready for review October 17, 2026 02:54
@lightsofapollo
lightsofapollo marked this pull request as draft October 17, 2026 02:59
Only collapse a deduplicated allOf owner when it has no sibling assertions. Preserve object-type and not constraints around mixed object/scalar unions, with JSON Schema witnesses and compiled scalar-rejection coverage. Keep annotation-only owners eligible for aliases.
@lightsofapollo lightsofapollo changed the title fix(generator): preserve owner fields when deduplicating allOf unions fix(generator): preserve owner assertions when deduplicating allOf unions Oct 17, 2026
@lightsofapollo
lightsofapollo marked this pull request as ready for review October 17, 2026 03:21
@lightsofapollo
lightsofapollo merged commit 2a226e4 into main Oct 17, 2026
@lightsofapollo
lightsofapollo deleted the fix/allof-restated-union-owner-fields branch October 17, 2026 03:24

This branch was successfully deployed

1 active deployment
Preview — e9344117 Deployed Oct 17, 2026 by vercel[bot]
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