From 7e03e77f41710752d3b51bc3000c136f72b82281 Mon Sep 17 00:00:00 2001 From: MickaelSchimpf <122897940+MickaelSchimpf@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:36:31 +0100 Subject: [PATCH 1/2] docs(validation): add missing hook (#1795) docs: add missing hook in validation.md for "Dynamic validation groups" From 85d68975e2f1dc4567f23c3e376248090a5e2ffd Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Wed, 15 Jan 2025 08:26:18 +0100 Subject: [PATCH 2/2] docs(content-negociation): document how to declare an encoder for custom format (#1797) --- core/content-negotiation.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/content-negotiation.md b/core/content-negotiation.md index e52c44b86ca..bbc11eb7549 100644 --- a/core/content-negotiation.md +++ b/core/content-negotiation.md @@ -196,6 +196,19 @@ api_platform: myformat: ['application/vnd.myformat'] ``` +You will also need to declare an encoder which supports the new format: + +```yaml +services: + app.api-platform.myformat.encoder: + class: ApiPlatform\Serializer\JsonEncoder + arguments: + $format: 'myformat' + # The following lines are only needed if autoconfigure is disabled + # tags: + # - { name: 'serializer.encoder' } +``` + API Platform will automatically call the serializer with your defined format name as `format` parameter during the deserialization process (`myformat` in the example). 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).