Skip to content

Commit 720f200

Browse files
vinceAmstoutzMickaelSchimpfnikophil
authored
Merge 3.4 in 4.0 (#2127)
* docs(validation): add missing hook (#1795) docs: add missing hook in validation.md for "Dynamic validation groups" * docs(content-negociation): document how to declare an encoder for custom format (#1797) --------- Co-authored-by: MickaelSchimpf <[email protected]> Co-authored-by: Nicolas PHILIPPE <[email protected]>
1 parent 7d0224b commit 720f200

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: core/content-negotiation.md

+13
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,19 @@ api_platform:
196196
myformat: ['application/vnd.myformat']
197197
```
198198

199+
You will also need to declare an encoder which supports the new format:
200+
201+
```yaml
202+
services:
203+
app.api-platform.myformat.encoder:
204+
class: ApiPlatform\Serializer\JsonEncoder
205+
arguments:
206+
$format: 'myformat'
207+
# The following lines are only needed if autoconfigure is disabled
208+
# tags:
209+
# - { name: 'serializer.encoder' }
210+
```
211+
199212
API Platform will automatically call the serializer with your defined format name as `format` parameter during the deserialization process (`myformat` in the example).
200213
It will then return the result to the client with the requested MIME type using its built-in responder.
201214
For non-standard formats, [a vendor, vanity or unregistered MIME type should be used](https://en.wikipedia.org/wiki/Media_type#Vendor_tree).

0 commit comments

Comments
 (0)