Fix 204 responses still including a content schema - #1087
Open
TZK- wants to merge 2 commits into
Open
Conversation
$response->status is a strictly-typed int (Knuckles\Camel\Extraction\Response::$status),
but generateEndpointResponsesSpec() compared it against the string '204' with ===. Since
204 === '204' is always false in PHP, the "must not add content for 204" guard never
triggered, so responses tagged 204 (e.g. via #[Response(status: 204)] or
#[ResponseFromApiResource(..., 204)]) still got a full content schema in the generated
OpenAPI spec.
Compare against the int 204 instead, and add a dedicated regression test asserting the
generated 204 response is exactly `{"description": ""}`, with no `content` key at all.
TZK-
force-pushed
the
fix/204-response-content-type-comparison
branch
from
August 20, 2026 14:59
21452a0 to
46dcada
Compare
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.
Problem
Responses documented with status
204still get a fullcontentschema in the generated OpenAPI spec, instead of the expected empty response.Generated
openapi.yaml(current, incorrect):Expected (per the OpenAPI spec, a
204response has no body):Root cause
In
BaseGenerator::generateEndpointResponsesSpec():Knuckles\Camel\Extraction\Response::$statusis declared as a strictly-typedint(and is cast with(int)in its constructor), so$codeis always anint. Comparing it with===against the string'204'is therefore alwaysfalse.Note
This branch also includes an unrelated one-line commit removing an unused import in src/Extracting/ParamHelpers.php. It was failing my branch's CI. Happy to drop it from this PR if you'd rather handle it separately.