core icon indicating copy to clipboard operation
core copied to clipboard

`:property` key cannot be used in `SearchFilter` (Symfony only)

Open ttskch opened this issue 2 months ago • 2 comments

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.

: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 avatar Oct 30 '25 07:10 ttskch

@ttskch Please refer to https://github.com/api-platform/core/issues/7483#issuecomment-3480788370

vinceAmstoutz avatar Nov 03 '25 14:11 vinceAmstoutz

@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.

ttskch avatar Nov 05 '25 02:11 ttskch