docs(dto): clarify object mapper output on write operations - #2321
Open
soyuka wants to merge 1 commit into
Open
Conversation
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.
|
Before merging this, please take a look at: api-platform/core#8497 |
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.
Summary
core/dto.mdimplied that anoutputclass configured on a write operation is used as theObject Mapper target after persistence. It is not:
ObjectMapperOutputProcessoralways maps thepersisted entity back to the resource class. This is intentional, a resource instance is required
downstream for IRI generation and the
Location/Content-Locationheaders, and the same changewas declined in api-platform/core#7611, api-platform/core#7940 and api-platform/core#8420.
This PR:
ObjectMapperInputProcessor,ObjectMapperOutputProcessor) in"How it works internally" and states that write mapping always targets the resource class.
outputwith the Object Mapper applies toGetandGetCollection.#[ApiResource]class sharing the entity through
stateOptions,input:for the request body, anditemUriTemplateonPostto 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.mdnpx markdownlint-cli2 core/dto.mdnpx prettier --check core/dto.md --prose-wrap always