تخطَّ إلى المحتوى

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.

<?php
#[Route('/users/{id}', methods: ['GET'])]
public function show(int $id)
{
return $this->json($this->repo->find($id));
}
<?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.