Skip to content

Commit 4669b2b

Browse files
committed
doc: path versioning
1 parent 6d118f4 commit 4669b2b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

core/deprecations.md

+30
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,33 @@ class Parchment
152152
// ...
153153
}
154154
```
155+
156+
## Path versioning
157+
158+
> [!NOTE]
159+
> REST and GraphQL architectures recommend to use deprecations instead of path versioning.
160+
161+
You can prefix your URI Templates and change the representation using serialization groups:
162+
163+
```php
164+
<?php
165+
// api/src/Entity/Parchment.php
166+
namespace App\Model;
167+
168+
use ApiPlatform\Metadata\Get;
169+
use Symfony\Component\Serializer\Attrbute\Groups;
170+
171+
#[Get(uriTemplate: '/v1/books/{id}', normalizationContext: ['groups' => ['v1']])]
172+
#[Get(uriTemplate: '/v2/books/{id}', normalizationContext: ['groups' => ['v2']])]
173+
class Parchment
174+
{
175+
#[Groups(['v1'])]
176+
public $name;
177+
178+
#[Groups(['v2'])]
179+
public $title;
180+
}
181+
```
182+
183+
> [!NOTE]
184+
> It's also possible to use the configuration `route_prefix` to prefix all your operations.

0 commit comments

Comments
 (0)