mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-03 04:29:40 +00:00
Add endpoint to retrieve stored object content
- Introduced `/1.0/doc-store/stored-object/{uuid}` endpoint to fetch the content of a stored object by UUID.
- Implemented access control using `StoredObjectRoleEnum::SEE` permission.
- Added OpenAPI specification for the new endpoint, including path parameter `uuid` and response codes `200` and `403`.
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
|
||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
@@ -53,4 +54,17 @@ class StoredObjectApiController extends ApiController
|
||||
json: true
|
||||
);
|
||||
}
|
||||
|
||||
#[Route('/api/1.0/doc-store/stored-object/{uuid}', methods: ['GET'])]
|
||||
public function getStoredObject(StoredObject $storedObject): JsonResponse
|
||||
{
|
||||
if (!$this->security->isGranted(StoredObjectRoleEnum::SEE->value, $storedObject)) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
|
||||
return new JsonResponse(
|
||||
$this->serializer->serialize($storedObject, 'json', [AbstractNormalizer::GROUPS => ['read']]),
|
||||
json: true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,30 @@ paths:
|
||||
422:
|
||||
description: "Invalid data"
|
||||
|
||||
/1.0/doc-store/stored-object/{uuid}:
|
||||
get:
|
||||
tags:
|
||||
- storedobject
|
||||
summary: Get the content of a stored object
|
||||
parameters:
|
||||
- in: path
|
||||
name: uuid
|
||||
required: true
|
||||
allowEmptyValue: false
|
||||
description: The UUID of the storedObject
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
200:
|
||||
description: "OK"
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/StoredObject"
|
||||
403:
|
||||
description: "Unauthorized"
|
||||
|
||||
/1.0/doc-store/stored-object/{uuid}/is-ready:
|
||||
get:
|
||||
tags:
|
||||
|
||||
Reference in New Issue
Block a user