Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/book/v6/tutorials/create-book-module-via-dot-maker.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class Book extends AbstractEntity
public function getArrayCopy(): array
{
return [
'uuid' => $this->getUuid()->toString(),
'uuid' => $this->uuid->toString(),
'name' => $this->getName(),
'author' => $this->getAuthor(),
'releaseDate' => $this->getReleaseDate(),
Expand Down
2 changes: 1 addition & 1 deletion docs/book/v6/tutorials/create-book-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class Book extends AbstractEntity
public function getArrayCopy(): array
{
return [
'uuid' => $this->getUuid()->toString(),
'uuid' => $this->uuid->toString(),
'name' => $this->getName(),
'author' => $this->getAuthor(),
'releaseDate' => $this->getReleaseDate(),
Expand Down
26 changes: 13 additions & 13 deletions docs/book/v7/commands/display-available-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ The output should be similar to the following:
| GET | admin::view-account | /admin/account |
| PATCH | admin::update-account | /admin/account |
| GET | admin::list-role | /admin/role |
| GET | admin::view-role | /admin/role/{uuid} |
| DELETE | admin::delete-admin | /admin/{uuid} |
| GET | admin::view-admin | /admin/{uuid} |
| PATCH | admin::update-admin | /admin/{uuid} |
| GET | admin::view-role | /admin/role/{id} |
| DELETE | admin::delete-admin | /admin/{id} |
| GET | admin::view-admin | /admin/{id} |
| PATCH | admin::update-admin | /admin/{id} |
| POST | app::create-error-report | /error-report |
| POST | security::token | /security/token |
| GET | user::list-user | /user |
Expand All @@ -43,15 +43,15 @@ The output should be similar to the following:
| GET | user::check-account-reset-password | /user/account/reset-password/{hash} |
| PATCH | user::update-account-reset-password | /user/account/reset-password/{hash} |
| GET | user::list-role | /user/role |
| GET | user::view-role | /user/role/{uuid} |
| DELETE | user::delete-user | /user/{uuid} |
| GET | user::view-user | /user/{uuid} |
| PATCH | user::update-user | /user/{uuid} |
| PATCH | user::activate-user | /user/{uuid}/activate |
| DELETE | user::delete-user-avatar | /user/{uuid}/avatar |
| GET | user::view-user-avatar | /user/{uuid}/avatar |
| POST | user::create-user-avatar | /user/{uuid}/avatar |
| PATCH | user::deactivate-user | /user/{uuid}/deactivate |
| GET | user::view-role | /user/role/{id} |
| DELETE | user::delete-user | /user/{id} |
| GET | user::view-user | /user/{id} |
| PATCH | user::update-user | /user/{id} |
| PATCH | user::activate-user | /user/{id}/activate |
| DELETE | user::delete-user-avatar | /user/{id}/avatar |
| GET | user::view-user-avatar | /user/{id}/avatar |
| POST | user::create-user-avatar | /user/{id}/avatar |
| PATCH | user::deactivate-user | /user/{id}/deactivate |
+------+----------------+-------------------------------------+-------------------------------------+

```
Expand Down
2 changes: 1 addition & 1 deletion docs/book/v7/extended-features/route-grouping.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Along with the features from `mezzio/mezzio-fastroute`, the new `dot-router` pac
Here we have an example from `src/User/src/RoutesDelegator.php` with the new grouping method:

```php
$routeCollector->group('/user/' . $uuid)
$routeCollector->group('/user/' . $id)
->delete('', DeleteUserResourceHandler::class, 'user::delete-user')
->get('', GetUserResourceHandler::class, 'user::view-user')
->patch('', PatchUserResourceHandler::class, 'user::update-user');
Expand Down
4 changes: 2 additions & 2 deletions docs/book/v7/openapi/initialized-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ use OpenApi\Attributes as OA;
#[OA\Schema(
schema: 'UserRole',
properties: [
new OA\Property(property: 'uuid', type: 'string', example: '1234abcd-abcd-4321-12ab-123456abcdef'),
new OA\Property(property: 'id', type: 'string', example: '1234abcd-abcd-4321-12ab-123456abcdef'),
new OA\Property(property: 'name', type: 'string', example: UserRole::ROLE_USER),
new OA\Property(
property: '_links',
Expand Down Expand Up @@ -132,7 +132,7 @@ Then, when generating the documentation file, `OpenAPI` will transform it into t
```yaml
UserRole:
properties:
uuid:
id:
type: string
example: 1234abcd-abcd-4321-12ab-123456abcdef
name:
Expand Down
10 changes: 5 additions & 5 deletions docs/book/v7/openapi/write-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If you need help, take a look at the existing definitions found in Dotkernel API

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

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

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

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

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

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

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

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

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

- `path`: the route to the resource (example: `/resource/{uuid}` - where `uuid` is a path parameter defined below)
- `path`: the route to the resource (example: `/resource/{id}` - where `id` is a path parameter defined below)
- `description`: verbose description of the endpoint's purpose
- `summary`: short description of the endpoint's purpose
- `security`: an array of security scheme(s) to be used—omit if the endpoint is not protected
Expand Down
14 changes: 7 additions & 7 deletions docs/book/v7/tutorials/api-evolution.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ API evolution: Updating an API while keeping it compatible for existing consumer

## How it works

In Dotkernel API we can mark an entire endpoint or a single method as deprecated using attributes on handlers.
In Dotkernel API we can mark an endpoint as deprecated using attributes on handlers.
We use response headers to inform the consumers about the future changes by using two new headers:

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

**Both headers are independent, you can use them separately.**
**The above headers are independent, so you can use them separately.**

> Make sure you have the `DeprecationMiddleware:class` piped in your `pipeline` list.
> Make sure you have the `DeprecationMiddleware:class` added to your `pipeline` list.
> In our case it's `config/pipeline.php`.

## Marking an entire endpoint as deprecated
## Marking an endpoint as deprecated

When you want to mark an entire resource as deprecated, you have to use the `ResourceDeprecation` attribute.
When you want to mark a resource as deprecated, you have to use the `ResourceDeprecation` attribute.

```php
...
Expand All @@ -33,7 +33,7 @@ class HomeHandler implements RequestHandlerInterface
}
```

In the example above, the `ResourceDeprecation` attribute is attached to the class, marking the entire `/` (home) endpoint as deprecated starting from `2038-01-01`.
In the example above, the `ResourceDeprecation` attribute is attached to the class, marking the `/` (home) endpoint as deprecated starting from `2038-01-01`.

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

Expand Down Expand Up @@ -62,4 +62,4 @@ Vary: Origin

> Deprecations can only be attached to handler classes that implement `RequestHandlerInterface`.

> The `rel` and `type` arguments are optional, they default to `sunset` and `text/html` if no value was provided and are `Link` related parts.
> The `rel` and `type` arguments are optional, they default to `sunset` and `text/html` if no value is provided and are `Link` related parts.
32 changes: 27 additions & 5 deletions docs/book/v7/tutorials/create-book-module-via-dot-maker.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace Core\Book\Entity;

use Core\App\Entity\AbstractEntity;
use Core\App\Entity\TimestampsTrait;
use Core\App\Entity\UuidIdentifierTrait;
use Core\Book\Repository\BookRepository;
use DateTimeImmutable;
use Doctrine\ORM\Mapping as ORM;
Expand All @@ -120,6 +121,7 @@ use Doctrine\ORM\Mapping as ORM;
class Book extends AbstractEntity
{
use TimestampsTrait;
use UuidIdentifierTrait;

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

/**
* @return array{
* id: non-empty-string,
* name: non-empty-string,
* author: non-empty-string,
* releaseDate: DateTimeImmutable|null,
* created: DateTimeImmutable|null,
* updated: DateTimeImmutable|null,
* }
*/
public function getArrayCopy(): array
{
return [
'uuid' => $this->getUuid()->toString(),
'name' => $this->getName(),
'author' => $this->getAuthor(),
'releaseDate' => $this->getReleaseDate(),
'id' => $this->id->toString(),
'name' => $this->name,
'author' => $this->author,
'releaseDate' => $this->releaseDate,
'created' => $this->created,
'updated' => $this->updated,
];
}
}
Expand Down Expand Up @@ -306,6 +320,14 @@ use Api\Book\InputFilter\Input\NameInput;
use Api\Book\InputFilter\Input\ReleaseDateInput;
use Core\App\InputFilter\AbstractInputFilter;

/**
* @phpstan-type CreateBookDataType array{
* name: non-empty-string,
* author: non-empty-string,
* name: DateTimeImmutable|null,
* }
* @extends AbstractInputFilter<CreateBookDataType>
*/
class CreateBookInputFilter extends AbstractInputFilter
{
public function __construct()
Expand Down Expand Up @@ -428,5 +450,5 @@ To fetch a book, `curl` one of the links found in the output of the **list books
The link should have the following format:

```shell
curl http://0.0.0.0:8080/book/{uuid}
curl http://0.0.0.0:8080/book/{id}
```
Loading