2024-07-05 14:08:01 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
|
|
use OpenApi\Attributes as OA;
|
|
|
|
|
|
2026-02-16 01:54:19 +00:00
|
|
|
// MapleDeploy branding: API documentation
|
|
|
|
|
#[OA\Info(title: 'MapleDeploy', version: '0.1')]
|
|
|
|
|
#[OA\Server(url: '/api/v1', description: 'MapleDeploy API. Powered by Coolify.')]
|
2024-07-06 12:34:15 +00:00
|
|
|
#[OA\SecurityScheme(
|
|
|
|
|
type: 'http',
|
|
|
|
|
scheme: 'bearer',
|
|
|
|
|
securityScheme: 'bearerAuth',
|
|
|
|
|
description: 'Go to `Keys & Tokens` / `API tokens` and create a new token. Use the token as the bearer token.')]
|
|
|
|
|
#[OA\Components(
|
|
|
|
|
responses: [
|
|
|
|
|
new OA\Response(
|
2024-07-09 08:45:10 +00:00
|
|
|
response: 400,
|
|
|
|
|
description: 'Invalid token.',
|
2024-07-06 12:34:15 +00:00
|
|
|
content: new OA\JsonContent(
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: [
|
2024-07-09 08:45:10 +00:00
|
|
|
new OA\Property(property: 'message', type: 'string', example: 'Invalid token.'),
|
2024-07-06 12:34:15 +00:00
|
|
|
]
|
|
|
|
|
)),
|
|
|
|
|
new OA\Response(
|
2024-07-09 08:45:10 +00:00
|
|
|
response: 401,
|
|
|
|
|
description: 'Unauthenticated.',
|
2024-07-06 12:34:15 +00:00
|
|
|
content: new OA\JsonContent(
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: [
|
2024-07-09 08:45:10 +00:00
|
|
|
new OA\Property(property: 'message', type: 'string', example: 'Unauthenticated.'),
|
2024-07-06 12:34:15 +00:00
|
|
|
]
|
|
|
|
|
)),
|
|
|
|
|
new OA\Response(
|
|
|
|
|
response: 404,
|
|
|
|
|
description: 'Resource not found.',
|
|
|
|
|
content: new OA\JsonContent(
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: [
|
2024-07-09 08:45:10 +00:00
|
|
|
new OA\Property(property: 'message', type: 'string', example: 'Resource not found.'),
|
2024-07-06 12:34:15 +00:00
|
|
|
]
|
|
|
|
|
)),
|
2025-10-12 12:20:45 +00:00
|
|
|
new OA\Response(
|
|
|
|
|
response: 422,
|
|
|
|
|
description: 'Validation error.',
|
|
|
|
|
content: new OA\JsonContent(
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: [
|
|
|
|
|
new OA\Property(property: 'message', type: 'string', example: 'Validation error.'),
|
|
|
|
|
new OA\Property(
|
|
|
|
|
property: 'errors',
|
|
|
|
|
type: 'object',
|
|
|
|
|
additionalProperties: new OA\AdditionalProperties(
|
|
|
|
|
type: 'array',
|
|
|
|
|
items: new OA\Items(type: 'string')
|
|
|
|
|
),
|
|
|
|
|
example: [
|
|
|
|
|
'name' => ['The name field is required.'],
|
|
|
|
|
'api_url' => ['The api url field is required.', 'The api url format is invalid.'],
|
|
|
|
|
]
|
|
|
|
|
),
|
|
|
|
|
]
|
|
|
|
|
)),
|
2025-12-11 11:12:43 +00:00
|
|
|
new OA\Response(
|
|
|
|
|
response: 429,
|
|
|
|
|
description: 'Rate limit exceeded.',
|
|
|
|
|
headers: [
|
|
|
|
|
new OA\Header(
|
|
|
|
|
header: 'Retry-After',
|
|
|
|
|
description: 'Number of seconds to wait before retrying.',
|
|
|
|
|
schema: new OA\Schema(type: 'integer', example: 60)
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
content: new OA\JsonContent(
|
|
|
|
|
type: 'object',
|
|
|
|
|
properties: [
|
|
|
|
|
new OA\Property(property: 'message', type: 'string', example: 'Rate limit exceeded. Please try again later.'),
|
|
|
|
|
]
|
|
|
|
|
)),
|
2024-07-06 12:34:15 +00:00
|
|
|
],
|
|
|
|
|
)]
|
2024-07-05 14:08:01 +00:00
|
|
|
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.
|
|
|
|
|
}
|