From dfe938b74ff51f1400e889da0cd10c29537f5d69 Mon Sep 17 00:00:00 2001 From: Anto Date: Sun, 4 Nov 2018 12:33:23 +0100 Subject: [PATCH 1/2] Fixes api-platform/api-platform#884 --- core/content-negotiation.md | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/core/content-negotiation.md b/core/content-negotiation.md index 27ed9cd17b5..6e216ac3b4b 100644 --- a/core/content-negotiation.md +++ b/core/content-negotiation.md @@ -89,6 +89,66 @@ Additionally the `csv` format is added with the mime type `text/csv`. It is also important to notice that the usage of this attribute will override the formats defined in the configuration, therefore this configuration might disable the `json` or the `htlm` on this resource for example. +You can specify different accepted formats at operation level too: +```php + + + + + + + text/xml + + + + + + + + jsonld + text/csv + + + +``` +YAML: +```yaml +resources: + App\Entity\Book: + collectionOperations: + get: + formats: + xml: ['text/xml'] # works also with "text/html" + attributes: + formats: + 0: 'jsonld' # format already defined in the config + csv: 'text/csv' +``` + ## Registering a Custom Serializer If you are adding support for a format not supported by default by API Platform nor by the Symfony Serializer Component, From b45b54752ff2f3f1d8a540aa658ab993b087c86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 5 Nov 2018 08:53:40 +0100 Subject: [PATCH 2/2] Fix typo --- core/content-negotiation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/content-negotiation.md b/core/content-negotiation.md index 6e216ac3b4b..73e6b749e2e 100644 --- a/core/content-negotiation.md +++ b/core/content-negotiation.md @@ -87,7 +87,7 @@ In the example above, `xml` or `jsonld` will be allowed and there is no need to Additionally the `csv` format is added with the mime type `text/csv`. It is also important to notice that the usage of this attribute will override the formats defined in the configuration, therefore -this configuration might disable the `json` or the `htlm` on this resource for example. +this configuration might disable the `json` or the `html` on this resource for example. You can specify different accepted formats at operation level too: ```php