Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing controller method reported for abstract methods #91

Closed
nickvergessen opened this issue Feb 2, 2024 · 1 comment
Closed

Missing controller method reported for abstract methods #91

nickvergessen opened this issue Feb 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@nickvergessen
Copy link
Member

I tried to add OpenAPI docs for the workflowengine by migrating away from "ocs-resources":

diff --git a/apps/workflowengine/appinfo/routes.php b/apps/workflowengine/appinfo/routes.php
index b5436e86daa..97fa4a2020d 100644
--- a/apps/workflowengine/appinfo/routes.php
+++ b/apps/workflowengine/appinfo/routes.php
@@ -27,8 +27,17 @@ return [
        'routes' => [
                ['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'],
        ],
-       'ocs-resources' => [
-               'global_workflows' => ['url' => '/api/v1/workflows/global'],
-               'user_workflows' => ['url' => '/api/v1/workflows/user'],
+       'ocs' => [
+               ['name' => 'global_workflows#index', 'verb' => 'GET', 'url' => '/api/v1/workflows/global'],
+               ['name' => 'global_workflows#show', 'verb' => 'GET', 'url' => '/api/v1/workflows/global/{operationClass}', 'requirements' => ['operationClass' => '[a-zA-Z0-9\\]+']],
+               ['name' => 'global_workflows#create', 'verb' => 'POST', 'url' => '/api/v1/workflows/global'],
+               ['name' => 'global_workflows#update', 'verb' => 'PUT', 'url' => '/api/v1/workflows/global/{id}', 'requirements' => ['id' => '\d+']],
+               ['name' => 'global_workflows#destroy', 'verb' => 'DELETE', 'url' => '/api/v1/workflows/global/{id}', 'requirements' => ['id' => '\d+']],
+
+               ['name' => 'user_workflows#index', 'verb' => 'GET', 'url' => '/api/v1/workflows/user'],
+               ['name' => 'user_workflows#show', 'verb' => 'GET', 'url' => '/api/v1/workflows/user/{operationClass}', 'requirements' => ['operationClass' => '[a-zA-Z0-9\\]+']],
+               ['name' => 'user_workflows#create', 'verb' => 'POST', 'url' => '/api/v1/workflows/user'],
+               ['name' => 'user_workflows#update', 'verb' => 'PUT', 'url' => '/api/v1/workflows/user/{id}', 'requirements' => ['id' => '\d+']],
+               ['name' => 'user_workflows#destroy', 'verb' => 'DELETE', 'url' => '/api/v1/workflows/user/{id}', 'requirements' => ['id' => '\d+']],
        ],
 ];
diff --git a/apps/workflowengine/lib/Controller/AWorkflowController.php b/apps/workflowengine/lib/Controller/AWorkflowController.php
index 2c3655743ff..f085ffb3e8c 100644
--- a/apps/workflowengine/lib/Controller/AWorkflowController.php
+++ b/apps/workflowengine/lib/Controller/AWorkflowController.php
@@ -86,11 +86,11 @@ abstract class AWorkflowController extends OCSController {
         *
         * @throws OCSForbiddenException
         */
-       public function show(string $id): DataResponse {
+       public function show(string $operationClass): DataResponse {
                $context = $this->getScopeContext();
 
                // The ID corresponds to a class name
-               $operations = $this->manager->getOperations($id, $context);
+               $operations = $this->manager->getOperations($operationClass, $context);
 
                foreach ($operations as &$operation) {
                        $operation = $this->manager->formatOperation($operation);
diff --git a/apps/workflowengine/lib/Controller/UserWorkflowsController.php b/apps/workflowengine/lib/Controller/UserWorkflowsController.php
index 02c52deb9c7..ceba686115b 100644
--- a/apps/workflowengine/lib/Controller/UserWorkflowsController.php
+++ b/apps/workflowengine/lib/Controller/UserWorkflowsController.php
@@ -76,8 +76,8 @@ class UserWorkflowsController extends AWorkflowController {
         * Example: curl -u joann -H "OCS-APIREQUEST: true" "http://my.nc.srvr/ocs/v2.php/apps/workflowengine/api/v1/workflows/user/OCA\\Workflow_DocToPdf\\Operation?format=json"
         * @throws OCSForbiddenException
         */
-       public function show(string $id): DataResponse {
-               return parent::show($id);
+       public function show(string $operationClass): DataResponse {
+               return parent::show($operationClass);
        }
 
        /**

but the abstract methods seem to not be taken into consideration.

Ignoring the global one

diff --git a/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php b/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php
index 8778f85365f..5c6c0f70690 100644
--- a/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php
+++ b/apps/workflowengine/lib/Controller/GlobalWorkflowsController.php
@@ -29,6 +29,9 @@ namespace OCA\WorkflowEngine\Controller;
 use OCA\WorkflowEngine\Helper\ScopeContext;
 use OCP\WorkflowEngine\IManager;
 
+/**
+ * @IgnoreOpenAPI
+ */
 class GlobalWorkflowsController extends AWorkflowController {
 
        /** @var ScopeContext */

Shows normal errors for the user workflows as that one "wraps" all the methods:
https://github.com/nextcloud/server/blob/d8ffbed2c268dde5ef73a1a617bc3627946d835d/apps/workflowengine/lib/Controller/UserWorkflowsController.php#L69

@nickvergessen nickvergessen added the bug Something isn't working label Feb 2, 2024
@provokateurin
Copy link
Member

I'll close this one in favor of #28 because it is literally the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants