Migrate routes to #[FrontpageRoute] attributes and add OpenAPI support#3623
Migrate routes to #[FrontpageRoute] attributes and add OpenAPI support#3623
Conversation
…add #[OpenAPI] support Co-authored-by: Grotax <5429298+Grotax@users.noreply.github.com>
Co-authored-by: Grotax <5429298+Grotax@users.noreply.github.com>
b88d3d2 to
0ee1ed8
Compare
|
@Grotax when I last checked the api route attribute has a prefix, so it's not compatible afaik. |
|
@copilot The integration tests and the updater tests have failed which shows us that that at least the API routes do not work. The tests work by requesting an app password and then using basic auth on the route they are testing. |
…onse for error() Co-authored-by: Grotax <5429298+Grotax@users.noreply.github.com>
Fixed in d73223d. Two issues were causing the failures:
Confirmed — |
|
True, just found out. It uses Which would of course be a breaking change for the current API that is not even worth considering. An alternative would be of course to extend the V2 API spec by saying it will use OCS and then to leave the old stuff as it is while adding new controllers for V2, eventually deprecating the old API. But its not an easy task either I guess. The thing is with AI we now have more developer power than we ever had for News and requested features like Tags become more reachable, I just would like the core architecture to be more up to date. What do you think about the V2 approach with OCS? |
|
Ah another point to consider of course is the regular request to use some "standard" API spec for the API like GoogleReader or others but I looked into those and they are not well defined and since we work as nextcloud app we have restrictions when it comes to authentication. |
I don't know if anyone uses it, but I guess we could. Maybe we can even keep them side by side for a while. |
Routes were split across
routes.phpand controller methods, requiring duplicate declarations and making the API hard to document. Moves all route declarations onto controller methods using PHP attributes, and adds OpenAPI metadata.Summary
Route migration
/api/*) decorated with#[FrontpageRoute]on the corresponding controller methods inApiController,UtilityApiController,FolderApiController,FeedApiController,ItemApiController,FaviconApiController, andFolderApiV2Controller#[FrontpageRoute]onPageController,FolderController,FeedController,ItemController,ExportController,ImportController, andFaviconController#[ApiRoute]is for OCS routes (accessed at/ocs/v2.php/apps/...) and is not compatible with the News REST API which uses regular app routes at/apps/news/api/...;#[FrontpageRoute]is correct for all News routesappinfo/routes.phptrimmed to only unmigrated entries: admin routes (noAdminControllerclass yet),page#manifest(nomanifest()method onPageController), and the wildcard CORS preflight route (utility_api#preflighted_cors, since#[FrontpageRoute]does not auto-handle OPTIONS)#[FrontpageRoute]withpostfixon the same methodOpenAPI support
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)]added at class level to all API controllersFolderApiV2Controllermethods given typedDataResponse<200, ...>|DataResponse<404, ...>return types for spec generationApiPayloadTrait::responseV2()and the V2-specific error helpers inJSONHttpErrorTraitchanged fromJSONResponsetoDataResponse; the generalerror()helper keeps returningJSONResponsefor compatibility with existing frontend controllersChecklist
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.