Skip to content

fix(state): map to the resource on mapped write operations - #8848

Open
soyuka wants to merge 1 commit into
api-platform:5.0from
soyuka:fix/object-mapper-provider-write-target
Open

soyuka wants to merge 1 commit into
api-platform:5.0from
soyuka:fix/object-mapper-provider-write-target

Conversation

@soyuka

@soyuka soyuka commented Nov 13, 2026

Copy link
Copy Markdown
Member
Q A
Branch? 5.0
Tickets Refs #8497
License MIT

On a resource mapped to an entity (stateOptions + #[Map]), a resource-level output was used as the mapping target by ObjectMapperProvider on every method. PATCH, PUT and DELETE then received the output class as their state instead of the resource:

  • DELETE answered successfully and did not remove the entity, the output class is not the class the input mapper expects and Doctrine has no manager for it
  • PATCH discarded the object to populate, a new resource was built from the body and unsent fields were overwritten (Expected argument of type "string", "null" given at property path "description" when the property is nullable or has a default)

The provider now maps to the resource class on unsafe methods. Safe methods (GET, HEAD, OPTIONS, QUERY) and non-HTTP operations keep mapping to the output class.

This is the provider change from #8497, on its own. The response body of a mapped write with an output is not addressed here.

With a resource-level output, ObjectMapperProvider handed the output
class to PATCH, PUT and DELETE: DELETE did not remove the entity and
PATCH overwrote unsent fields.
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