Skip to content

fix: re-add implicitly-filtered schemas in collectOperations#3791

Merged
mrlubos merged 2 commits intohey-api:mainfrom
sbs44:fix/deprecated-filter-collectOperations
Apr 19, 2026
Merged

fix: re-add implicitly-filtered schemas in collectOperations#3791
mrlubos merged 2 commits intohey-api:mainfrom
sbs44:fix/deprecated-filter-collectOperations

Conversation

@sbs44
Copy link
Copy Markdown
Contributor

@sbs44 sbs44 commented Apr 19, 2026

Problem

When parser.filters.deprecated: false is set, collectOperations silently drops non-deprecated operations whose transitive dependencies include a deprecated schema (e.g. via oneOf unions in response types).

Fixes #3790

Root Cause

collectOperations treats a missing schema dependency as fatal:

case 'schema':
  return !schemas.has(dependency);

Its siblings (collectParameters, collectRequestBodies, collectResponses) instead re-add implicitly-filtered schemas:

case 'schema':
  if (filters.schemas.exclude.has(dependency)) finalSet.delete(key);
  else if (!schemas.has(dependency)) schemas.add(dependency);
  break;

Fix

Align collectOperations with the sibling pattern:

case 'schema': {
  if (schemas.has(dependency)) return false;
  if (filters.schemas.exclude.has(dependency)) return true;
  schemas.add(dependency);
  return false;
}

Consistency fix, not a behavior change.

Impact

On Apple's App Store Connect OpenAPI spec, 48 non-deprecated operations disappear from the output... including apps_getCollection, apps_getInstance, and appStoreVersions_createInstance. The triggering deprecated schemas sit inside included field oneOf unions (standard JSON:API pattern).

@bolt-new-by-stackblitz
Copy link
Copy Markdown

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

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 19, 2026

@sbs44 is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog bot commented Apr 19, 2026

Reviewed PR #3791 — approved with no issues. The fix correctly aligns collectOperations's schema dependency handling with the sibling collect* functions, and the test covers the exact scenario from the linked issue.

Task list (5/5 completed)
  • Read the PR diff
  • Read the source files for full context
  • Verify fix aligns with sibling functions
  • Review test coverage
  • Submit review

Pullfrog  | View workflow run | via Pullfrog𝕏

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 19, 2026

🦋 Changeset detected

Latest commit: 3316682

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/openapi-ts Patch
@hey-api/shared 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

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug 🔥 Broken or incorrect behavior. labels Apr 19, 2026
@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog bot commented Apr 19, 2026

TL;DR — When deprecated: false is set in parser filters, collectOperations was incorrectly dropping non-deprecated operations that transitively depend on deprecated schemas (e.g. via oneOf unions). This patch aligns collectOperations with the sibling collect* functions so it re-adds implicitly-filtered schema dependencies instead of treating them as fatal missing deps.

Key changes

  • Align collectOperations schema dependency handling with sibling collectors — When a schema dependency is missing from the filtered set, re-add it (unless explicitly excluded) instead of discarding the entire operation.
  • Add test for transitive deprecated schema references — Verifies that a non-deprecated operation referencing a deprecated schema via its dependency set is kept, and the deprecated schema is re-added.
  • Include @hey-api/openapi-ts in changeset — The changeset now covers both @hey-api/shared and @hey-api/openapi-ts as patch releases.

Summary | 3 files | 2 commits | base: mainfix/deprecated-filter-collectOperations


Re-add implicitly-filtered schemas in collectOperations

Before: collectOperations returned !schemas.has(dependency) for schema deps — if a schema was filtered out (e.g. deprecated), the operation was silently dropped even though it was itself non-deprecated.
After: Missing schemas are re-added to the set (matching collectParameters, collectRequestBodies, collectResponses), unless they appear in filters.schemas.exclude.

The existing schema case was a simple negation check. The fix introduces a three-step check: if the schema is already in the set, keep going; if it's explicitly excluded, mark the dependency as unresolvable; otherwise, add it to the schema set and continue. This matches the pattern used by every other collect* function in the same file.

Why does this matter in practice? On specs like Apple's App Store Connect OpenAPI definition, deprecated schemas appear inside oneOf unions on response types (a standard JSON:API pattern). The old behavior caused 48 non-deprecated operations — including apps_getCollection, apps_getInstance, and appStoreVersions_createInstance — to silently vanish from generated output.

.changeset/fix-deprecated-filter-operations.md · packages/shared/src/openApi/shared/utils/__tests__/filter.test.ts · packages/shared/src/openApi/shared/utils/filter.ts

Pullfrog  | View workflow run | via Pullfrog𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog bot left a comment

Choose a reason for hiding this comment

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

Reviewed — no issues found.

The fix correctly aligns collectOperations's schema case with the sibling pattern used in collectParameters, collectRequestBodies, and collectResponses. The adaptation from the for-loop/finalSet.delete pattern to the .some()/return boolean pattern is sound — return true (skip operation) for explicit excludes, schemas.add(dependency); return false (keep operation, re-add schema) for implicitly-filtered schemas.

The other namespace cases (body, parameter, response) in collectOperations don't need the same treatment because their sets are already fully resolved with re-addition logic by the time collectOperations runs. Test covers the exact scenario described in the issue.

Task list (5/5 completed)
  • Read the PR diff
  • Read the source files for full context
  • Verify fix aligns with sibling functions
  • Review test coverage
  • Submit review

Pullfrog  | View workflow run𝕏

Copy link
Copy Markdown
Member

@mrlubos mrlubos left a comment

Choose a reason for hiding this comment

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

Thank you!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 19, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 19, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 39.80%. Comparing base (7aab250) to head (3316682).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/shared/src/openApi/shared/utils/filter.ts 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3791      +/-   ##
==========================================
+ Coverage   39.75%   39.80%   +0.04%     
==========================================
  Files         530      530              
  Lines       19462    19467       +5     
  Branches     5795     5791       -4     
==========================================
+ Hits         7738     7748      +10     
+ Misses       9491     9487       -4     
+ Partials     2233     2232       -1     
Flag Coverage Δ
unittests 39.80% <85.71%> (+0.04%) ⬆️

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
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 19, 2026

Open in StackBlitz

@hey-api/codegen-core

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

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

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

@hey-api/nuxt

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

@hey-api/openapi-ts

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

@hey-api/shared

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

@hey-api/spec-types

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

@hey-api/types

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

@hey-api/vite-plugin

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

commit: 3316682

@mrlubos mrlubos merged commit 3cc893d into hey-api:main Apr 19, 2026
10 of 11 checks passed
@hey-api hey-api bot mentioned this pull request Apr 18, 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. lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deprecated: false silently drops operations that reference deprecated schemas through unions

2 participants