Skip to content

fix(bundler): compose only reachable external fragments - #741

Merged
daveshanley merged 4 commits into
mainfrom
codex/fix-734-fragment-reachability
Nov 29, 2026
Merged

daveshanley merged 4 commits into
mainfrom
codex/fix-734-fragment-reachability

Conversation

@daveshanley

@daveshanley daveshanley commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Fixes #734.

Importing /pets/options also pulled in an integer Id referenced only by /pets in the same file. That component took the name Id and forced the UUID used by /docs/{id} to become Id__schemas.

Behaviour changes

  • Both composed bundling APIs follow ordinary $ref values and discriminator mappings from the selected external fragment. They include schemas reached only by a mapping, including through a root-local pointer or another mapping. Relative targets resolve against the file that declares them.
  • Unused external fragments contribute no components or origin entries. They also contribute no discriminator validation errors. With StrictValidation enabled, OpenAPI 3.0 sibling checks apply to reachable references.
  • Literal example payloads contribute no mapping targets. When a discriminator uses a mapping from an example through a YAML alias or merge, the composer rewrites the schema's copy and preserves the example.
  • Reachable components retain their existing collision order. YAML aliases used in different OpenAPI slots retain the component type of the selected use.

Verification

The regression suite builds fresh models for BundleDocumentComposed and BundleDocumentComposedWithOrigins, then parses the output as a standalone document. It covers the six-file report, multiple fragments in one file, mapping chains, relative targets with the same spelling, collisions, origins, and reusable components with OpenAPI keywords as names. Both byte-based entry points also run the unused-fragment and discriminator case with strict validation.

The full Go suite passed with network fixtures enabled. The bundler has 100% statement coverage. The bundler race tests and go vet ./bundler also passed.

In a local composition benchmark, the six-file case allocated 57.6 KiB per operation, down from 70.3 KiB on main. The existing collision fixture allocated 571.6 KiB, up from 565.4 KiB. Six samples per revision showed no statistically significant runtime difference for either fixture.

@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (b3ad31f) to head (c84257d).

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #741    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          324       325     +1     
  Lines        41641     41784   +143     
==========================================
+ Hits         41641     41784   +143     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@daveshanley
daveshanley marked this pull request as ready for review November 29, 2026 22:46
@daveshanley
daveshanley merged commit 6aaf03b into main Nov 29, 2026
8 checks passed
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.

BundleDocumentComposed composes refs from parts of a file the root doesn't use, and can rename the root's own schema

1 participant