Skip to content

docs(dto): clarify object mapper output on write operations - #2321

Open
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:docs/object-mapper-output-write-ops
Open

docs(dto): clarify object mapper output on write operations#2321
soyuka wants to merge 1 commit into
api-platform:4.3from
soyuka:docs/object-mapper-output-write-ops

Conversation

@soyuka

@soyuka soyuka commented Sep 2, 2026

Copy link
Copy Markdown
Member

Summary

core/dto.md implied that an output class configured on a write operation is used as the
Object Mapper target after persistence. It is not: ObjectMapperOutputProcessor always maps the
persisted entity back to the resource class. This is intentional, a resource instance is required
downstream for IRI generation and the Location/Content-Location headers, and the same change
was declined in api-platform/core#7611, api-platform/core#7940 and api-platform/core#8420.

This PR:

  • Names the 4.3 classes (ObjectMapperInputProcessor, ObjectMapperOutputProcessor) in
    "How it works internally" and states that write mapping always targets the resource class.
  • Adds a note after the input/output wiring example: output with the Object Mapper applies to
    Get and GetCollection.
  • Adds "Returning a Different Representation From a Write Operation": a second #[ApiResource]
    class sharing the entity through stateOptions, input: for the request body, and
    itemUriTemplate on Post to reuse the main resource's item IRI.

Refs api-platform/core#7940, api-platform/core#8420.

Checks

  • python3 -m proselint check --config .proselintrc.json core/dto.md
  • npx markdownlint-cli2 core/dto.md
  • npx prettier --check core/dto.md --prose-wrap always

The write-side description said the persisted entity is mapped back to
the "Output DTO Resource", implying an `output` class is honored on
POST/PUT/PATCH. ObjectMapperOutputProcessor always maps back to the
resource class; a resource instance is required for IRI generation and
the Location header. Name the 4.3 classes, add a note, and document the
dedicated-resource pattern with `itemUriTemplate` as the alternative.

See api-platform/core#7940, api-platform/core#8420.
@dylan-rumble

Copy link
Copy Markdown

Before merging this, please take a look at: api-platform/core#8497

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.

2 participants