api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 874 forks source link

Deprecation in QueryParameterValidateListener #6686

Open dannyvw opened 1 month ago

dannyvw commented 1 month ago

API Platform version(s) affected: 3.4

Description
User Deprecated: Since api-platform/core 3.3: Use a "ApiPlatform\State\ProviderInterface" as first argument in "ApiPlatform\Symfony\EventListener\QueryParameterValidateListener" instead of "ApiPlatform\ParameterValidator\ParameterValidator".

How to reproduce

Possible Solution

Additional Context

How can we solve this deprecation?

james2001 commented 1 month ago

I wish to know too 😁

mv-developer commented 1 month ago

+1

derskythe commented 1 week ago

@dannyvw @james2001 @dannyvw

This helped me: Upgrade Guide

Special guest:

php bin/console api:upgrade-resource

From the topic The Upgrade Command

soyuka commented 1 week ago

https://github.com/api-platform/core/pull/6655

sengaigibon commented 1 week ago

I managed to "solve it" by decorating the event listener QueryParameterValidateListener ... This is the snippet in my services.yaml file:

services:
    ApiPlatform\Symfony\EventListener\QueryParameterValidateListener:
        decorates: 'api_platform.listener.view.validate_query_parameters'
        arguments:
            $queryParameterValidator: '@App\State\SimpleStateProvider'

App\State\SimpleStateProvider is a dummy class with this content:

class SimpleStateProvider implements ProviderInterface
{

    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
    {
        return [];
    }
}

I mean, it's more like a workaround than a solution.