From 4a45de564603021f237cf0b8f953afce945195c4 Mon Sep 17 00:00:00 2001 From: SierraJC <7351311+SierraJC@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:04:51 +1100 Subject: [PATCH 1/6] fix: empty server API response --- app/Http/Controllers/Api/ServersController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/ServersController.php b/app/Http/Controllers/Api/ServersController.php index 3f0f4d2c3..0dcd63a1c 100644 --- a/app/Http/Controllers/Api/ServersController.php +++ b/app/Http/Controllers/Api/ServersController.php @@ -678,9 +678,7 @@ class ServersController extends Controller ValidateServer::dispatch($server); } - return response()->json([ - - ])->setStatusCode(201); + return response()->json(serializeApiResponse($server))->setStatusCode(201); } #[OA\Delete( From 379045c8356c455e70ecc58d90331e44694e0cdb Mon Sep 17 00:00:00 2001 From: SierraJC <7351311+SierraJC@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:17:38 +1100 Subject: [PATCH 2/6] fix: incorrect server API patch response --- app/Http/Controllers/Api/ServersController.php | 3 +-- openapi.json | 7 ++----- openapi.yaml | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/Http/Controllers/Api/ServersController.php b/app/Http/Controllers/Api/ServersController.php index 0dcd63a1c..f5b20c84a 100644 --- a/app/Http/Controllers/Api/ServersController.php +++ b/app/Http/Controllers/Api/ServersController.php @@ -596,8 +596,7 @@ class ServersController extends Controller new OA\MediaType( mediaType: 'application/json', schema: new OA\Schema( - type: 'array', - items: new OA\Items(ref: '#/components/schemas/Server') + ref: '#/components/schemas/Server' ) ), ]), diff --git a/openapi.json b/openapi.json index cdcd47f40..9c497cb12 100644 --- a/openapi.json +++ b/openapi.json @@ -1,5 +1,5 @@ { - "openapi": "3.0.0", + "openapi": "3.1.0", "info": { "title": "Coolify", "version": "0.1" @@ -5451,10 +5451,7 @@ "content": { "application\/json": { "schema": { - "type": "array", - "items": { - "$ref": "#\/components\/schemas\/Server" - } + "$ref": "#\/components\/schemas\/Server" } } } diff --git a/openapi.yaml b/openapi.yaml index 2b1ece41c..2b4e140d2 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3713,9 +3713,7 @@ paths: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Server' + $ref: '#/components/schemas/Server' '401': $ref: '#/components/responses/401' '400': From fead884809cfceb95439a5c7e5c1e9ef4d304a6a Mon Sep 17 00:00:00 2001 From: SierraJC <7351311+SierraJC@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:40:22 +1100 Subject: [PATCH 3/6] fix: missing `uuid` parameter on server API patch --- app/Http/Controllers/Api/ServersController.php | 3 +++ openapi.json | 11 +++++++++++ openapi.yaml | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/app/Http/Controllers/Api/ServersController.php b/app/Http/Controllers/Api/ServersController.php index f5b20c84a..a83e6ed66 100644 --- a/app/Http/Controllers/Api/ServersController.php +++ b/app/Http/Controllers/Api/ServersController.php @@ -567,6 +567,9 @@ class ServersController extends Controller ['bearerAuth' => []], ], tags: ['Servers'], + parameters: [ + new OA\Parameter(name: 'uuid', in: 'path', required: true, description: 'Server UUID', schema: new OA\Schema(type: 'string')), + ], requestBody: new OA\RequestBody( required: true, description: 'Server updated.', diff --git a/openapi.json b/openapi.json index 9c497cb12..2b38923b2 100644 --- a/openapi.json +++ b/openapi.json @@ -5391,6 +5391,17 @@ "summary": "Update", "description": "Update Server.", "operationId": "update-server-by-uuid", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Server UUID", + "required": true, + "schema": { + "type": "string" + } + } + ], "requestBody": { "description": "Server updated.", "required": true, diff --git a/openapi.yaml b/openapi.yaml index 2b4e140d2..d56b19795 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -3671,6 +3671,14 @@ paths: summary: Update description: 'Update Server.' operationId: update-server-by-uuid + parameters: + - + name: uuid + in: path + description: 'Server UUID' + required: true + schema: + type: string requestBody: description: 'Server updated.' required: true From d6441549e8efe0646fff49f6551ac8b4a371e195 Mon Sep 17 00:00:00 2001 From: SierraJC <7351311+SierraJC@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:44:04 +1100 Subject: [PATCH 4/6] fix: missing `settings` property on servers API --- app/Models/Server.php | 1 + openapi.json | 3 +++ openapi.yaml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/Models/Server.php b/app/Models/Server.php index e6e2ffbe1..2a9e926ed 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -44,6 +44,7 @@ use Symfony\Component\Yaml\Yaml; 'swarm_cluster' => ['type' => 'string', 'description' => 'The swarm cluster configuration.'], 'delete_unused_volumes' => ['type' => 'boolean', 'description' => 'The flag to indicate if the unused volumes should be deleted.'], 'delete_unused_networks' => ['type' => 'boolean', 'description' => 'The flag to indicate if the unused networks should be deleted.'], + 'settings' => ['$ref' => '#/components/schemas/ServerSetting'], ] )] diff --git a/openapi.json b/openapi.json index 2b38923b2..479b0b9d6 100644 --- a/openapi.json +++ b/openapi.json @@ -7456,6 +7456,9 @@ "delete_unused_networks": { "type": "boolean", "description": "The flag to indicate if the unused networks should be deleted." + }, + "settings": { + "$ref": "#\/components\/schemas\/ServerSetting" } }, "type": "object" diff --git a/openapi.yaml b/openapi.yaml index d56b19795..178da5ca0 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4979,6 +4979,8 @@ components: delete_unused_networks: type: boolean description: 'The flag to indicate if the unused networks should be deleted.' + settings: + $ref: '#/components/schemas/ServerSetting' type: object ServerSetting: description: 'Server Settings model' From bbd7d8b567905195c1070fd1c831cc990b1de9e0 Mon Sep 17 00:00:00 2001 From: SierraJC <7351311+SierraJC@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:11:48 +1100 Subject: [PATCH 5/6] fix: move servers API `delete_unused_*` properties correct location from API response is in server.settings --- app/Models/Server.php | 2 -- app/Models/ServerSetting.php | 2 ++ openapi.json | 16 ++++++++-------- openapi.yaml | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index 2a9e926ed..cb9def688 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -42,8 +42,6 @@ use Symfony\Component\Yaml\Yaml; 'validation_logs' => ['type' => 'string', 'description' => 'The validation logs.'], 'log_drain_notification_sent' => ['type' => 'boolean', 'description' => 'The flag to indicate if the log drain notification has been sent.'], 'swarm_cluster' => ['type' => 'string', 'description' => 'The swarm cluster configuration.'], - 'delete_unused_volumes' => ['type' => 'boolean', 'description' => 'The flag to indicate if the unused volumes should be deleted.'], - 'delete_unused_networks' => ['type' => 'boolean', 'description' => 'The flag to indicate if the unused networks should be deleted.'], 'settings' => ['$ref' => '#/components/schemas/ServerSetting'], ] )] diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.php index fc2c5a0f4..e078372e2 100644 --- a/app/Models/ServerSetting.php +++ b/app/Models/ServerSetting.php @@ -45,6 +45,8 @@ use OpenApi\Attributes as OA; 'wildcard_domain' => ['type' => 'string'], 'created_at' => ['type' => 'string'], 'updated_at' => ['type' => 'string'], + 'delete_unused_volumes' => ['type' => 'boolean', 'description' => 'The flag to indicate if the unused volumes should be deleted.'], + 'delete_unused_networks' => ['type' => 'boolean', 'description' => 'The flag to indicate if the unused networks should be deleted.'], ] )] class ServerSetting extends Model diff --git a/openapi.json b/openapi.json index 479b0b9d6..2ec218438 100644 --- a/openapi.json +++ b/openapi.json @@ -7449,14 +7449,6 @@ "type": "string", "description": "The swarm cluster configuration." }, - "delete_unused_volumes": { - "type": "boolean", - "description": "The flag to indicate if the unused volumes should be deleted." - }, - "delete_unused_networks": { - "type": "boolean", - "description": "The flag to indicate if the unused networks should be deleted." - }, "settings": { "$ref": "#\/components\/schemas\/ServerSetting" } @@ -7567,6 +7559,14 @@ }, "updated_at": { "type": "string" + }, + "delete_unused_volumes": { + "type": "boolean", + "description": "The flag to indicate if the unused volumes should be deleted." + }, + "delete_unused_networks": { + "type": "boolean", + "description": "The flag to indicate if the unused networks should be deleted." } }, "type": "object" diff --git a/openapi.yaml b/openapi.yaml index 178da5ca0..2a22c730c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -4973,12 +4973,6 @@ components: swarm_cluster: type: string description: 'The swarm cluster configuration.' - delete_unused_volumes: - type: boolean - description: 'The flag to indicate if the unused volumes should be deleted.' - delete_unused_networks: - type: boolean - description: 'The flag to indicate if the unused networks should be deleted.' settings: $ref: '#/components/schemas/ServerSetting' type: object @@ -5053,6 +5047,12 @@ components: type: string updated_at: type: string + delete_unused_volumes: + type: boolean + description: 'The flag to indicate if the unused volumes should be deleted.' + delete_unused_networks: + type: boolean + description: 'The flag to indicate if the unused networks should be deleted.' type: object Service: description: 'Service model' From 059639eb428eaaedf126858a4a51f01f32211ae0 Mon Sep 17 00:00:00 2001 From: SierraJC <7351311+SierraJC@users.noreply.github.com> Date: Sat, 23 Nov 2024 13:12:43 +1100 Subject: [PATCH 6/6] fix: servers API returning `port` as a string -> integer --- app/Models/Server.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index cb9def688..27c2b9b99 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -813,7 +813,7 @@ $schema://$host { { return Attribute::make( get: function ($value) { - return preg_replace('/[^0-9]/', '', $value); + return (int) preg_replace('/[^0-9]/', '', $value); } ); }