Skip to content
Open
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2408e64
graphql.md: add "MediaObject Normalization" chapter (#2109)
timble-one Sep 15, 2025
fd44e8f
Merge 4.1
soyuka Sep 16, 2025
7990e10
docs: fix small typo (#2205)
florentdrousset Sep 16, 2025
d423095
Update openapi.md (#2042)
rnbw-spctrm Sep 17, 2025
8410d87
Merge 4.1 (#2206)
vinceAmstoutz Sep 17, 2025
0f90473
4.2 branch
soyuka Sep 17, 2025
d840a9c
Update from 'attributes' to 'properties' (#2195)
kentrichards Sep 19, 2025
17d371c
docs(openapi): refacto override OpenAPI section (#2207)
maxhelias Sep 22, 2025
df2f502
docs(core/operations): update explanation about omitting GET item ope…
ttskch Oct 8, 2025
ed00f67
docs(core/extensions): add eloquent support (#2208)
ttskch Oct 8, 2025
263c804
Remove invalid tip about #[GetCollection] alias (#2215)
rvanlaak Oct 8, 2025
e39b731
docs: metadata mutators (#2228)
NathanPesneau Nov 25, 2025
6f09119
docs: add missing "docs_formats" configuration for Symfony (#2226)
creocoder Nov 25, 2025
e98c7fb
Fix invalid YAML in example in core/state-processors.md and state-pro…
xalopp Nov 25, 2025
e34dfd7
docs: update UUID recommendation to v7 for better database performanc…
OlivierBarbier Nov 25, 2025
97b274e
document property filter back (#2220)
soyuka Nov 25, 2025
a0e1317
Update releases information (#2232)
xammmue Dec 4, 2025
323e977
improve dto documentation (#2231)
soyuka Dec 4, 2025
6a249e8
Merge 4.1
soyuka Dec 4, 2025
ff2ccb4
update docs
soyuka Dec 4, 2025
ba8d387
fix #1749
soyuka Dec 5, 2025
9e67aec
document enums as resource
soyuka Dec 5, 2025
67485f7
fix #1856
soyuka Dec 5, 2025
d7c1d74
bootstrap
soyuka Dec 5, 2025
8aaa843
fix #2230
soyuka Dec 5, 2025
5dd857b
fix #2221
soyuka Dec 5, 2025
812d718
fix #2189
soyuka Dec 5, 2025
54ef2ac
doc(provider): show how to enable link security to be able to use Rea…
Cryde Dec 5, 2025
3011261
docs(filters): document enhanced QueryParameter syntax on old filters…
vinceAmstoutz Dec 5, 2025
2e12e24
default fixup
soyuka Dec 5, 2025
9bb4738
lint
soyuka Dec 5, 2025
c671247
restore max depth + prettier
soyuka Dec 5, 2025
a6375a4
max-length 100 prettier
soyuka Dec 5, 2025
d0a2717
max-length prettier
soyuka Dec 5, 2025
c619f82
max-length markdown
soyuka Dec 5, 2025
17aac72
lint
soyuka Dec 5, 2025
68dfcfe
Document Deprecation HTTP Header usage (#2233)
aaa2000 Dec 8, 2025
ffef094
doc(mutator): fix typo (#2234)
Jean-Beru Dec 19, 2025
4775684
fix(core/bootstrap): note formatting (#2235)
vinceAmstoutz Dec 19, 2025
e61eec1
fix api-platform/core/pull/5606
soyuka Jan 26, 2026
bb66780
fix: typo “through” (#2243)
alexisLefebvre Jan 27, 2026
f1c33c3
docs: mention symfony/object-mapper:^8.0 (#2238)
alexisLefebvre Jan 27, 2026
d724e5a
docs: clarify pagination_client_enabled configuration (#2237)
mdavid-dev Jan 27, 2026
fa2534e
docs: rewrite intro to DTO (#2244)
alexisLefebvre Jan 27, 2026
2d2a5dd
cs (#2246)
soyuka Jan 27, 2026
04bdd63
doc: refactor BlogPostProvider examples (#2239)
alexisLefebvre Jan 27, 2026
6efe91c
docs: fix links to Hoppscotch and remove duplicated line (#2245)
alexisLefebvre Jan 27, 2026
eb4a006
cs
soyuka Jan 27, 2026
0e3611e
feat: update php version on workflow
ginifizz Jan 29, 2026
badbbc1
docs: update vich example to use the Attribute namespace instead (#2250)
cngJo Feb 9, 2026
7cd27ed
feat: add global defaults.normalization_context.gen_id configuration …
Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
document property filter back (#2220)
  • Loading branch information
soyuka authored Nov 25, 2025
commit 97b274e2f437fecc7c0ff1d98d4e3650cc064a4c
54 changes: 51 additions & 3 deletions core/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q
}
```

Note that we're using `api_platform.doctrine.orm.search_filter.instance` (exists also for ODM). Indeed this is a special instance of the search filter where `properties` can be changed during runtime. This is considered as "legacy filter" below, in API Platform 4.0 we'll recommend to create a custom filter or to use the `PartialSearchFilter`.
> [!NOTE]
> We are using `api_platform.doctrine.orm.search_filter.instance` (exists also for ODM).
> Indeed this is a special instance of the search filter where `properties` can be changed during runtime.
> This is considered as "legacy filter" below, in API Platform 4.0 we'll recommend to create a custom filter or to use the `PartialSearchFilter`.

### Restricting Properties with `:property` Placeholders

Expand Down Expand Up @@ -244,7 +247,8 @@ class Book {

This approach is recommended for new filters as it's more flexible and allows true property restriction via the parameter configuration.

Note that invalid values are usually ignored by our filters, use [validation](#parameter-validation) to trigger errors for wrong parameter values.
> [!NOTE]
> Invalid values are usually ignored by our filters, use [validation](#parameter-validation) to trigger errors for wrong parameter values.

## OpenAPI and JSON Schema

Expand Down Expand Up @@ -338,7 +342,8 @@ use Symfony\Component\Validator\Constraints as Assert;
class User {}
```

Note that when `castToNativeType` is enabled, API Platform infers type validation from the JSON Schema.
> [!NOTE]
> When `castToNativeType` is enabled, API Platform infers type validation from the JSON Schema.

The `ApiPlatform\Validator\Util\ParameterValidationConstraints` trait can be used to automatically infer validation constraints from the JSON Schema and OpenAPI definitions of a parameter.

Expand Down Expand Up @@ -396,6 +401,49 @@ class StrictParameters {}

With this configuration, a request to `/strict_query_parameters?bar=test` will fail with a 400 error because `bar` is not a supported parameter.

### Property filter

> [!NOTE]
> We strongly recommend using [Vulcain](https://vulcain.rocks) instead of this filter.
> Vulcain is faster, allows a better hit rate, and is supported out of the box in the API Platform distribution.
> [!NOTE]
> When unsing JSON:API check out the [specific SparseFieldset and Sort filters](./content-negotiation/#jsonapi-sparse-fieldset-and-sort-parameters)

The property filter adds the possibility to select the properties to serialize (sparse fieldsets).

Syntax: `?properties[]=<property>&properties[<relation>][]=<property>`

You can add as many properties as you need.

Enable the filter:

```php
<?php
// api/src/Entity/Book.php
namespace App\Entity;

use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Serializer\Filter\PropertyFilter;

#[ApiResource(
parameters: ['properties' => new QueryParameter(filter: PropertyFilter::class)]
)]
class Book
{
// ...
}
```

Three arguments are available to configure the filter:

- `parameterName` is the query parameter name (default `properties`)
- `overrideDefaultProperties` allows to override the default serialization properties (default `false`)
- `whitelist` properties whitelist to avoid uncontrolled data exposure (default `null` to allow all properties)

Given that the collection endpoint is `/books`, you can filter the serialization properties with the following query: `/books?properties[]=title&properties[]=author`.
If you want to include some properties of the nested "author" document, use: `/books?properties[]=title&properties[author][]=name`.

## Parameter Providers

Parameter Providers are powerful services that can inspect, transform, or provide values for parameters. They can even modify the current `Operation` metadata on the fly. A provider is a class that implements `ApiPlatform\State\ParameterProviderInterface`.
Expand Down
Loading