This commit is contained in:
@@ -7,16 +7,36 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Repository\RoomCategoryRepository;
|
||||
use App\Entity\RoomCategory;
|
||||
use App\Entity\RoomCategoryPhoto;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use OpenApi\Annotations\Property;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder;
|
||||
use OpenApi\Attributes as OA;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
class RoomCategoryController extends AbstractController
|
||||
{
|
||||
|
||||
#[Route('/api/room/category', name: 'app_room_AllCategories')]
|
||||
/**
|
||||
* Get All room categories.
|
||||
*/
|
||||
#[Route('/api/room/category', name: 'app_room_AllCategories', methods: ["GET"])]
|
||||
#[OA\Tag(name: "Rooms")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Returns all room categories',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "results",
|
||||
type: "array",
|
||||
items: new OA\Items(ref: new Model(type: RoomCategory::class))
|
||||
)
|
||||
]
|
||||
)
|
||||
)]
|
||||
public function getAll(RoomCategoryRepository $catRepo): Response
|
||||
{
|
||||
$catList = $catRepo->findAll();
|
||||
@@ -24,7 +44,24 @@ class RoomCategoryController extends AbstractController
|
||||
return $this->json(["results" => $catList]);
|
||||
}
|
||||
|
||||
#[Route('/api/room/category/{id}', name: 'app_room_category')]
|
||||
/**
|
||||
* Get a room category by ID.
|
||||
*/
|
||||
#[Route('/api/room/category/{id}', name: 'app_room_category', methods: ["GET"])]
|
||||
#[OA\Tag(name: "Rooms")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Returns a room category',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
ref: new Model(type: RoomCategory::class),
|
||||
)
|
||||
)]
|
||||
#[OA\Parameter(
|
||||
name: 'id',
|
||||
in: 'path',
|
||||
description: 'RoomCategory ID',
|
||||
)]
|
||||
public function getById(RoomCategory $category): Response
|
||||
{
|
||||
return $this->json($category);
|
||||
|
||||
Reference in New Issue
Block a user