You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by andersmateusz October 6, 2023
Hey, I have encountered following problem when normalizing data in my Symfony app where I use API Platform as bundle. I have 'File' entity registered as API resource. When invoking follwing code:
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Client;
use App\Entity\Complaint;
use App\Entity\File;
use App\Repository\ClientRepository;
use App\Repository\FileRepository;
use App\Service\AzureBlobServiceAdapter;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
#[Route('/storage')]
final class StorageController extends AbstractController
{
public const DEFAULT_CONTAINER_NAME = 'files';
#[Route('/store', name: 'app_storage_store', methods: ['POST'])]
public function store(Request $request, AzureBlobServiceAdapter $azureBlobService, SerializerInterface $serializer, ClientRepository $clientRepository): JsonResponse
{
$file = new File();
$normalize = $serializer->normalize($file);
I get an error: 'Unable to generate an IRI for the item of type "App\Entity\File"'. In general it happens when I want to normalize API resource that is not persisted yet and does not have id issigned.
Now the questions are:
How to disable IRI generation in normalization context (if possible)?
How to disable linking API docs in response header for routes that are not API platform routes?
Can I define in API Platform which are and which are not API routes (for example all routes that start with prefix '/api' should return docs and rest of them not)?
Why API Platform interferes in Symfony serialization process?
Thank you for your response in advance.
The text was updated successfully, but these errors were encountered:
Discussed in #5875
Originally posted by andersmateusz October 6, 2023
Hey, I have encountered following problem when normalizing data in my Symfony app where I use API Platform as bundle. I have 'File' entity registered as API resource. When invoking follwing code:
I get an error: 'Unable to generate an IRI for the item of type "App\Entity\File"'. In general it happens when I want to normalize API resource that is not persisted yet and does not have id issigned.
Now the questions are:
How to disable IRI generation in normalization context (if possible)?
How to disable linking API docs in response header for routes that are not API platform routes?
Can I define in API Platform which are and which are not API routes (for example all routes that start with prefix '/api' should return docs and rest of them not)?
Why API Platform interferes in Symfony serialization process?
Thank you for your response in advance.
The text was updated successfully, but these errors were encountered: