A
A
AlpineMilk2020-09-07 21:38:29
PHP
AlpineMilk, 2020-09-07 21:38:29

How to make a custom endpoint with your own parameters in the Api platform?

Hello everyone,
I'm doing a test task, and I need to connect to an external API to take data from it and display it myself. The problem is what needs to be done using the Api platform, which I have not dealt with before. I understand that it should be used as a layer between my application and an external api, but I want to use a route similar to this /api/route/{startdate}/{enddate}one and I don’t find the possibility of creating such a route with my own parameters in the api platform. I also don’t have entities, since I don’t work with a database, but there is just a Vacation object into which I convert data from an external api. How to make such a route? and its processing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2020-09-08
@SilenceOfWinter

https://api-platform.com/docs/core/operations/#pre... https://api-platform.com/docs/core/swagger/
annotations are used there like this

/**
     * @Route(
     *     name="book_post_publication",
     *     path="/books/{id}/publication",
     *     methods={"POST"},
     *     defaults={
     *         "_api_resource_class"=Book::class,
     *         "_api_item_operation_name"="post_publication"
     *     }
     * )
     */

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question