fix: remove consumed annotations from analysis registry#2024
Merged
DerManoMann merged 3 commits intoJun 14, 2026
Merged
Conversation
Add Analysis::removeAnnotation() and use it in all processors that consume/merge annotations. MergeJsonContent and MergeXmlContent now properly remove the original JsonContent/XmlContent from the analysis after transforming them into MediaType + Schema, preventing orphan annotations from appearing in validation. Replaces all direct $analysis->annotations->offsetUnset() calls with the new method for consistency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
38090ad to
6892b72
Compare
…Type After merge, the consumed annotation is reused as MediaType->schema but its _context->nested still pointed at the old parent. Validation walks the tree via collectAnnotations() and would find the annotation in an unexpected location. Update _context to reflect the new parent. Also adds ADR-001 documenting context keys and the annotation lifecycle contract for processors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Created backport PR for
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 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Analysis::removeAnnotation()as a proper API for removing annotations from the analysis registry — removes from bothSplObjectStorageand$context->annotationsarray (full inverse ofaddAnnotation)MergeJsonContentandMergeXmlContentnow fully clean up after consuming annotations:_contextto reflect the new parent (MediaType), so tree-walking validation sees the annotation in the correct location$analysis->annotations->offsetUnset()calls across processors (AugmentRefs,AugmentTags,BuildPaths,MergeIntoOpenApi) with the new method for consistencyBackground
After converting
JsonContentintoMediaType+ schema, the processor removed it from$parent->_unmergedbut:SplObjectStorageand$context->annotations_context->nestedpointing at the old parentWhen validation walks the tree via
collectAnnotations(), it finds theJsonContent(reused asMediaType->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
JsonContent/XmlContentwarnings with dynamically-created annotations (openapi-extras integration)🤖 Generated with Claude Code