`:property` key cannot be used in `SearchFilter` (Symfony only)
API Platform version(s) affected: 4.2.2
Description
As the document warns, ApiFilter is currently deprecated and using QueryParameter is recommended.
However, there are several bugs when applying filters using QueryParameter.
- With
QueryParameter, it is not possible to set multiple filters for the same property ExistsFilterandOrderFilteroutput incorrect parameter names to Hydra'ssearchproperty (Symfony only):propertykey cannot be used inSearchFilter(Symfony only)
:property key cannot be used in SearchFilter (Symfony only)
Although SearchFilter is deprecated, it has the following bugs:
#[QueryParameter(key: ':property', filter: 'serviceId.for.search_filter', properties: ['title', 'note'])]
Although this code correctly outputs the parameters in OpenAPI as shown below, filtering does not actually occur when making requests with ?title={query} or ?note={query} appended.
The above code works correctly in Laravel, so it appears to be a bug in the Symfony version.
Incidentally, the following code also works correctly in Symfony.
#[QueryParameter(key: 'title', filter: 'serviceId.for.search_filter')]
#[QueryParameter(key: 'note', filter: 'serviceId.for.search_filter')]
@ttskch Please refer to https://github.com/api-platform/core/issues/7483#issuecomment-3480788370
@vinceAmstoutz
Thank you for your comment.
So, you're saying that I should be using the property argument of QueryParameter instead of the properties argument of Filter, right?
In the code I provided below, I'm using the properties argument of QueryParameter:
#[QueryParameter(key: ':property', filter: 'serviceId.for.search_filter', properties: ['title', 'note'])]
This works correctly in the Laravel version, but it doesn't work in the Symfony version, which is why I reported it as a bug.