pkp / pkp-lib

The library used by PKP's applications OJS, OMP and OPS, open source software for scholarly publishing.
https://pkp.sfu.ca
GNU General Public License v3.0
298 stars 443 forks source link

Allow plugins to add/modify API endpoints of existing entity #9434

Open touhidurabir opened 9 months ago

touhidurabir commented 9 months ago

Describe the problem With the merge of https://github.com/pkp/pkp-lib/issues/7698 in the main branch(Future 3.5.0 LTS) , slim routing toolset set has been removed as one of the core dependency and the API implementation moved to laravel routing toolset completely . This has made the previously applied hook APIHandler::endpoints to tap into and modify/add/update obsolete and removed .

Describe the proposal Possible enhancement is to bring back the hook similar kind of hook APIHandler::endpoints to allow dynamic insertion of API routes on run time using laravel router which oversees the each routing process . This will be helpful for plugins to inject routes to any existing routes collection .

What application are you using? OJS, OMP or OPS version main

PRs pkp-lib --> https://github.com/pkp/pkp-lib/pull/9451 ojs --> https://github.com/pkp/ojs/pull/4081 [TEST ONLY] omp --> https://github.com/pkp/omp/pull/1625 [TEST ONLY] ops --> https://github.com/pkp/ops/pull/724 [TEST ONLY]

An example plugin to demonstrate the usage of plugin level api implementation at https://github.com/touhidurabir/apiExample

Additional Information Feature request : https://forum.pkp.sfu.ca/t/create-custom-api-handler-ver-3-5/89101/4

touhidurabir commented 9 months ago

@asmecher can you please preview the PR at https://github.com/pkp/pkp-lib/issues/9434#issue-1953801910

asmecher commented 8 months ago

Thanks, @touhidurabir! I added a review: https://github.com/pkp/pkp-lib/pull/9451#pullrequestreview-1723622313

touhidurabir commented 3 weeks ago

@asmecher can you take a look at the PRs at https://github.com/pkp/pkp-lib/issues/9434#issue-1953801910

asmecher commented 3 weeks ago

@touhidurabir, it's promising, but it feels like the APIRouter is trying to be two things at once. I wonder if maybe it's worth coming up with a PluginAPIRouter class that lives parallel to APIRouter? That would keep APIRouter from having to accommodate two distinctly different URL patterns.