Open rixvet opened 1 year ago
Also looks like there is a standard for this: https://datatracker.ietf.org/doc/html/rfc5988
The current status of this item:
In the current dev branch there is some pagination, however the server will fetch all data even if you just request two pages.
Please see: https://github.com/hashtopolis/server/blob/dev/src/inc/apiv2/common/AbstractModelAPI.class.php#L298
In the feature branch of this issue this already has been partially implemented: https://github.com/hashtopolis/server/blob/feature/1018-convert-homebrew-apiv2-interface-to-jsonapi-standard/src/inc/apiv2/common/AbstractModelAPI.class.php#L345
This need to be synced with the current dev branch. There needs to be some implementation of 'start-from-filter' in the SQL queries.
Beside the pagination, fetching of related object should also be done with the json-api standard (include).
Summary:
Attached branch: https://github.com/hashtopolis/server/blob/feature/1018-convert-homebrew-apiv2-interface-to-jsonapi-standard
I have been looking into this and it seems to me that all these points have already been implemented in this feature branch. The only thing that I found that is not according to the JSON API specification is the pagination. For example in the feature branch you can paginate with the following query: http://localhost:8080/api/v2/ui/tasks?page[after]=1&page[size]=2. But according to the spec this should be done as follows: http://localhost:8080/api/v2/ui/tasks?page[offset]=1&page[limit]=2. But this should be a relative easy fix. I could try to fix that and merge it with the dev branch if needed?
Re-write APIv2 interface to adhere to JSON:API 1.1 standard (https://jsonapi.org/) this will future-proof the APIv2 for new features and allow for more compact response.
Related to: