File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,40 @@ 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/) indicates that a URI
175+ will be or has been deprecated. This header can be used alongside the `Sunset` header to provide a deprecation date and
176+ a link to relevant documentation. Additionally, the `deprecation` link relation can be used to point to a resource that
177+ provides further information about the planned or existing deprecation.
178+
179+ To set a `Deprecation` header, use the `headers` option in the operation definition. The value of the `deprecation`
180+ header should be a Unix timestamp. You can also provide a `Link` header with a `deprecation` relation to give users more
181+ context about the deprecation :
182+
183+ ` ` ` php
184+ use ApiPlatform\M etadata\A piResource;
185+ use ApiPlatform\M etadata\G etCollection;
186+ use ApiPlatform\M etadata\L ink;
187+
188+ #[ApiResource(
189+ operations: [
190+ new GetCollection(
191+ headers: [
192+ 'deprecation' => '@1688169599', // Unix timestamp
193+ ],
194+ links: [
195+ new Link('deprecation', 'https://developer.example.com/deprecation'),
196+ ],
197+ ),
198+ ],
199+ )]
200+ class DeprecationHeader
201+ {
202+ // ...
203+ }
204+ ` ` `
205+
172206# # Path versioning
173207
174208> [!NOTE] REST and GraphQL architectures recommend to use deprecations instead of path versioning.
You can’t perform that action at this time.
0 commit comments