Skip to content

Commit

Permalink
fix(laravel): property filter and _format
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 10, 2024
1 parent 28ae243 commit 8332e88
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Filter/PropertyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

namespace ApiPlatform\Serializer\Filter;

use ApiPlatform\Metadata\HasOpenApiParameterFilterInterface;
use ApiPlatform\Metadata\Parameter as MetadataParameter;
use ApiPlatform\Metadata\QueryParameter;
use ApiPlatform\OpenApi\Model\Parameter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
Expand Down Expand Up @@ -114,7 +117,7 @@
*
* @author Baptiste Meyer <[email protected]>
*/
final class PropertyFilter implements FilterInterface
final class PropertyFilter implements FilterInterface, HasOpenApiParameterFilterInterface
{
private ?array $whitelist;

Expand Down Expand Up @@ -246,4 +249,9 @@ private function denormalizePropertyName($property): string
{
return null !== $this->nameConverter ? $this->nameConverter->denormalize($property) : $property;
}

public function getOpenApiParameter(MetadataParameter $parameter): Parameter
{
return new Parameter(name: $parameter->getKey().'[]', in: $parameter instanceof QueryParameter ? 'query' : 'header');
}
}
2 changes: 1 addition & 1 deletion Parameter/SerializerFilterParameterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function provide(Parameter $parameter, array $parameters = [], array $con
return null;
}

$context = $operation->getNormalizationContext();
$context = $operation->getNormalizationContext() ?? [];
$request->attributes->set('_api_parameter', $parameter);
$filter->apply($request, true, RequestAttributesExtractor::extractAttributes($request), $context);

Expand Down

0 comments on commit 8332e88

Please sign in to comment.