Skip to content

Defer JsonContent creation to processors; support parameter-level JsonRequestBody - #54

Merged
DerManoMann merged 1 commit into
mainfrom
feature/defer-json-content-to-processors
Jun 12, 2026
Merged

Defer JsonContent creation to processors; support parameter-level JsonRequestBody#54
DerManoMann merged 1 commit into
mainfrom
feature/defer-json-content-to-processors

Conversation

@DerManoMann

@DerManoMann DerManoMann commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Move JsonContent creation from constructors into AugmentJsonResponse and AugmentJsonRequestBody processors — constructors now only record source
  • Add TARGET_PARAMETER to JsonRequestBody attribute, enabling #[OAX\JsonRequestBody] on method parameters with type-hint inference
  • AugmentJsonRequestBody dispatches based on source class annotation: #[OA\Schema] → inline JsonContent, #[OA\RequestBody] → component $ref
  • Extract shared resolveDescription into Processors/Concerns/ResolvesDescription trait
  • No swagger-php changes required — processor does its own reflection

New usage

// Parameter-level — ref inferred from type-hint
public function login(#[OAX\JsonRequestBody] LoginRequest $request)

// Explicit ref to a RequestBody component class
#[OAX\JsonRequestBody(ref: SharedCreateBody::class)]

Pipeline flow

Step 13: AugmentJsonRequestBody (extras) — resolves source, dispatches to JsonContent or component ref
Step 16: AugmentRefs (swagger-php) — resolves FQCN → #/components/schemas/...
Step 18: MergeJsonContent (swagger-php) — converts JsonContent → MediaType + Schema

Test plan

  • Existing tests updated and passing (71 tests, 47832 assertions)
  • New test: processor creates JsonContent when source is set
  • New test: parameter type-hint resolution via ReflectionParameter
  • New test: component $ref dispatch for RequestBody-annotated source classes
  • Linting clean (cs-fixer + rector + phpstan)

🤖 Generated with Claude Code

…nRequestBody

Move JsonContent creation from constructors into AugmentJsonResponse and
AugmentJsonRequestBody processors, enabling parameter-level usage where
the schema ref is inferred from the type-hint at processing time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DerManoMann
DerManoMann force-pushed the feature/defer-json-content-to-processors branch from 6c3dc98 to 52731ae Compare June 12, 2026 22:30
@DerManoMann
DerManoMann merged commit 8c04687 into main Jun 12, 2026
7 checks passed
@DerManoMann
DerManoMann deleted the feature/defer-json-content-to-processors branch June 12, 2026 22:45
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