title: How to create custom endpoint in API Platform and add it to the documentation?
body: <p>I want to create not mapped with entity endpoint like <code>/api/v1/me</code> that returns information (<code>User</code> object) about currently authenticated user and add it to my documentation. In the plans I also want to add endpoints like <code>/api/v1/account/recover</code> and <code>/api/v1/account/verify-email</code>.</p>
  
  <p>I have an action:</p>
  
  <pre><code>namespace AppBundle\Action\Me;
  
  use AppBundle\Entity\User;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  use Symfony\Component\Routing\Annotation\Route;
  use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  
  class MeView
  {
  
      /**
       * @var TokenStorageInterface
       */
      private $tokenStorage;
  
      public function __construct(TokenStorageInterface $tokenStorage)
      {
          $this-&gt;tokenStorage = $tokenStorage;
      }
  
      /**
       * @Security("is_authenticated()")
       *
       * @Route(
       *     name="me_view",
       *     path="/me",
       *     methods={"GET"}
       * )
       *
       * @return User
       */
      public function __invoke()
      {
          return $this-&gt;tokenStorage-&gt;getToken()-&gt;getUser();
      }
  }
  </code></pre>
  
  <p>But when I try to access it, it returns an exception:</p>
  
  <blockquote>
    <p>The controller must return a response (Object(AppBundle\Entity\User) given). (500 Internal Server Error)</p>
  </blockquote>
  
  <p>Same action, but mapped with entity, works well:</p>
  
  <pre><code>namespace AppBundle\Action\City;
  
  use AppBundle\Entity\City;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  use Symfony\Component\Routing\Annotation\Route;
  
  class CityView
  {
  
      /**
       * @Security("is_authenticated()")
       *
       * @Route(
       *     name="city_view",
       *     path="/cities/{id}",
       *     methods={"GET"},
       *     defaults={"_api_resource_class"=City::class, "_api_item_operation_name"="view"}
       * )
       *
       * @param City $city
       * @return City
       */
      public function __invoke(City $city)
      {
          return $city;
      }
  }
  </code></pre>
  
  <p>What should I do to make my custom action work and how to add it to auto-generated Swagger documentation?</p>