From 1ccf443691da1982654dca195b2cfcb0dfb80c18 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sat, 27 Sep 2025 22:44:16 +0300 Subject: [PATCH] fix: update settings PUT endpoint path --- .lintstagedrc.cjs | 2 +- lib/Controller/ApiController.php | 2 +- openapi-administration.json | 308 +++++++++++++++---------------- openapi-full.json | 74 ++++---- src/AdminSettings.vue | 2 +- 5 files changed, 192 insertions(+), 196 deletions(-) diff --git a/.lintstagedrc.cjs b/.lintstagedrc.cjs index 68d52a1..098b42c 100644 --- a/.lintstagedrc.cjs +++ b/.lintstagedrc.cjs @@ -3,5 +3,5 @@ module.exports = { 'src/**/*.{scss,vue,ts,md,json}': ['prettier --write'], '*.md': ['prettier --write'], '*.php': [() => 'make php-cs-fixer'], - '*Controller.php': [() => 'make openapi', () => 'git add openapi.json'], + '*Controller.php': [() => 'make openapi', () => 'git add openapi*.json'], } diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 1721f6b..c12e6cf 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -129,7 +129,7 @@ class ApiController extends OCSController { * * 200: Data returned */ - #[ApiRoute(verb: 'PUT', url: '/api/cron')] + #[ApiRoute(verb: 'PUT', url: '/api/settings')] public function updateSettings(mixed $data): DataResponse { $interval = $data['interval']; $this->config->setValueInt(AppInfo\Application::APP_ID, 'cron_interval', $interval); diff --git a/openapi-administration.json b/openapi-administration.json index 16c1a04..e669b07 100644 --- a/openapi-administration.json +++ b/openapi-administration.json @@ -178,6 +178,159 @@ } } } + }, + "put": { + "operationId": "api-update-settings", + "summary": "Update auto currency settings", + "description": "This endpoint requires admin access", + "tags": [ + "api" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "type": "object", + "description": "Data to update", + "required": [ + "interval" + ], + "properties": { + "interval": { + "type": "integer", + "format": "int64" + } + } + } + } + } + } + } + }, + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Data returned", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "object", + "required": [ + "status" + ], + "properties": { + "status": { + "type": "string", + "minLength": 1 + } + } + } + } + } + } + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "403": { + "description": "Logged in account must be an admin", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } } }, "/ocs/v2.php/apps/autocurrency/api/cron/run": { @@ -306,161 +459,6 @@ } } } - }, - "/ocs/v2.php/apps/autocurrency/api/cron": { - "put": { - "operationId": "api-update-settings", - "summary": "Update auto currency settings", - "description": "This endpoint requires admin access", - "tags": [ - "api" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "data": { - "type": "object", - "description": "Data to update", - "required": [ - "interval" - ], - "properties": { - "interval": { - "type": "integer", - "format": "int64" - } - } - } - } - } - } - } - }, - "parameters": [ - { - "name": "OCS-APIRequest", - "in": "header", - "description": "Required to be true for the API request to pass", - "required": true, - "schema": { - "type": "boolean", - "default": true - } - } - ], - "responses": { - "200": { - "description": "Data returned", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": { - "type": "object", - "required": [ - "status" - ], - "properties": { - "status": { - "type": "string", - "minLength": 1 - } - } - } - } - } - } - } - } - } - }, - "401": { - "description": "Current user is not logged in", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - }, - "403": { - "description": "Logged in account must be an admin", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - } - } - } } }, "tags": [] diff --git a/openapi-full.json b/openapi-full.json index a0b200e..3917976 100644 --- a/openapi-full.json +++ b/openapi-full.json @@ -178,12 +178,10 @@ } } } - } - }, - "/ocs/v2.php/apps/autocurrency/api/cron/run": { - "post": { - "operationId": "api-run-cron", - "summary": "Run cron immediately", + }, + "put": { + "operationId": "api-update-settings", + "summary": "Update auto currency settings", "description": "This endpoint requires admin access", "tags": [ "api" @@ -196,6 +194,34 @@ "basic_auth": [] } ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "data" + ], + "properties": { + "data": { + "type": "object", + "description": "Data to update", + "required": [ + "interval" + ], + "properties": { + "interval": { + "type": "integer", + "format": "int64" + } + } + } + } + } + } + } + }, "parameters": [ { "name": "OCS-APIRequest", @@ -307,10 +333,10 @@ } } }, - "/ocs/v2.php/apps/autocurrency/api/cron": { - "put": { - "operationId": "api-update-settings", - "summary": "Update auto currency settings", + "/ocs/v2.php/apps/autocurrency/api/cron/run": { + "post": { + "operationId": "api-run-cron", + "summary": "Run cron immediately", "description": "This endpoint requires admin access", "tags": [ "api" @@ -323,34 +349,6 @@ "basic_auth": [] } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "data" - ], - "properties": { - "data": { - "type": "object", - "description": "Data to update", - "required": [ - "interval" - ], - "properties": { - "interval": { - "type": "integer", - "format": "int64" - } - } - } - } - } - } - } - }, "parameters": [ { "name": "OCS-APIRequest", diff --git a/src/AdminSettings.vue b/src/AdminSettings.vue index caf38e4..0baa93a 100644 --- a/src/AdminSettings.vue +++ b/src/AdminSettings.vue @@ -127,7 +127,7 @@ export default { try { this.loading = true const interval = this.getIntervalByLabel(this.interval)?.value ?? 24 - const resp = await ocs.put('/cron', { data: { interval } }) + const resp = await ocs.put('/settings', { data: { interval } }) const data = resp.data this.loading = false console.debug('[DEBUG] Auto Currency settings saved', data)