Skip to content

Commit cb93b34

Browse files
committed
Merge branch '4.0'
2 parents 9506e8e + 72a22d6 commit cb93b34

File tree

5 files changed

+44
-28
lines changed

5 files changed

+44
-28
lines changed

core/file-upload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ vich_uploader:
4343
media_object:
4444
uri_prefix: /media
4545
upload_destination: '%kernel.project_dir%/public/media'
46-
# Will rename uploaded files using a uniqueid as a prefix.
46+
# Will rename uploaded files using a uniqueid as a suffix.
4747
namer: Vich\UploaderBundle\Naming\SmartUniqueNamer
4848
```
4949

core/filters.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ A parameter can alter the current Operation context, to do so use a `ApiPlatform
4343

4444
```php
4545
class GroupsParameterProvider implements ParameterProviderInterface {
46-
public function provider(Parameter $parameter, array $uriVariables = [], array $context = []): HttpOperation
46+
public function provide(Parameter $parameter, array $uriVariables = [], array $context = []): HttpOperation
4747
{
4848
$request = $context['request'];
4949
return $context['operation']->withNormalizationContext(['groups' => $request->query->all('groups')]);
@@ -1534,6 +1534,7 @@ use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
15341534
use ApiPlatform\Metadata\Operation;
15351535
use Doctrine\ORM\QueryBuilder;
15361536
use Symfony\Component\PropertyInfo\Type;
1537+
use ApiPlatform\OpenApi\Model\Parameter;
15371538
15381539
final class RegexpFilter extends AbstractFilter
15391540
{
@@ -1567,12 +1568,14 @@ final class RegexpFilter extends AbstractFilter
15671568
'type' => Type::BUILTIN_TYPE_STRING,
15681569
'required' => false,
15691570
'description' => 'Filter using a regex. This will appear in the OpenApi documentation!',
1570-
'openapi' => [
1571-
'example' => 'Custom example that will be in the documentation and be the default value of the sandbox',
1572-
'allowReserved' => false,// if true, query parameters will be not percent-encoded
1573-
'allowEmptyValue' => true,
1574-
'explode' => false, // to be true, the type must be Type::BUILTIN_TYPE_ARRAY, ?product=blue,green will be ?product=blue&product=green
1575-
],
1571+
'openapi' => new Parameter(
1572+
name: $property,
1573+
in: 'query',
1574+
allowEmptyValue: true,
1575+
explode: false, // to be true, the type must be Type::BUILTIN_TYPE_ARRAY, ?product=blue,green will be ?product=blue&product=green
1576+
allowReserved: false, // if true, query parameters will be not percent-encoded
1577+
example: 'Custom example that will be in the documentation and be the default value of the sandbox',
1578+
),
15761579
];
15771580
}
15781581

core/getting-started.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
You can choose your preferred stack between Symfony, Laravel, or bootstrapping the API Platform core library manually.
66

77
> [!CAUTION]
8-
>
98
> If you are migrating from an older version of API Platform, make sure you read the [Upgrade Guide](upgrade-guide.md).
109
1110
### Symfony
@@ -263,11 +262,11 @@ Open the generated migration class (`database/migrations/<timestamp>_create_prod
263262
Schema::create('products', function (Blueprint $table) {
264263
$table->id();
265264
266-
+ $table->string('name');
267-
+ $table->decimal('price', 8, 2);
268-
+ $table->text('description');
269-
+ $table->boolean('is_active')->default(true);
270-
+ $table->date('created_date')->nullable();
265+
+ $table->string('name');
266+
+ $table->decimal('price', 8, 2);
267+
+ $table->text('description');
268+
+ $table->boolean('is_active')->default(true);
269+
+ $table->date('created_date')->nullable();
271270
272271
$table->timestamps();
273272
});
@@ -277,7 +276,7 @@ Open the generated migration class (`database/migrations/<timestamp>_create_prod
277276
Finally, execute the migration:
278277

279278
```console
280-
php artisan
279+
php artisan migrate
281280
```
282281

283282
And after that, just adding the `#[ApiResource]` attribute as follows onto your model:

core/operations.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ an implementation point of view, an operation is a link between a resource, a ro
66
<p align="center" class="symfonycasts"><a href="https://symfonycasts.com/screencast/api-platform/operations?cid=apip"><img src="../symfony/images/symfonycasts-player.png" alt="Operations screencast"><br>Watch the Operations screencast</a></p>
77

88
API Platform automatically registers typical [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations
9-
and describes them in the exposed documentation (Hydra and Swagger). It also creates and registers routes corresponding
10-
to these operations in the Symfony routing system (if it is available).
9+
and describes them in the exposed documentation (Hydra and Swagger). It also creates and registers routes
10+
for these operations in the Symfony routing system, if available, or in the Laravel routing system,
11+
should that be the case.
1112

1213
The behavior of built-in operations is briefly presented in the [Getting started](getting-started.md#mapping-the-entities)
1314
guide.
@@ -42,13 +43,20 @@ Method | Mandatory | Description | Registered b
4243
`PATCH` | no | Apply a partial modification to an element | yes
4344
`DELETE` | no | Delete an element | yes
4445

45-
Note: the `PATCH` method must be enabled explicitly in the configuration, refer to the [Content Negotiation](content-negotiation.md) section for more information.
46+
> [!NOTE]
47+
> The `PATCH` method must be enabled explicitly in the configuration, refer to the [Content Negotiation](content-negotiation.md) section for more information.
4648
47-
Note: with JSON Merge Patch, the [null values will be skipped](https://symfony.com/doc/current/components/serializer.html#skipping-null-values) in the response.
49+
---
4850

49-
Note: Current `PUT` implementation behaves more or less like the `PATCH` method.
50-
Existing properties not included in the payload are **not** removed, their current values are preserved.
51-
To remove an existing property, its value must be explicitly set to `null`.
51+
> [!NOTE]
52+
> With JSON Merge Patch, the [null values will be skipped](https://symfony.com/doc/current/components/serializer.html#skipping-null-values) in the response.
53+
54+
---
55+
56+
> [!NOTE]
57+
> Current `PUT` implementation behaves more or less like the `PATCH` method.
58+
> Existing properties not included in the payload are **not** removed, their current values are preserved.
59+
> To remove an existing property, its value must be explicitly set to `null`.
5260
5361
## Enabling and Disabling Operations
5462

@@ -64,7 +72,13 @@ for the `GET` method for both `collection` and `item` to create a readonly endpo
6472
If the operation's name matches a supported HTTP method (`GET`, `POST`, `PUT`, `PATCH` or `DELETE`), the corresponding `method` property
6573
will be automatically added.
6674

67-
Note: The `#[GetCollection]` attribute is an alias for `#[Get(collection: true)]`
75+
> [!TIP]
76+
> The `#[GetCollection]` attribute is an alias for `#[Get(collection: true)]`
77+
78+
---
79+
80+
> [!NOTE]
81+
> In Symfony we use the term “entities”, while the following documentation is mostly for Laravel “models”.
6882
6983
<code-selector>
7084

laravel/filters.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Parameters and Filters
22

3-
API Platform is great for Rapid Application Development and provides lots of functionalities out of the box such as collection filtering with Eloquent. Most of the filtering is done using query parameters, which are automatically documented and validated. If needed you can use [state providers](core/state-providers) or a [Links Handler] to provide data.
3+
API Platform is great for Rapid Application Development and provides lots of functionalities out of the box such as collection filtering with Eloquent. Most of the filtering is done using query parameters, which are automatically documented and validated. If needed you can use [state providers](../core/state-providers.md) or a [Links Handler] to provide data.
44

55
## Parameters
66

@@ -84,13 +84,13 @@ class Book extends Model
8484
}
8585
```
8686

87-
The documentation will output a query parameter per property that applies the `PartialSearchFilter` and also gives the ability to sort by name and id using: `/books?name=search&order[id]=asc&order[name]=desc`.
87+
The documentation will output a query parameter per property that applies the `PartialSearchFilter` and also gives the ability to sort by name and ID using: `/books?name=search&order[id]=asc&order[name]=desc`.
8888

8989
## Filters
9090

9191
### Text
9292

93-
As shown above the following search filters are available:
93+
As shown above the following search filters are available:
9494

9595
- `ApiPlatform\Laravel\Eloquent\Filter\PartialSearchFilter` queries `LIKE %term%`
9696
- `ApiPlatform\Laravel\Eloquent\Filter\EqualsFilter` queries `= term`
@@ -99,7 +99,7 @@ As shown above the following search filters are available:
9999

100100
### Date
101101

102-
The `DateFilter` allows to filter dates with an operator (`eq`, `lt`, `gt`, `lte`, `gte`):
102+
The `DateFilter` allows to filter dates with an operator (`eq`, `lt`, `gt`, `lte`, `gte`):
103103

104104
```php
105105
// app/Models/Book.php
@@ -119,7 +119,7 @@ class Book extends Model
119119
}
120120
```
121121

122-
Our default strategy is to exclude null values, just remove the `filterContext` if you want to exclude nulls.
122+
Our default strategy is to exclude null values, just remove the `filterContext` if you want to exclude nulls.
123123

124124
### Or
125125

0 commit comments

Comments
 (0)