Skip to content

Commit 68dfcfe

Browse files
authored
Document Deprecation HTTP Header usage (#2233)
1 parent 17aac72 commit 68dfcfe

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

core/deprecations.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,41 @@ class Parchment
169169
}
170170
```
171171

172+
### Setting the Deprecation HTTP Header to Indicate When an Operation Is Deprecated
173+
174+
[The Deprecation HTTP Response Header Field (RFC 9745)](https://datatracker.ietf.org/doc/rfc9745/)
175+
indicates that a URI will be or has been deprecated. This header can be used alongside the `Sunset`
176+
header to provide a deprecation date and a link to relevant documentation. Additionally, the
177+
`deprecation` link relation can be used to point to a resource that provides further information
178+
about the planned or existing deprecation.
179+
180+
To set a `Deprecation` header, use the `headers` option in the operation definition. The value of
181+
the `deprecation` header should be a Unix timestamp. You can also provide a `Link` header with a
182+
`deprecation` relation to give users more context about the deprecation:
183+
184+
```php
185+
use ApiPlatform\Metadata\ApiResource;
186+
use ApiPlatform\Metadata\GetCollection;
187+
use ApiPlatform\Metadata\Link;
188+
189+
#[ApiResource(
190+
operations: [
191+
new GetCollection(
192+
headers: [
193+
'deprecation' => '1688169599', // Unix timestamp
194+
],
195+
links: [
196+
new Link('deprecation', 'https://developer.example.com/deprecation'),
197+
],
198+
),
199+
],
200+
)]
201+
class DeprecationHeader
202+
{
203+
// ...
204+
}
205+
```
206+
172207
## Path versioning
173208

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

0 commit comments

Comments
 (0)