feat: implement GenericResponse class and update controllers to use it for consistent JSON responses
All checks were successful
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m51s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m56s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m50s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 2m52s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m1s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m21s

This commit is contained in:
2025-12-01 11:16:59 -05:00
parent 375ba1b4d5
commit af2f164546
3 changed files with 4 additions and 4 deletions

View File

@@ -37,7 +37,7 @@ class IndexController extends Controller
#[UnauthorizedResponse]
public function get(ServerRequest $request): ResponseInterface
{
return JsonResponseFactory::createJsonResponse(['message' => 'Server is running']);
return JsonResponseFactory::createJsonResponse(new GenericResponse('Server is running'));
}
/**

View File

@@ -16,4 +16,4 @@ class TokenSecurity extends OA\SecurityScheme
scheme: 'bearer'
);
}
}
}

View File

@@ -20,7 +20,7 @@ class IndexControllerTest extends AbstractController
$response = $controller->get($this->getMockRequest());
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('{"status_code":200,"message":"Server is running"}', (string)$response->getBody());
$this->assertEquals('{"message":"Server is running","status_code":200}', (string)$response->getBody());
}
/**
@@ -35,6 +35,6 @@ class IndexControllerTest extends AbstractController
$response = $controller->post($this->getMockRequest());
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('{"status_code":200,"message":"Server is running"}', (string)$response->getBody());
$this->assertEquals('{"message":"POST request received","status_code":200}', (string)$response->getBody());
}
}