Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

test openapi

Andras Bacsai88ab3851008b
diff --git a/app/Http/Controllers/Api/OpenApi.php b/app/Http/Controllers/Api/OpenApi.php
new file mode 100644
index 0000000000..0878238f04
--- /dev/null
+++ b/app/Http/Controllers/Api/OpenApi.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Http\Controllers\Api;
+
+use OpenApi\Attributes as OA;
+
+#[OA\Info(title: 'Coolify', version: '0.1')]
+#[OA\Server(url: 'https://coolify.io/api/v1')]
+#[OA\SecurityScheme(type: 'http', scheme: 'bearer', bearerFormat: 'JWT', securityScheme: 'bearerAuth')]
+class OpenApi
+{
+ // This class is used to generate OpenAPI documentation
+ // for the Coolify API. It is not a controller and does
+ // not contain any routes. It is used to define the
+ // OpenAPI metadata and security scheme for the API.
+}
diff --git a/app/Http/Controllers/Api/TeamController.php b/app/Http/Controllers/Api/TeamController.php
index 2ad18c9db1..32863aff3f 100644
--- a/app/Http/Controllers/Api/TeamController.php
+++ b/app/Http/Controllers/Api/TeamController.php
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
+use OpenApi\Attributes as OA;
class TeamController extends Controller
{
@@ -27,6 +28,9 @@ class TeamController extends Controller
return serializeApiResponse($team);
}
+ #[OA\Get(path: '/teams')]
+ #[OA\Response(response: '200', description: 'List of teams')]
+ #[OA\Response(response: '401', description: 'Unauthorized')]
public function teams(Request $request)
{
$teamId = getTeamIdFromToken();
@@ -43,6 +47,33 @@ class TeamController extends Controller
);
}
+ #[OA\Get(path: '/teams/{id}')]
+ #[OA\Response(
+ response: 401,
+ description: 'Unauthorized',
+ content: new OA\JsonContent(
+ type: 'object',
+ properties: [
+ new OA\Property(property: 'message', type: 'string', example: 'Unauthenticated.'),
+ ]
+ )
+ )]
+ #[OA\Response(response: '404', description: 'Team not found')]
+ #[OA\Parameter(name: 'id', in: 'path', required: true, description: 'Team ID', schema: new OA\Schema(type: 'integer'))]
+ // response 200 with team model
+ #[OA\Response(
+ response: 200,
+ description: 'Team model',
+ content: new OA\JsonContent(
+ type: 'object',
+ properties: [
+ new OA\Property(property: 'id', type: 'integer', example: 1),
+ new OA\Property(property: 'name', type: 'string', example: 'Team 1'),
+ new OA\Property(property: 'created_at', type: 'string', format: 'date-time', example: '2021-10-10T10:00:00Z'),
+ new OA\Property(property: 'updated_at', type: 'string', format: 'date-time', example: '2021-10-10T10:00:00Z'),
+ ]
+ )
+ )]
public function team_by_id(Request $request)
{
$id = $request->id;
diff --git a/composer.json b/composer.json
index 3603b936e4..9991931d56 100644
--- a/composer.json
+++ b/composer.json
@@ -43,7 +43,8 @@
"stripe/stripe-php": "^12.0",
"symfony/yaml": "^6.2",
"visus/cuid2": "^2.0.0",
- "yosymfony/toml": "^1.0"
+ "yosymfony/toml": "^1.0",
+ "zircote/swagger-php": "^4.10"
},
"require-dev": {
"fakerphp/faker": "^v1.21.0",
diff --git a/composer.lock b/composer.lock
index 23d7d2e132..09492fd31a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "168e351cec87acbea9c1c745b83eead2",
+ "content-hash": "ec2082fff21212c016bfd6ffd13f8249",
"packages": [
{
"name": "amphp/amp",
@@ -12348,6 +12348,87 @@
}
],
"time": "2023-05-30T22:51:52+00:00"
+ },
+ {
+ "name": "zircote/swagger-php",
+ "version": "4.10.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/zircote/swagger-php.git",
+ "reference": "ad3f913d39b2a4dfb6e59ee4babb35a6b4a2b998"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/zircote/swagger-php/zipball/ad3f913d39b2a4dfb6e59ee4babb35a6b4a2b998",
+ "reference": "ad3f913d39b2a4dfb6e59ee4babb35a6b4a2b998",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "php": ">=7.2",
+ "psr/log": "^1.1 || ^2.0 || ^3.0",
+ "symfony/deprecation-contracts": "^2 || ^3",
+ "symfony/finder": ">=2.2",
+ "symfony/yaml": ">=3.3"
+ },
+ "require-dev": {
+ "composer/package-versions-deprecated": "^1.11",
+ "doctrine/annotations": "^1.7 || ^2.0",
+ "friendsofphp/php-cs-fixer": "^2.17 || ^3.47.1",
+ "phpstan/phpstan": "^1.6",
+ "phpunit/phpunit": ">=8",
+ "vimeo/psalm": "^4.23"
+ },
+ "suggest": {
+ "doctrine/annotations": "^1.7 || ^2.0"
+ },
+ "bin": [
+ "bin/openapi"
+ ],
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "OpenApi\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Robert Allen",
+ "email": "[email protected]"
+ },
+ {
+ "name": "Bob Fanger",
+ "email": "[email protected]",
+ "homepage": "https://bfanger.nl"
+ },
+ {
+ "name": "Martin Rademacher",
+ "email": "[email protected]",
+ "homepage": "https://radebatz.net"
+ }
+ ],
+ "description": "swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations",
+ "homepage": "https://github.com/zircote/swagger-php/",
+ "keywords": [
+ "api",
+ "json",
+ "rest",
+ "service discovery"
+ ],
+ "support": {
+ "issues": "https://github.com/zircote/swagger-php/issues",
+ "source": "https://github.com/zircote/swagger-php/tree/4.10.3"
+ },
+ "time": "2024-07-04T07:53:11+00:00"
}
],
"packages-dev": [
diff --git a/openapi.yaml b/openapi.yaml
new file mode 100644
index 0000000000..f2a813c194
--- /dev/null
+++ b/openapi.yaml
@@ -0,0 +1,55 @@
+openapi: 3.0.0
+info:
+ title: Coolify
+ version: '0.1'
+servers:
+ -
+ url: 'https://coolify.io/api/v1'
+paths:
+ /teams:
+ get:
+ operationId: f9c530b5b25df9601cb87d6a58646f0a
+ responses:
+ '200':
+ description: 'List of teams'
+ '401':
+ description: Unauthorized
+ '/teams/{id}':
+ get:
+ operationId: ac57ff546c002032cef44602c46a4e76
+ parameters:
+ -
+ name: id
+ in: path
+ description: 'Team ID'
+ required: true
+ schema:
+ type: integer
+ responses:
+ '401':
+ description: Unauthorized
+ content:
+ application/json:
+ schema:
+ properties:
+ message: { type: string, example: Unauthenticated. }
+ type: object
+ '404':
+ description: 'Team not found'
+ '200':
+ description: 'Team model'
+ content:
+ application/json:
+ schema:
+ properties:
+ id: { type: integer, example: 1 }
+ name: { type: string, example: 'Team 1' }
+ created_at: { type: string, format: date-time, example: '2021-10-10T10:00:00Z' }
+ updated_at: { type: string, format: date-time, example: '2021-10-10T10:00:00Z' }
+ type: object
+components:
+ securitySchemes:
+ bearerAuth:
+ type: http
+ bearerFormat: JWT
+ scheme: bearer