Skip to content

fix: include orphans when explicitly requested#3714

Merged
mrlubos merged 1 commit into
mainfrom
fix/parser-include-orphans
Apr 6, 2026
Merged

fix: include orphans when explicitly requested#3714
mrlubos merged 1 commit into
mainfrom
fix/parser-include-orphans

Conversation

@mrlubos

@mrlubos mrlubos commented Apr 6, 2026

Copy link
Copy Markdown
Member

No description provided.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pullfrog

pullfrog Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Reviewed and approved. The only change since review was a changeset file addition — no code changes to re-review.

Task list (4/4 completed)
  • Read the diff to identify major areas of change
  • Read source files for full context
  • Analyze logic correctness and edge cases
  • Submit review

Pullfrog  | View workflow run | Triggered by Pullfrog𝕏

@changeset-bot

changeset-bot Bot commented Apr 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e2c4b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hey-api/shared Patch
@hey-api/openapi-ts Patch
@hey-api/openapi-python Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Apr 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
hey-api-docs Ready Ready Preview, Comment Apr 6, 2026 9:16pm

Request Review

@pullfrog

pullfrog Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

TL;DR — When users explicitly include schemas, request bodies, parameters, or responses via filters, the orphan-dropping pass now preserves those resources and their transitive dependencies instead of discarding them as unreferenced.

Key changes

  • Fix dropOrphans to respect explicitly included resources — Resources added via include filters (and their transitive dependencies) are no longer removed by the orphan-dropping pass, which previously only checked whether a resource was reachable from an operation.
  • Add collectExplicitDependencies and collectDependencies helpers — New functions walk the dependency graph from explicitly included filter seeds, collecting all transitive dependencies so dropOrphans can preserve them.
  • Extract getResourceDependencies utility — Deduplicates the namespace-based dependency lookup that was previously inlined in collectOperationDependencies.
  • Add unit tests for createFilteredDependencies — Three tests cover the core scenarios: included schemas with deps, included request bodies with schema deps, and exclude-wins-over-include precedence.
  • Convert arrow functions to function declarations — All module-level const fn = () => {} patterns in filter.ts are converted to function declarations.

Summary | 3 files | 1 commit | base: mainfix/parser-include-orphans


Explicitly included resources survive orphan pruning

Before: The orphan-dropping pass only kept schemas, parameters, request bodies, and responses that were transitively reachable from operations. Explicitly including a schema (e.g. schemas.include: ['Foo']) had no effect if no operation referenced it — it was silently dropped.
After: A new collectExplicitDependencies function gathers all non-excluded include-filter seeds across every resource type, walks their full dependency graph via collectDependencies, and passes the result as includedDependencies into dropOrphans. The orphan check now keeps a resource if it appears in either operationDependencies or includedDependencies.

How does exclude-wins-over-include work here?

collectExplicitDependencies first skips any seed that appears in the corresponding exclude set. After collecting transitive dependencies, it makes a second pass to remove any dependency whose namespace-specific exclude set contains it. This means excludes are respected at both the root and transitive levels.

The getResourceDependencies helper consolidates the namespace-switch logic previously duplicated in collectOperationDependencies, and is now shared by both collectOperationDependencies and collectDependencies.

filter.ts · filter.test.ts

Pullfrog  | View workflow run | Triggered by Pullfrog𝕏

@mrlubos mrlubos force-pushed the fix/parser-include-orphans branch from c6f0109 to 8e2c4b1 Compare April 6, 2026 21:15
@mrlubos mrlubos marked this pull request as ready for review April 6, 2026 21:15
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 6, 2026
@pullfrog

pullfrog Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Reviewed PR #3714. The fix correctly ensures explicitly included components (schemas, parameters, request bodies, responses) and their transitive dependencies survive orphan dropping via the new collectExplicitDependencies / collectDependencies functions. Exclude-wins-over-include semantics are properly respected. Approved with no issues.

Task list (4/4 completed)
  • Read the diff to understand the changes
  • Read source files for full context
  • Trace data flow and verify correctness
  • Self-critique and submit review

Pullfrog  | View workflow run | Triggered by Pullfrog𝕏

@dosubot dosubot Bot added the bug 🔥 Broken or incorrect behavior. label Apr 6, 2026

@pullfrog pullfrog Bot 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.

Reviewed — no issues found.

Pullfrog  | View workflow run𝕏

@codecov

codecov Bot commented Apr 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.21519% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.24%. Comparing base (bb6c491) to head (8e2c4b1).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
packages/shared/src/openApi/shared/utils/filter.ts 77.21% 15 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3714      +/-   ##
==========================================
+ Coverage   39.39%   40.24%   +0.85%     
==========================================
  Files         520      520              
  Lines       19278    19302      +24     
  Branches     5714     5726      +12     
==========================================
+ Hits         7594     7769     +175     
+ Misses       9445     9337     -108     
+ Partials     2239     2196      -43     
Flag Coverage Δ
unittests 40.24% <77.21%> (+0.85%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Apr 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/@hey-api/codegen-core@3714

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/@hey-api/json-schema-ref-parser@3714

@hey-api/nuxt

npm i https://pkg.pr.new/@hey-api/nuxt@3714

@hey-api/openapi-ts

npm i https://pkg.pr.new/@hey-api/openapi-ts@3714

@hey-api/shared

npm i https://pkg.pr.new/@hey-api/shared@3714

@hey-api/spec-types

npm i https://pkg.pr.new/@hey-api/spec-types@3714

@hey-api/types

npm i https://pkg.pr.new/@hey-api/types@3714

@hey-api/vite-plugin

npm i https://pkg.pr.new/@hey-api/vite-plugin@3714

commit: 8e2c4b1

@pullfrog pullfrog Bot 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.

Reviewed — no issues found.

Pullfrog  | View workflow run𝕏

@mrlubos mrlubos merged commit 05207e0 into main Apr 6, 2026
12 checks passed
@mrlubos mrlubos deleted the fix/parser-include-orphans branch April 6, 2026 21:19
This was referenced Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Broken or incorrect behavior. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant