diff --git a/app/Http/Controllers/Api/ServersController.php b/app/Http/Controllers/Api/ServersController.php index 3f0f4d2c3..a83e6ed66 100644 --- a/app/Http/Controllers/Api/ServersController.php +++ b/app/Http/Controllers/Api/ServersController.php @@ -567,6 +567,9 @@ public function create_server(Request $request) ['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.', @@ -596,8 +599,7 @@ public function create_server(Request $request) new OA\MediaType( mediaType: 'application/json', schema: new OA\Schema( - type: 'array', - items: new OA\Items(ref: '#/components/schemas/Server') + ref: '#/components/schemas/Server' ) ), ]), @@ -678,9 +680,7 @@ public function update_server(Request $request) ValidateServer::dispatch($server); } - return response()->json([ - - ])->setStatusCode(201); + return response()->json(serializeApiResponse($server))->setStatusCode(201); } #[OA\Delete( diff --git a/app/Models/Server.php b/app/Models/Server.php index e6e2ffbe1..27c2b9b99 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -42,8 +42,7 @@ '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'], ] )] @@ -814,7 +813,7 @@ public function port(): Attribute { return Attribute::make( get: function ($value) { - return preg_replace('/[^0-9]/', '', $value); + return (int) preg_replace('/[^0-9]/', '', $value); } ); } 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 @@ '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 cdcd47f40..2ec218438 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" @@ -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, @@ -5451,10 +5462,7 @@ "content": { "application\/json": { "schema": { - "type": "array", - "items": { - "$ref": "#\/components\/schemas\/Server" - } + "$ref": "#\/components\/schemas\/Server" } } } @@ -7441,13 +7449,8 @@ "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" @@ -7556,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 2b1ece41c..2a22c730c 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 @@ -3713,9 +3721,7 @@ paths: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/Server' + $ref: '#/components/schemas/Server' '401': $ref: '#/components/responses/401' '400': @@ -4967,12 +4973,8 @@ 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 ServerSetting: description: 'Server Settings model' @@ -5045,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'