File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ final class PostController extends AbstractController
62
62
#[Route('/post', methods: ['GET'])]
63
63
public function getAll(#[Query] ?string $filter): PostCollection
64
64
{
65
- return $this->repository->findAll();
65
+ return $this->repository->findAll($filter );
66
66
}
67
67
68
68
#[Route('/post/{id}', methods: ['GET'])]
@@ -120,6 +120,25 @@ public function update(#[Body] Json $body): Json
120
120
}
121
121
```
122
122
123
+ ### Multiple response types
124
+
125
+ In case your method can return different response types you can use the ` #[Outgoing] ` attribute to
126
+ define a response schema independent of the return type.
127
+
128
+ ``` php
129
+ #[Route('/post', methods: ['POST'])]
130
+ #[Outgoing(201, Message::class)]
131
+ #[Outgoing(400, Error::class)]
132
+ public function update(#[Body] Post $body): JsonResponse
133
+ {
134
+ if (empty($body->getTitle())) {
135
+ return new JsonResponse(['error' => 'An error occurred'], 400);
136
+ }
137
+
138
+ return new JsonResponse(['success' => true], 201);
139
+ }
140
+ ```
141
+
123
142
## Generator
124
143
125
144
### SDK
You can’t perform that action at this time.
0 commit comments