0
votes

With Api-Platform, exposing Doctrine Entities is quite easy and works very well but I don't see how to create custom entrypoint without entities just to call an external service and get its data or do complex treatments

I saw this post (API Platform - Which approach should I use for creating custom operation without entity) but I don't want to create a POST method just to insert my logic in a data persister.

If i just want to create one entrypoint /getMyCustomData with the GET method and without passing any parameter, what should I do?

I looked at swagger decorators but if I understand, it works on an existing entity.

1
Why do you need Api-Platform for this? - yivi
Api platform helps me for CRUD of a lot of entities but to keep the API documentation up to date, i want this entrypoint to be documented in the swagger documentation. Like Mattin answered, i can create a controller but doing so don't add the entrypoint in the swagger documentation. and i didn't found a Action-Domain-Responder example if it is the rigth solution to use - pop_up

1 Answers

2
votes

you can create just a normal controller in Symfony.

/**
 * @Route("/getMyCustomData", methods={"GET"}, name="my_api_custom_data")
 * @param Request $request
 * @return Response
 */
public function getMyCustomDataAction(Request $request): Response
{

   /** your code **/

}