feat: add Swagger integration with OpenAPI annotations and endpoints
All checks were successful
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 4m0s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 4m11s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 4m22s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 4m42s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 4m27s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m55s

This commit is contained in:
2025-12-01 10:21:04 -05:00
parent cd49507140
commit 99493d4264
10 changed files with 546 additions and 145 deletions

View File

@@ -8,6 +8,7 @@ use Nyholm\Psr7\ServerRequest;
use Psr\Http\Message\ResponseInterface;
use Siteworxpro\App\Attributes\Guards;
use Siteworxpro\App\Http\JsonResponseFactory;
use OpenApi\Attributes as OA;
/**
* Class IndexController
@@ -24,6 +25,15 @@ class IndexController extends Controller
#[Guards\Jwt]
#[Guards\Scope(['get.index', 'status.check'])]
#[Guards\RequireAllScopes]
#[OA\Get(path: '/')]
#[OA\Response(
response: '200',
description: 'An Example Response',
content: new OA\JsonContent(properties: [
new OA\Property('status_code', type: 'integer'),
new OA\Property('message', type: 'string'),
])
)]
public function get(ServerRequest $request): ResponseInterface
{
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);
@@ -34,6 +44,17 @@ class IndexController extends Controller
*/
#[Guards\Jwt]
#[Guards\Scope(['post.index'])]
#[OA\Post(path: '/')]
#[OA\Response(
response: '200',
description: 'An Example Response',
content: new OA\JsonContent(
properties: [
new OA\Property('status_code', type: 'integer'),
new OA\Property('message', type: 'string'),
]
)
)]
public function post(ServerRequest $request): ResponseInterface
{
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);