AOEpeople / TYPO3_Restler

restler (PHP REST-Framework) for TYPO3
GNU General Public License v3.0
30 stars 17 forks source link

CarController: "/api/motorsport/cars" actually returns error #68

Closed rowild closed 2 years ago

rowild commented 2 years ago

First of all: It is unclear, what numbers are valid for $id in the car controller. 1, 2, 3 all return errors. (There is no way to create "Car" records; maybe because the Repositories are missing?)

Second: when calling the api in the frontend (not within the api_explorer), I would it expect to return all cars. But it does not. As a matter of fact the "/api/motorsport/cars" route REQUIRES the id – not sure if that is really correct? Or why is that? Shouldn't this route be reserved to return ALL cars?

Bildschirmfoto 2021-07-16 um 15 51 49

Thank you!

felixsemmler commented 2 years ago

At first, your issue is related to the restler_examples extension not to restler extension. I agree that the documentation does not cover all or all of the information that should be provided.

  1. question: You can use all numeric IDs you like, you will always get the same object with the id passed by url. Please check the following requests: curl -X GET --header 'Accept: application/json' 'https://pod.ddev.site/api/motorsport/cars/1' curl -X GET --header 'Accept: application/json' 'https://pod.ddev.site/api/motorsport/cars/2' curl -X GET --header 'Accept: application/json' 'https://pod.ddev.site/api/motorsport/cars/6000'

The response for this endpoint is always generated for each request. There is no persistence layer or static response defined.

  1. question: There is no endpoint for returning all cars, but I can understand your confusion. I will add an endpoint for returing a static list of all cars, to make this example more comprehensible.
felixsemmler commented 2 years ago

I released a new version of the restler_examples extension which contains a /cars endpoint. https://extensions.typo3.org/extension/restler_examples https://packagist.org/packages/aoe/restler-examples