Skip to content
Snippets Groups Projects
RestaurantController.php 1.06 KiB
Newer Older
<?php

declare(strict_types=1);

namespace App\Controller;

use App\Service\RestaurantService;
use Nelmio\ApiDocBundle\Annotation\Model;
use OpenApi\Annotations as OA;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use App\Model\RestaurantList;

#[Route("/api/v1")]
class RestaurantController extends AbstractController
{
    public function __construct(private RestaurantService $restaurantService) {}

    /**
     @OA\OpenApi\Response(response=200, description="Листинг ресторанов")
     * @OA\Parameter(
     *     name="page",
     *     in="query",
     *     description="Номер страницы",
     *     @OA\Schema(type="integer")
     * )
     * @Model(type=RestaurantList::class)
     */
    #[Route('/restaurants', name: 'restaurants', methods: ['GET'])]
    public function index(int $page): Response
    {
        $restaurantsList = $this->restaurantService->getRestaurants();
        return $this->json($restaurantsList);
    }


}