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
As you can see in example, you can register as many endpoints as you want with different configurations. Nette-Api supports API versioning from the beginning.
@@ -179,8 +179,8 @@ Example with user detail:
179
179
namespace App\MyApi\v1\Handlers;
180
180
181
181
use Tomaj\NetteApi\Handlers\BaseHandler;
182
+
use Tomaj\NetteApi\Params\GetInputParam;
182
183
use Tomaj\NetteApi\Response\JsonApiResponse;
183
-
use Tomaj\NetteApi\Params\InputParam;
184
184
use Tomaj\NetteApi\Response\ResponseInterface;
185
185
186
186
class UsersDetailHandler extends Basehandler
@@ -196,7 +196,7 @@ class UsersDetailHandler extends Basehandler
196
196
public function params(): array
197
197
{
198
198
return [
199
-
new InputParam(InputParam::TYPE_GET, 'id', InputParam::REQUIRED),
199
+
(new GetInputParam('id'))->setRequired(),
200
200
];
201
201
}
202
202
@@ -224,12 +224,12 @@ This is table with support input types:
224
224
225
225
| Input type | Example
226
226
| ---------- | -------
227
-
| POST | `new InputParam(InputParam::TYPE_POST, 'key')`
228
-
| GET | `new InputParam(InputParam::TYPE_GET, 'key')`
Copy file name to clipboardExpand all lines: UPGRADE.md
+39-2
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,35 @@
2
2
3
3
## Upgrade from 1.x to 2.0.0
4
4
5
+
### Splitted InputParam to multiple subclasses
6
+
InputParam is now abstract class and all types have their own class. Also InputParam is more like Nette Form inputs with fluent API
7
+
8
+
Examples of replacements:
9
+
10
+
Requred get input with available values:
11
+
12
+
Old:
13
+
```php
14
+
new InputParam(InputParam::TYPE_GET, 'status', InputParam::REQUIRED, ['ok', 'error'])
15
+
```
16
+
17
+
New:
18
+
```php
19
+
(new GetInputParam('status'))->setRequired()->setAvailableValues(['ok', 'error'])
20
+
```
21
+
22
+
Multiple optional file input:
23
+
24
+
Old:
25
+
```php
26
+
new InputParam(InputParam::TYPE_FILE, 'myfile', InputParam::OPTIONAL, null, true)
27
+
```
28
+
29
+
New:
30
+
```php
31
+
(new FileInputParam('myfile'))->setMulti()
32
+
```
33
+
5
34
### Removed support for old PHP versions
6
35
New version not supported PHP versions 5.6 and 7.0 and also hhvm. Please use it with newer versions of PHP (>7.1)
7
36
@@ -47,6 +76,9 @@ Add typehints to methods:
47
76
-`getApiAction(): ?string`
48
77
-`getUrl(): string`
49
78
79
+
### Changed behavior
80
+
API handler tripplet (array of endpoint, handler, authorization) has been changed to class `Api` which has methods `getEndpoint()`, `getHandler()` and `getAuthorization()`.
81
+
50
82
### Renamed methods
51
83
Few methods have been renamed, please use their new versions:
0 commit comments