File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -213,3 +213,29 @@ final class BookRepresentationProcessor implements ProcessorInterface
213
213
}
214
214
}
215
215
```
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
+ ```
Original file line number Diff line number Diff line change @@ -141,6 +141,5 @@ As this is an `extraProperties` it's configurable per resource/operation. This i
141
141
142
142
# ## OpenApi context
143
143
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).
You can’t perform that action at this time.
0 commit comments