Skip to content

Commit 9d49823

Browse files
committed
docs(core/dtos): improve by adding other usages
fix(dto): remove useless doc fix(operation): remove unused operation fix(typing): wrong return type fix(lint/md): bare url
1 parent c7cd42c commit 9d49823

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

core/dto.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,29 @@ final class BookRepresentationProcessor implements ProcessorInterface
213213
}
214214
}
215215
```
216+
217+
## DTO without response
218+
219+
Sometimes we need DTOs to process something, but we don't need to send an object in response.
220+
Assuming that, we can disable the output for our API Resource using the following code:
221+
222+
```php
223+
<?php
224+
// api/src/Resource/Book.php with Symfony or app/Resource/Book.php with Laravel
225+
226+
declare(strict_types=1);
227+
228+
namespace App\ApiResource;
229+
230+
use ApiPlatform\Metadata\ApiResource;
231+
use App\Dto\BookInput;
232+
233+
#[ApiResource(
234+
input: BookInput::class,
235+
output: false, // Disables the response
236+
)]
237+
final class Book
238+
{
239+
// ...
240+
}
241+
```

core/upgrade-guide.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,5 @@ As this is an `extraProperties` it's configurable per resource/operation. This i
141141

142142
### OpenApi context
143143

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

0 commit comments

Comments
 (0)