Skip to content

Commit 06a647a

Browse files
authored
feat(laravel): add CSV support (#6617)
* feat(laravel): add CSV support * text/csv
1 parent de6e3f5 commit 06a647a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Laravel/ApiPlatformProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
199199
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
200200
use Symfony\Component\Routing\RequestContext;
201+
use Symfony\Component\Serializer\Encoder\CsvEncoder;
201202
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
202203
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
203204
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
@@ -956,7 +957,15 @@ public function register(): void
956957
// $list->insert($jsonserializableNormalizer, -900);
957958
// $list->insert($uuidDenormalizer, -895); //Todo ramsey uuid support ?
958959
959-
return new Serializer(iterator_to_array($list), [new JsonEncoder('json'), $app->make(JsonEncoder::class), new JsonEncoder('jsonopenapi'), new JsonEncoder('jsonapi')]);
960+
return new Serializer(
961+
iterator_to_array($list),
962+
[
963+
new JsonEncoder('json'),
964+
$app->make(JsonEncoder::class),
965+
new JsonEncoder('jsonopenapi'),
966+
new JsonEncoder('jsonapi'),
967+
new CsvEncoder(),
968+
]);
960969
});
961970

962971
$this->app->singleton(JsonLdItemNormalizer::class, function (Application $app) {

src/Laravel/config/api-platform.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'formats' => [
2424
'jsonld' => ['application/ld+json'],
2525
//'jsonapi' => ['application/vnd.api+json'],
26+
//'csv' => ['text/csv'],
2627
],
2728

2829
'patch_formats' => [

0 commit comments

Comments
 (0)