From d6cdf234c1c77dfb32498d7c650461ddf875c9cb Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Wed, 30 Aug 2023 10:30:10 +0200 Subject: [PATCH] docs(content-negociation): document how to declare an encoder for custom format --- core/content-negotiation.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/content-negotiation.md b/core/content-negotiation.md index 83bc7cd2cb07..6e730472952e 100644 --- a/core/content-negotiation.md +++ b/core/content-negotiation.md @@ -200,6 +200,19 @@ API Platform will automatically call the serializer with your defined format nam It will then return the result to the client with the requested MIME type using its built-in responder. For non-standard formats, [a vendor, vanity or unregistered MIME type should be used](https://en.wikipedia.org/wiki/Media_type#Vendor_tree). +You will also need to declare an encoder which supports the new format: + +```yaml +services: + app.api-platform.myformat.encoder: + class: ApiPlatform\Serializer\JsonEncoder + argumments: + $format: 'myformat' + # The following lines are only needed if autoconfigure is disabled + # tags: + # - { name: 'serializer.encoder' } +``` + ### Reusing the API Platform Infrastructure Using composition is the recommended way to implement a custom normalizer. You can use the following template to start your