Skip to content

docs(core/dtos): improve by adding other usages #2167

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

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions core/dto.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,29 @@ final class BookRepresentationProcessor implements ProcessorInterface
}
}
```

## DTO without response

Sometimes we need DTOs to process something, but we don't need to send an object in response.
Assuming that, we can disable the output for our API Resource using the following code:

```php
<?php
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel

declare(strict_types=1);

namespace App\ApiResource;

use ApiPlatform\Metadata\ApiResource;
use App\Dto\BookInput;

#[ApiResource(
input: BookInput::class,
output: false, // Disables the response
)]
final class Book
{
// ...
}
```
5 changes: 2 additions & 3 deletions core/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,5 @@ As this is an `extraProperties` it's configurable per resource/operation. This i

### OpenApi context

You may want to convert your openApiContext to openapi, doing so is quite fastidious, @lyrixx created a rector script to help if needed:

https://github.com/lyrixx/rector-apip-openapi
You may want to convert your openApiContext to openapi, doing so is quite fastidious, @lyrixx created a rector script to
help if needed: [lyrixx/rector-apip-openapi](https://github.com/lyrixx/rector-apip-openapi).