core icon indicating copy to clipboard operation
core copied to clipboard

Allow specifying the query parameter name when using `ApiFilter`

Open bendavies opened this issue 2 years ago • 1 comments

Description
If is often desirable to filter on api resource properties, but you might not want to use the names of the properties directly to do so.

It would be nice to be able to decouple the name of the property from the query parameter used to query that property.

Example Something like this would be undesirable to the consumer of your API.

#[ApiResource(
    operations: [
        new GetCollection(),
    ],
)]

#[ApiFilter(DateFilter::class, properties: [
    'reallyBadlyNamedDateForLegacyReasons',
])]
class Foo
{
    public \DateTimeInterface $reallyBadlyNamedDateForLegacyReasons;
}

We would not want to expose the name reallyBadlyNamedDateForLegacyReasons directly to the consumer, and instead let them use a more friendly name

possibly a way to specificy on ApiFilters properties, the query parameter that the client can use to filter, something like (i've not thought about the naming):

	#[ApiFilter(DateFilter::class, properties: [
	    'reallyBadlyNamedDateForLegacyReasons' => ['filter_param_name' => 'date']
	])]

bendavies avatar Nov 20 '23 14:11 bendavies

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 20 '24 06:01 stale[bot]