-
- Notifications
You must be signed in to change notification settings - Fork 941
Closed as not planned
Closed as not planned
Copy link
Labels
Description
API Platform version(s) affected: 3.x
Description
Considering the following resource:
#[ApiResource( types: ['https://schema.org/Review'], operations: [ new GetCollection(), new Get(), ], routePrefix: '/admin', security: 'is_granted("ROLE_ADMIN")' )] #[ApiResource( uriTemplate: '/books/{bookId}/reviews{._format}', types: ['https://schema.org/Review'], operations: [ new GetCollection(filters: [], itemUriTemplate: '/books/{bookId}/reviews/{id}{._format}'), new NotExposed( uriTemplate: '/books/{bookId}/reviews/{id}{._format}', uriVariables: [ 'bookId' => new Link(toProperty: 'book', fromClass: Book::class), 'id' => new Link(fromClass: Review::class), ], ), ], uriVariables: [ 'bookId' => new Link(toProperty: 'book', fromClass: Book::class), ], )] class Review { #[ApiFilter(NumericFilter::class)] public ?int $rating = null;The filter on rating must be applied only on the first ApiResource (/admin/reviews), not the second one. To do so, I set the filters: [] option to disable all filters. But the FiltersResourceMetadataCollectionFactory erases this configuration.
Possible Solution
Do not set filters on FiltersResourceMetadataCollectionFactory is filters is not null.