Skip to content

feat(metadata): ResponseHeaderParameter for declaring HTTP response headers#7875

Open
soyuka wants to merge 1 commit into
api-platform:mainfrom
soyuka:parameter/request-response
Open

feat(metadata): ResponseHeaderParameter for declaring HTTP response headers#7875
soyuka wants to merge 1 commit into
api-platform:mainfrom
soyuka:parameter/request-response

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Mar 25, 2026

No description provided.

@soyuka soyuka force-pushed the parameter/request-response branch from c879618 to 2113877 Compare March 25, 2026 06:06
@stale
Copy link
Copy Markdown

stale Bot commented May 24, 2026

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@soyuka
Copy link
Copy Markdown
Member Author

soyuka commented Jun 1, 2026

ResponseProvider ?

Introduce dedicated `ResponseHeader` value object and
`ResponseHeaderProviderInterface` for declaring HTTP response headers on
operations. Drop `ResponseHeaderParameter`, which extended `Parameter`
and forced `instanceof` carve-outs across `ParameterProvider`,
`ParameterParserTrait`, and `OpenApiFactory`.

New `HttpOperation::$responseHeaders` powers both OpenAPI documentation
and runtime header mutation.

Resolution:
- `value: '...'` -> static value
- `provider: Svc::class` -> resolved via tagged locator
- `provider: callable` -> invoked directly
- Return `string|array` -> set, return `null` -> unset
- Applied last in `HttpResponseHeadersTrait` so removals/overrides win
  over defaults, `$operation->getHeaders()`, Sunset, Content-Location,
  and LDP headers.

Symfony: new `api_platform.response_header_provider` tag, autoconfigured
for `ResponseHeaderProviderInterface`, locator injected into
`RespondProcessor` and both `JsonStreamerProcessor` consumers. Laravel
parity in `ApiPlatformProvider` + `ApiPlatformDeferredProvider`.
@soyuka soyuka force-pushed the parameter/request-response branch from 2113877 to faa73b2 Compare June 2, 2026 11:55
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