Skip to content

Commit d6cdf23

Browse files
committed
docs(content-negociation): document how to declare an encoder for custom format
1 parent 07dd615 commit d6cdf23

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/content-negotiation.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,19 @@ API Platform will automatically call the serializer with your defined format nam
200200
It will then return the result to the client with the requested MIME type using its built-in responder.
201201
For non-standard formats, [a vendor, vanity or unregistered MIME type should be used](https://en.wikipedia.org/wiki/Media_type#Vendor_tree).
202202

203+
You will also need to declare an encoder which supports the new format:
204+
205+
```yaml
206+
services:
207+
app.api-platform.myformat.encoder:
208+
class: ApiPlatform\Serializer\JsonEncoder
209+
argumments:
210+
$format: 'myformat'
211+
# The following lines are only needed if autoconfigure is disabled
212+
# tags:
213+
# - { name: 'serializer.encoder' }
214+
```
215+
203216
### Reusing the API Platform Infrastructure
204217

205218
Using composition is the recommended way to implement a custom normalizer. You can use the following template to start your

0 commit comments

Comments
 (0)