Skip to content

[Backport #2018 to 5.x] fix: resolve Schema ref from parameter type in AugmentRequestBody#2022

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

[Backport #2018 to 5.x] fix: resolve Schema ref from parameter type in AugmentRequestBody#2022
github-actions[bot] wants to merge 1 commit into
5.xfrom
backport-2018-to-5.x

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #2018 to branch 5.x.

Do not modify this pull request.

Summary

  • When #[OA\RequestBody] is on a method parameter whose type has a #[OA\Schema] annotation, the existing augmentSchemaType + type2ref lookup fails because it searches for a RequestBody annotation on the class
  • Adds a fallback that resolves the parameter type to a Schema $ref when ref remains UNDEFINED after the existing logic

Details

Problem: augmentSchemaType calls type2ref($schema, $analysis, $sourceClass) where $sourceClass = OA\RequestBody::class. Inside type2ref, getAnnotationForSource looks for a RequestBody annotation on the class — but the class has a Schema annotation, so it returns null and the ref stays unresolved.

Fix: After the existing augmentSchemaType call, if ref is still UNDEFINED, use reflection to get the parameter type and look up a Schema annotation directly via $analysis->getAnnotationForSource($className, OA\Schema::class).

Backwards compatibility:

  • The existing augmentSchemaType + RequestBody lookup still runs first (unchanged)
  • The new code only activates when ref is still UNDEFINED after the existing logic
  • No existing behaviour is changed for classes annotated with #[OA\RequestBody]

Test plan

  • Updated Scratch/RequestBody fixture with new postSchemaParam endpoint
  • All 1037 tests pass
  • PHP CS Fixer clean
  • Rector clean

🤖 Generated with Claude Code

@DerManoMann DerManoMann deleted the backport-2018-to-5.x branch June 12, 2026 11:07
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