fix: update settings PUT endpoint path

This commit is contained in:
2025-09-27 22:44:16 +03:00
parent 80b3ea01e9
commit 1ccf443691
5 changed files with 192 additions and 196 deletions

View File

@@ -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'],
}

View File

@@ -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);

View File

@@ -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": []

View File

@@ -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",

View File

@@ -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)