Skip to content

[Backport #2024 to 5.x] fix: remove consumed annotations from analysis registry#2025

Closed
github-actions[bot] wants to merge 1 commit into
5.xfrom
backport-2024-to-5.x
Closed

[Backport #2024 to 5.x] fix: remove consumed annotations from analysis registry#2025
github-actions[bot] wants to merge 1 commit into
5.xfrom
backport-2024-to-5.x

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #2024 to branch 5.x.

Do not modify this pull request.

Summary

  • Adds Analysis::removeAnnotation() as a proper API for removing annotations from the analysis registry — removes from both SplObjectStorage and $context->annotations array (full inverse of addAnnotation)
  • MergeJsonContent and MergeXmlContent now fully clean up after consuming annotations:
    • Remove from analysis registry
    • Update _context to reflect the new parent (MediaType), so tree-walking validation sees the annotation in the correct location
  • Replaces all direct $analysis->annotations->offsetUnset() calls across processors (AugmentRefs, AugmentTags, BuildPaths, MergeIntoOpenApi) with the new method for consistency
  • Adds ADR-001 documenting context keys and the annotation lifecycle contract for processors

Background

After converting JsonContent into MediaType + schema, the processor removed it from $parent->_unmerged but:

  1. Left it in the analysis's SplObjectStorage and $context->annotations
  2. Left _context->nested pointing at the old parent

When validation walks the tree via collectAnnotations(), it finds the JsonContent (reused as MediaType->schema) and validates it. With the stale context, this could produce spurious "Unexpected @OA\JsonContent()" warnings — particularly for annotations created dynamically by processors.

Test plan

  • Full test suite passes (1037 tests, 12,937,597 assertions)
  • Verify no orphan JsonContent/XmlContent warnings with dynamically-created annotations (openapi-extras integration)

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown
Contributor Author

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-2024-to-5.x
git worktree add --checkout .worktree/backport-2024-to-5.x backport-2024-to-5.x
cd .worktree/backport-2024-to-5.x
git reset --hard HEAD^
git cherry-pick -x 060af3bb9c4cba6a5859aba2c51cd1c129479410

@DerManoMann DerManoMann deleted the backport-2024-to-5.x branch June 14, 2026 07:16
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.

1 participant