You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/v7/tutorials/api-evolution.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,20 +4,20 @@ API evolution: Updating an API while keeping it compatible for existing consumer
4
4
5
5
## How it works
6
6
7
-
In Dotkernel API we can mark an entire endpoint or a single method as deprecated using attributes on handlers.
7
+
In Dotkernel API we can mark an endpoint as deprecated using attributes on handlers.
8
8
We use response headers to inform the consumers about the future changes by using two new headers:
9
9
10
10
-`Link` - it's a link to the official documentation pointing out the changes that will take place.
11
11
-`Sunset` - this header is a date, indicating when the deprecated resource will potentially become unresponsive.
12
12
13
-
**Both headers are independent, you can use them separately.**
13
+
**The above headers are independent, so you can use them separately.**
14
14
15
-
> Make sure you have the `DeprecationMiddleware:class`piped in your `pipeline` list.
15
+
> Make sure you have the `DeprecationMiddleware:class`added to your `pipeline` list.
16
16
> In our case it's `config/pipeline.php`.
17
17
18
-
## Marking an entire endpoint as deprecated
18
+
## Marking an endpoint as deprecated
19
19
20
-
When you want to mark an entire resource as deprecated, you have to use the `ResourceDeprecation` attribute.
20
+
When you want to mark a resource as deprecated, you have to use the `ResourceDeprecation` attribute.
21
21
22
22
```php
23
23
...
@@ -33,7 +33,7 @@ class HomeHandler implements RequestHandlerInterface
33
33
}
34
34
```
35
35
36
-
In the example above, the `ResourceDeprecation` attribute is attached to the class, marking the entire `/` (home) endpoint as deprecated starting from `2038-01-01`.
36
+
In the example above, the `ResourceDeprecation` attribute is attached to the class, marking the `/` (home) endpoint as deprecated starting from `2038-01-01`.
37
37
38
38
Running the following curl will print out the response headers where we can see the **Sunset** and **Link** headers.
39
39
@@ -62,4 +62,4 @@ Vary: Origin
62
62
63
63
> Deprecations can only be attached to handler classes that implement `RequestHandlerInterface`.
64
64
65
-
> The `rel` and `type` arguments are optional, they default to `sunset` and `text/html` if no value was provided and are `Link` related parts.
65
+
> The `rel` and `type` arguments are optional, they default to `sunset` and `text/html` if no value is provided and are `Link` related parts.
public function getBooks(array $params = []): QueryBuilder;
218
237
}
219
238
@@ -253,6 +272,7 @@ class BookService implements BookServiceInterface
253
272
254
273
/**
255
274
* @throws Exception
275
+
* @param array<non-empty-string,mixed> $data
256
276
*/
257
277
public function saveBook(array $data): Book
258
278
{
@@ -267,6 +287,9 @@ class BookService implements BookServiceInterface
267
287
return $book;
268
288
}
269
289
290
+
/**
291
+
* @param array<non-empty-string,mixed> $params
292
+
*/
270
293
public function getBooks(array $params = []): QueryBuilder
271
294
{
272
295
$filters = $params['filters'] ?? [];
@@ -289,7 +312,7 @@ class BookService implements BookServiceInterface
289
312
290
313
```
291
314
292
-
When creating or updating a book, we will need some validators, so we will create input filters that will be used to validate the data received in the request
315
+
When creating or updating a book, we will need some validators, so we will create input filters that will be used to validate the data received in the request.
293
316
294
317
*`src/Book/src/InputFilter/Input/AuthorInput.php`
295
318
@@ -415,6 +438,14 @@ use Api\Book\InputFilter\Input\NameInput;
0 commit comments