Skip to content

Comments

Fix document filtering to handle references with description or summary fields#858

Merged
czechboy0 merged 3 commits intoapple:mainfrom
egrank:main
Jan 13, 2026
Merged

Fix document filtering to handle references with description or summary fields#858
czechboy0 merged 3 commits intoapple:mainfrom
egrank:main

Conversation

@egrank
Copy link
Contributor

@egrank egrank commented Jan 12, 2026

Motivation

If OpenAPI document filtering is enabled for operations containing references with description or summary fields, Swift OpenAPI Generator fails with an error as such references cannot be resolved.

For example, this reference can be resolved:

  schema:
    $ref: '#/components/schemas/Item'

but not this one:


  schema:
    $ref: '#/components/schemas/Item'
    description: "Item with description"

The cause of the described issue is in the FilteredDocumentBuilder code. The required components are registered there, including optional description and summary properties, while the reference matching for filtering is done against references created only with component keys, so equality check fails if description or summary are present.

Modifications

Registering and matching only component keys instead of whole references.

Result

After this change, there are no more limitations on having description and summary fields for references in filtered operations.

Test Plan

Extended unit tests with test cases to cover the described issues:

  • Added /things/c path that exercises references with descriptions across:
    • Path-level and operation-level parameters with description fields
    • Response references with descriptions
    • Headers with schema references containing descriptions
    • Examples with descriptions
  • Updated the test assertion helper to verify headers and examples are correctly filtered

The added tests fail without the fix.

Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

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

This is great, thank you @egrank! 🙏

@czechboy0 czechboy0 enabled auto-merge (squash) January 13, 2026 09:14
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Jan 13, 2026
auto-merge was automatically disabled January 13, 2026 13:53

Head branch was pushed to by a user without write access

@egrank egrank requested a review from czechboy0 January 13, 2026 13:58
@czechboy0 czechboy0 merged commit ecf21fd into apple:main Jan 13, 2026
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants