title: API Platform Collection POST Operation without Item GET
body: <p>I want to create a resource with collection operations &quot;POST&quot; and &quot;GET&quot; and no item operations.</p>
  <pre><code>/**
   * @ApiResource(
   *     collectionOperations={
   *          &quot;get&quot;,
   *          &quot;post&quot;
   *     },
   *     itemOperations={}
   * )
   */
  </code></pre>
  <p>When I try to post an item I get the following error: &quot;No item route associated with the type App\Entity\MyEntity&quot;.</p>
  <p>I seems like API Platform is trying to create an IRI but it can't because there is no item &quot;GET&quot; operation.</p>
  <p>I do not need an IRI, the plain Id would be fine for me. Is there a way to do this?</p>
  <p>EDIT: I found a solution in the documentation: <a href="https://api-platform.com/docs/core/operations/#enabling-and-disabling-operations" rel="nofollow noreferrer">https://api-platform.com/docs/core/operations/#enabling-and-disabling-operations</a></p>
  <p>I can disable the GET operation like this:</p>
  <pre><code> *     itemOperations={
   *         &quot;get&quot;={
   *             &quot;controller&quot;=NotFoundAction::class,
   *             &quot;read&quot;=false,
   *             &quot;output&quot;=false,
   *         },
   *     },
  </code></pre>
  <p>However it does not return a 404 like the documentation says. Instead it returns a 500 error with message &quot;Controller NotFoundAction does neither exist as service nor as class.&quot;. How can I get it to return 404.</p>
  <p>Also it would be nice if the GET operation would not show up in my Swagger documentation.</p>
  <p>EDIT: I found my mistake with the 404. I forgot to include <code>use ApiPlatform\Core\Action\NotFoundAction;</code></p>
  <p>Now I just need a way to remove the route from my documentation.</p>
  <p>EDIT: I used a Swagger decorater to remove the route from the docs.</p>
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  
  declare(strict_types=1);
  
  namespace App\Swagger;
  
  use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  
  final class SwaggerDecorator implements NormalizerInterface
  {
      private NormalizerInterface $decorated;
  
      public function __construct(NormalizerInterface $decorated)
      {
          $this-&gt;decorated = $decorated;
      }
  
      public function supportsNormalization($data, string $format = null): bool
      {
          return $this-&gt;decorated-&gt;supportsNormalization($data, $format);
      }
  
      public function normalize($object, string $format = null, array $context = [])
      {
          $docs = $this-&gt;decorated-&gt;normalize($object, $format, $context);
  
          unset($docs['paths']['/products/{id}']);
  
          return $docs;
      }
  }
  </code></pre>
  <p>And in services.yaml:</p>
  <pre class="lang-yaml prettyprint-override"><code>App\Swagger\SwaggerDecorator:
          decorates: 'api_platform.swagger.normalizer.documentation'
          arguments: [ '@App\Swagger\SwaggerDecorator.inner' ]
          autoconfigure: false
  </code></pre>
  <p>My solution works but I am not sure if it is the best solution. So if any one has another idea, feel free to answer.</p>