Skip to content

Fix CleanUnusedComponents removing schemas referenced via JsonContent#2047

Open
DerManoMann wants to merge 1 commit into
zircote:masterfrom
DerManoMann:fix/clean-unused-components-nested-refs
Open

Fix CleanUnusedComponents removing schemas referenced via JsonContent#2047
DerManoMann wants to merge 1 commit into
zircote:masterfrom
DerManoMann:fix/clean-unused-components-nested-refs

Conversation

@DerManoMann

@DerManoMann DerManoMann commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix CleanUnusedComponents incorrectly removing schemas that are only referenced via JsonContent(ref: ...) or XmlContent(ref: ...). The performance refactor in Fix/clean unused components performance #2030 stopped traversing nested annotation properties, making those refs invisible since MergeJsonContent removes the JsonContent from $analysis->annotations (but keeps it as MediaType->schema).
  • Guard against "Cannot unset string offsets" crash when the component type has already been set to UNDEFINED.
  • Deduplicate $_nested componentType iteration (Parameter/PathParameter both map to 'parameters').
  • Updated the performance test so that half the used schemas are only referenced via JsonContent, properly exercising the new traversal path.

Fixes #2046

🤖 Generated with Claude Code

… JsonContent/XmlContent

MergeJsonContent removes JsonContent from $analysis->annotations but keeps it
as the schema property of MediaType. The performance refactor in zircote#2030 stopped
traversing nested annotation properties, making those refs invisible to the
unused-components check. This caused schemas only referenced via JsonContent
(or XmlContent) to be incorrectly removed.

Fix by recursively collecting refs from annotation properties (with cycle
protection). Also guard against "Cannot unset string offsets" crash and
deduplicate $_nested componentType iteration.

Fixes zircote#2046

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

[Bug]: Cannot unset string offsets in CleanUnusedComponents

1 participant