Skip to content

fix: resolve Schema ref from parameter type in AugmentRequestBody#2018

Merged
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/augment-request-body-schema-ref
Jun 12, 2026
Merged

fix: resolve Schema ref from parameter type in AugmentRequestBody#2018
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/augment-request-body-schema-ref

Conversation

@DerManoMann

@DerManoMann DerManoMann commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

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

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. Add a fallback that resolves the parameter type to a Schema ref
when ref remains UNDEFINED after the existing logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DerManoMann DerManoMann force-pushed the fix/augment-request-body-schema-ref branch from d78d9cf to 38494a3 Compare June 12, 2026 05:04
@DerManoMann DerManoMann merged commit 57378fe into zircote:master Jun 12, 2026
17 checks passed
@DerManoMann DerManoMann deleted the fix/augment-request-body-schema-ref branch June 12, 2026 05:06
@github-actions

Copy link
Copy Markdown
Contributor

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