Skip to content

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

@sbs44

Description

@sbs44

Description

When parser.filters.deprecated: false is set, non-deprecated operations are silently removed if their response schemas transitively reference a deprecated schema... even when that schema is buried inside a oneOf/anyOf union (e.g., a JSON:API included field).

Root cause: In packages/shared/src/openApi/shared/utils/filter.ts, collectOperations treats a missing schema dependency as fatal:

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

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

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

So when deprecated: false removes a schema via collectSchemas, any operation transitively depending on it gets dropped.

Real-world impact: On Apple's App Store Connect spec (~1,200 operations), 48 non-deprecated operations silently disappear... including apps_getCollection, apps_getInstance, and appStoreVersions_createInstance. The triggering deprecated schemas sit inside included field oneOf unions (standard JSON:API pattern).

I'll open a PR with the 4-line fix aligning collectOperations with its siblings... I'd call it a consistency fix, not a behavior change.

Reproducible example or configuration

export default defineConfig({
  input: "./repro.yaml",
  output: { path: "./out" },
  parser: { filters: { deprecated: false } },
  plugins: ["@hey-api/typescript", "@hey-api/sdk"],
});
  • Expected: listWidgets is generated; LegacyWidget is either dropped from the oneOf or re-included as @deprecated.
  • Actual: listWidgets is silently dropped.

OpenAPI specification (optional)

openapi: "3.1.0"
info:
  title: Minimal Repro
  version: "1.0.0"
paths:
  /widgets:
    get:
      operationId: listWidgets
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/WidgetsResponse"
components:
  schemas:
    Widget:
      type: object
      properties:
        id:
          type: string
    LegacyWidget:
      deprecated: true
      type: object
      properties:
        id:
          type: string
    WidgetsResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/Widget"
        included:
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/Widget"
              - $ref: "#/components/schemas/LegacyWidget"

System information (optional)

  • @hey-api/openapi-ts: 0.96.0
  • @hey-api/shared: 0.4.0
  • Also reproduces on @next (0.0.0-next-20260418091407)
  • Possibly related to Missing operations when filtering #3779 (missing operations under tag filtering)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Broken or incorrect behavior.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions