Missing API response type (ARCH7201)
Key php.quality.missing-api-response · Severity info · Category quality
Controller actions that don’t declare a response schema or status codes leave the generated OpenAPI docs incomplete. Declare response types explicitly.
Incorrect
Section titled “Incorrect”<?php#[Route('/users/{id}', methods: ['GET'])]public function show(int $id){ return $this->json($this->repo->find($id));}Correct
Section titled “Correct”<?php#[Route('/users/{id}', methods: ['GET'])]#[OA\Response(response: 200, description: 'User', content: new OA\JsonContent(ref: User::class))]#[OA\Response(response: 404, description: 'Not found')]public function show(int $id): JsonResponse{ return $this->json($this->repo->find($id));}Add annotations to each HTTP action declaring the response schema and returned status codes.