Skip to content

fix(openapi): document request body on operations that deserialize - #8598

Merged
soyuka merged 1 commit into
api-platform:4.4from
soyuka:fix/issue-8418
Sep 28, 2026
Merged

soyuka merged 1 commit into
api-platform:4.4from
soyuka:fix/issue-8418

Conversation

@soyuka

@soyuka soyuka commented Sep 28, 2026

Copy link
Copy Markdown
Member
Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fixes #8418
License MIT

A custom Delete that declares an input DTO and deserialize: true got no requestBody in the OpenAPI document, so its payload was undocumented.

Two gates hardcoded the same method list. OpenApiFactory::collectPaths() only built a request body for PATCH, PUT and POST, and SchemaFactory::buildSchema() returned early for any method outside POST, PATCH, PUT, QUERY. Fixing only the first produced a requestBody carrying an empty schema, so both are needed.

Neither specification forbids this. RFC 9110 section 9.3.5 says a client "SHOULD NOT generate content in a DELETE request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported" — documenting it is that indication. OpenAPI 3.1 and 3.2 both state that requestBody on DELETE "is permitted".

The opt-in signal is $operation->canDeserialize(). It is ?bool defaulting to null (src/Metadata/Operation.php:791) and is resolved to a boolean only at runtime in MainController, so true === $operation->canDeserialize() holds only when the user wrote deserialize: true themselves. Nothing changes for any existing operation.

The test asserts both directions: a Delete with input and deserialize: true gets a request body whose schema $refs the DTO, and a plain Delete still gets null and still builds no input schema.

@soyuka
soyuka merged commit 852cc80 into api-platform:4.4 Sep 28, 2026
113 of 117 checks passed
@soyuka
soyuka deleted the fix/issue-8418 branch September 28, 2026 13:28
soyuka added a commit that referenced this pull request Sep 29, 2026
This reverts commit 852cc80 (#8598).

Operations with deserialize: true on GET/DELETE now get a requestBody
and an input schema, which changes generated OpenAPI documents. Not
acceptable in a 4.4 patch release; the change moves to 5.0.
soyuka added a commit that referenced this pull request Sep 29, 2026
soyuka added a commit that referenced this pull request Sep 29, 2026
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