Skip to content
Merged
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions core/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,41 @@ class Parchment
}
```

### Setting the Deprecation HTTP Header to Indicate When an Operation Is Deprecated

[The Deprecation HTTP Response Header Field (RFC 9745)](https://datatracker.ietf.org/doc/rfc9745/)
indicates that a URI will be or has been deprecated. This header can be used alongside the `Sunset`
header to provide a deprecation date and a link to relevant documentation. Additionally, the
`deprecation` link relation can be used to point to a resource that provides further information
about the planned or existing deprecation.

To set a `Deprecation` header, use the `headers` option in the operation definition. The value of
the `deprecation` header should be a Unix timestamp. You can also provide a `Link` header with a
`deprecation` relation to give users more context about the deprecation:

```php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;

#[ApiResource(
operations: [
new GetCollection(
headers: [
'deprecation' => '1688169599', // Unix timestamp
],
links: [
new Link('deprecation', 'https://developer.example.com/deprecation'),
],
),
],
)]
class DeprecationHeader
{
// ...
}
```

## Path versioning

> [!NOTE] REST and GraphQL architectures recommend to use deprecations instead of path versioning.
Expand Down