-
Notifications
You must be signed in to change notification settings - Fork 0
WIP: apip 4 and frankenphp migrations #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
mtarld
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round 😉
| // We must trigger the API Platform validator before the data transforming. | ||
| // Let's create an API Platform PR to update the AbstractItemNormalizer. | ||
| // In that way, this exception won't be raised anymore as payload will be validated (see DiscountBookPayload). | ||
| InvalidArgumentException::class => 422, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still working without it? Maybe it has been fixed 🙂
|
|
||
| $resources = []; | ||
| foreach ($models as $model) { | ||
| $resources[] = BookResource::fromModel($model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ObjectMapper has been integrated into API Platform, I think it could be great to use it here (and in other providers/processors).
To get inspiration, you can have a look at ObjectMapperProvider and ObjectMapperProcessor in API Platform's code.
| /** @var string $id */ | ||
| $id = $uriVariables['id']; | ||
|
|
||
| $model = $this->queryBus->ask(new FindBookQuery(new BookId(Uuid::fromString($id)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to remove the query bus for simple use cases like that and use the repository directly.
But maybe it's for a next PR
| * | ||
| * @return T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing it?
| * | ||
| * @return T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
| final readonly class AuthorFilter implements FilterInterface | ||
| { | ||
| #[\Override] | ||
| public function getDescription(string $resourceClass): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is deprecated in 4.2.
I think we should add a job checking that we have no deprecations, but same, for another PR!
| use ApiPlatform\Metadata\FilterInterface; | ||
| use Symfony\Component\TypeInfo\TypeIdentifier; | ||
|
|
||
| final readonly class AuthorFilter implements FilterInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, you can leverage this instead: https://api-platform.com/docs/core/filters/#customizing-the-openapi-parameter
| 'author' => [ | ||
| 'property' => 'author', | ||
| 'type' => Type::BUILTIN_TYPE_STRING, | ||
| 'type' => TypeIdentifier::STRING->value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be great to validate the type with: https://api-platform.com/docs/core/filters/#parameter-validation
| $resources = []; | ||
| foreach ($models as $model) { | ||
| $resources[] = BookResource::fromModel($model); | ||
| } | ||
|
|
||
| if (null !== $paginator = $models->paginator()) { | ||
| $resources = new Paginator( | ||
| new \ArrayIterator($resources), | ||
| (float) $paginator->getCurrentPage(), | ||
| (float) $paginator->getItemsPerPage(), | ||
| (float) $paginator->getLastPage(), | ||
| (float) $paginator->getTotalItems(), | ||
| ); | ||
| } | ||
|
|
||
| return $resources; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that with the ObjectMapper use, this won't be needed anymore 🎉
| - caddy_data:/data | ||
| - caddy_config:/config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - caddy_data:/data | |
| - caddy_config:/config | |
| - caddy_data:/data | |
| - caddy_config:/config |
No description provided.