Skip to content

Commit 3f38a0c

Browse files
authored
Merge pull request #146 from dotkernel/uuid-to-id
updated usage of uuid to id
2 parents ed13425 + 2c49349 commit 3f38a0c

File tree

10 files changed

+136
-52
lines changed

10 files changed

+136
-52
lines changed

docs/book/v6/tutorials/create-book-module-via-dot-maker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class Book extends AbstractEntity
180180
public function getArrayCopy(): array
181181
{
182182
return [
183-
'uuid' => $this->getUuid()->toString(),
183+
'uuid' => $this->uuid->toString(),
184184
'name' => $this->getName(),
185185
'author' => $this->getAuthor(),
186186
'releaseDate' => $this->getReleaseDate(),

docs/book/v6/tutorials/create-book-module.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class Book extends AbstractEntity
154154
public function getArrayCopy(): array
155155
{
156156
return [
157-
'uuid' => $this->getUuid()->toString(),
157+
'uuid' => $this->uuid->toString(),
158158
'name' => $this->getName(),
159159
'author' => $this->getAuthor(),
160160
'releaseDate' => $this->getReleaseDate(),

docs/book/v7/commands/display-available-endpoints.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ The output should be similar to the following:
2121
| GET | admin::view-account | /admin/account |
2222
| PATCH | admin::update-account | /admin/account |
2323
| GET | admin::list-role | /admin/role |
24-
| GET | admin::view-role | /admin/role/{uuid} |
25-
| DELETE | admin::delete-admin | /admin/{uuid} |
26-
| GET | admin::view-admin | /admin/{uuid} |
27-
| PATCH | admin::update-admin | /admin/{uuid} |
24+
| GET | admin::view-role | /admin/role/{id} |
25+
| DELETE | admin::delete-admin | /admin/{id} |
26+
| GET | admin::view-admin | /admin/{id} |
27+
| PATCH | admin::update-admin | /admin/{id} |
2828
| POST | app::create-error-report | /error-report |
2929
| POST | security::token | /security/token |
3030
| GET | user::list-user | /user |
@@ -43,15 +43,15 @@ The output should be similar to the following:
4343
| GET | user::check-account-reset-password | /user/account/reset-password/{hash} |
4444
| PATCH | user::update-account-reset-password | /user/account/reset-password/{hash} |
4545
| GET | user::list-role | /user/role |
46-
| GET | user::view-role | /user/role/{uuid} |
47-
| DELETE | user::delete-user | /user/{uuid} |
48-
| GET | user::view-user | /user/{uuid} |
49-
| PATCH | user::update-user | /user/{uuid} |
50-
| PATCH | user::activate-user | /user/{uuid}/activate |
51-
| DELETE | user::delete-user-avatar | /user/{uuid}/avatar |
52-
| GET | user::view-user-avatar | /user/{uuid}/avatar |
53-
| POST | user::create-user-avatar | /user/{uuid}/avatar |
54-
| PATCH | user::deactivate-user | /user/{uuid}/deactivate |
46+
| GET | user::view-role | /user/role/{id} |
47+
| DELETE | user::delete-user | /user/{id} |
48+
| GET | user::view-user | /user/{id} |
49+
| PATCH | user::update-user | /user/{id} |
50+
| PATCH | user::activate-user | /user/{id}/activate |
51+
| DELETE | user::delete-user-avatar | /user/{id}/avatar |
52+
| GET | user::view-user-avatar | /user/{id}/avatar |
53+
| POST | user::create-user-avatar | /user/{id}/avatar |
54+
| PATCH | user::deactivate-user | /user/{id}/deactivate |
5555
+------+----------------+-------------------------------------+-------------------------------------+
5656
5757
```

docs/book/v7/extended-features/route-grouping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Along with the features from `mezzio/mezzio-fastroute`, the new `dot-router` pac
1515
Here we have an example from `src/User/src/RoutesDelegator.php` with the new grouping method:
1616

1717
```php
18-
$routeCollector->group('/user/' . $uuid)
18+
$routeCollector->group('/user/' . $id)
1919
->delete('', DeleteUserResourceHandler::class, 'user::delete-user')
2020
->get('', GetUserResourceHandler::class, 'user::view-user')
2121
->patch('', PatchUserResourceHandler::class, 'user::update-user');

docs/book/v7/openapi/initialized-components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ use OpenApi\Attributes as OA;
103103
#[OA\Schema(
104104
schema: 'UserRole',
105105
properties: [
106-
new OA\Property(property: 'uuid', type: 'string', example: '1234abcd-abcd-4321-12ab-123456abcdef'),
106+
new OA\Property(property: 'id', type: 'string', example: '1234abcd-abcd-4321-12ab-123456abcdef'),
107107
new OA\Property(property: 'name', type: 'string', example: UserRole::ROLE_USER),
108108
new OA\Property(
109109
property: '_links',
@@ -132,7 +132,7 @@ Then, when generating the documentation file, `OpenAPI` will transform it into t
132132
```yaml
133133
UserRole:
134134
properties:
135-
uuid:
135+
id:
136136
type: string
137137
example: 1234abcd-abcd-4321-12ab-123456abcdef
138138
name:

docs/book/v7/openapi/write-documentation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If you need help, take a look at the existing definitions found in Dotkernel API
3030

3131
Defines a `DELETE` HTTP request. It should specify at least the following parameters:
3232

33-
- `path`: the route to the resource (example: `/resource/{uuid}` - where `uuid` is a path parameter defined below)
33+
- `path`: the route to the resource (example: `/resource/{id}` - where `id` is a path parameter defined below)
3434
- `description`: verbose description of the endpoint's purpose
3535
- `summary`: short description of the endpoint's purpose
3636
- `security`: an array of security scheme(s) to be used—omit if the endpoint is not protected
@@ -42,7 +42,7 @@ Defines a `DELETE` HTTP request. It should specify at least the following parame
4242

4343
Defines a `GET` HTTP request. It should specify at least the following parameters:
4444

45-
- `path`: the route to a single or collection of resources (example: `/resource/{uuid}` for a single resource or `/resource` for a collection of resources)
45+
- `path`: the route to a single or collection of resources (example: `/resource/{id}` for a single resource or `/resource` for a collection of resources)
4646
- `description`: verbose description of the endpoint's purpose
4747
- `summary`: short description of the endpoint's purpose
4848
- `security`: an array of security scheme(s) to be used—omit if the endpoint is not protected
@@ -54,7 +54,7 @@ Defines a `GET` HTTP request. It should specify at least the following parameter
5454

5555
Defines a `PATCH` HTTP request. It should specify at least the following parameters:
5656

57-
- `path`: the route to the resource (example: `/resource/{uuid}` - where `uuid` is a path parameter defined below)
57+
- `path`: the route to the resource (example: `/resource/{id}` - where `id` is a path parameter defined below)
5858
- `description`: verbose description of the endpoint's purpose
5959
- `summary`: short description of the endpoint's purpose
6060
- `security`: an array of security scheme(s) to be used—omit if the endpoint is not protected
@@ -67,7 +67,7 @@ Defines a `PATCH` HTTP request. It should specify at least the following paramet
6767

6868
Defines a `POST` HTTP request. It should specify at least the following parameters:
6969

70-
- `path`: the route to the resource (example: `/resource/{uuid}` - where `uuid` is a path parameter defined below)
70+
- `path`: the route to the resource (example: `/resource/{id}` - where `id` is a path parameter defined below)
7171
- `description`: verbose description of the endpoint's purpose
7272
- `summary`: short description of the endpoint's purpose
7373
- `security`: an array of security scheme(s) to be used—omit if the endpoint is not protected
@@ -80,7 +80,7 @@ Defines a `POST` HTTP request. It should specify at least the following paramete
8080

8181
Defines a `PUT` HTTP request. It should specify at least the following parameters:
8282

83-
- `path`: the route to the resource (example: `/resource/{uuid}` - where `uuid` is a path parameter defined below)
83+
- `path`: the route to the resource (example: `/resource/{id}` - where `id` is a path parameter defined below)
8484
- `description`: verbose description of the endpoint's purpose
8585
- `summary`: short description of the endpoint's purpose
8686
- `security`: an array of security scheme(s) to be used—omit if the endpoint is not protected

docs/book/v7/tutorials/api-evolution.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ API evolution: Updating an API while keeping it compatible for existing consumer
44

55
## How it works
66

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.
88
We use response headers to inform the consumers about the future changes by using two new headers:
99

1010
- `Link` - it's a link to the official documentation pointing out the changes that will take place.
1111
- `Sunset` - this header is a date, indicating when the deprecated resource will potentially become unresponsive.
1212

13-
**Both headers are independent, you can use them separately.**
13+
**The above headers are independent, so you can use them separately.**
1414

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.
1616
> In our case it's `config/pipeline.php`.
1717
18-
## Marking an entire endpoint as deprecated
18+
## Marking an endpoint as deprecated
1919

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.
2121

2222
```php
2323
...
@@ -33,7 +33,7 @@ class HomeHandler implements RequestHandlerInterface
3333
}
3434
```
3535

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`.
3737

3838
Running the following curl will print out the response headers where we can see the **Sunset** and **Link** headers.
3939

@@ -62,4 +62,4 @@ Vary: Origin
6262
6363
> Deprecations can only be attached to handler classes that implement `RequestHandlerInterface`.
6464
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.

docs/book/v7/tutorials/create-book-module-via-dot-maker.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ namespace Core\Book\Entity;
110110

111111
use Core\App\Entity\AbstractEntity;
112112
use Core\App\Entity\TimestampsTrait;
113+
use Core\App\Entity\UuidIdentifierTrait;
113114
use Core\Book\Repository\BookRepository;
114115
use DateTimeImmutable;
115116
use Doctrine\ORM\Mapping as ORM;
@@ -120,6 +121,7 @@ use Doctrine\ORM\Mapping as ORM;
120121
class Book extends AbstractEntity
121122
{
122123
use TimestampsTrait;
124+
use UuidIdentifierTrait;
123125

124126
#[ORM\Column(name: "name", type: "string", length: 100)]
125127
protected string $name;
@@ -175,13 +177,25 @@ class Book extends AbstractEntity
175177
return $this;
176178
}
177179

180+
/**
181+
* @return array{
182+
* id: non-empty-string,
183+
* name: non-empty-string,
184+
* author: non-empty-string,
185+
* releaseDate: DateTimeImmutable|null,
186+
* created: DateTimeImmutable|null,
187+
* updated: DateTimeImmutable|null,
188+
* }
189+
*/
178190
public function getArrayCopy(): array
179191
{
180192
return [
181-
'uuid' => $this->getUuid()->toString(),
182-
'name' => $this->getName(),
183-
'author' => $this->getAuthor(),
184-
'releaseDate' => $this->getReleaseDate(),
193+
'id' => $this->id->toString(),
194+
'name' => $this->name,
195+
'author' => $this->author,
196+
'releaseDate' => $this->releaseDate,
197+
'created' => $this->created,
198+
'updated' => $this->updated,
185199
];
186200
}
187201
}
@@ -306,6 +320,14 @@ use Api\Book\InputFilter\Input\NameInput;
306320
use Api\Book\InputFilter\Input\ReleaseDateInput;
307321
use Core\App\InputFilter\AbstractInputFilter;
308322

323+
/**
324+
* @phpstan-type CreateBookDataType array{
325+
* name: non-empty-string,
326+
* author: non-empty-string,
327+
* name: DateTimeImmutable|null,
328+
* }
329+
* @extends AbstractInputFilter<CreateBookDataType>
330+
*/
309331
class CreateBookInputFilter extends AbstractInputFilter
310332
{
311333
public function __construct()
@@ -428,5 +450,5 @@ To fetch a book, `curl` one of the links found in the output of the **list books
428450
The link should have the following format:
429451

430452
```shell
431-
curl http://0.0.0.0:8080/book/{uuid}
453+
curl http://0.0.0.0:8080/book/{id}
432454
```

0 commit comments

Comments
 (0)