File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff 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\M etadata\A piResource;
186+ use ApiPlatform\M etadata\G etCollection;
187+ use ApiPlatform\M etadata\L ink;
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.
You can’t perform that action at this time.
0 commit comments