From 091bb6764b143f753a21b8d0fc5931c53f4a4d0b Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Wed, 8 Oct 2025 14:29:35 -0300 Subject: [PATCH 1/2] feat: Extend Swagger Coverage for controller OAuth2LegalDocumentsApiController.php --- .../OAuth2LegalDocumentsApiController.php | 35 ++++++++++++++++++- app/Swagger/schemas.php | 14 ++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php b/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php index 40eaa1508..ff6e4fa72 100644 --- a/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php +++ b/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php @@ -12,11 +12,13 @@ * limitations under the License. **/ use App\Models\Foundation\Main\Repositories\ILegalDocumentRepository; +use Illuminate\Http\Response; use Illuminate\Support\Facades\Log; use models\exceptions\EntityNotFoundException; use models\exceptions\ValidationException; use models\oauth2\IResourceServerContext; use ModelSerializers\SerializerRegistry; +use OpenApi\Attributes as OA; use Exception; /** * Class OAuth2LegalDocumentsApiController @@ -39,6 +41,37 @@ public function __construct $this->repository = $repository; } + // OpenAPI Documentation + + #[OA\Get( + path: '/api/public/v1/legal-documents/{id}', + summary: 'Get a legal document by ID or slug', + description: 'Retrieves a legal document (privacy policy, terms of service, etc.) by its numeric ID or URL-friendly slug. This is a public endpoint that does not require authentication.', + tags: ['Legal Documents'], + parameters: [ + new OA\Parameter( + name: 'id', + in: 'path', + required: true, + description: 'Legal document ID (numeric) or slug (string)', + schema: new OA\Schema( + type: 'string', + example: 'privacy-policy' + ) + ), + ], + responses: [ + new OA\Response( + response: 200, + description: 'Legal document retrieved successfully', + content: new OA\JsonContent(ref: '#/components/schemas/LegalDocument') + ), + new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Legal document not found"), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"), + ] + )] + /** * @param $id * @return \Illuminate\Http\JsonResponse|mixed @@ -71,4 +104,4 @@ public function getById($id){ return $this->error500($ex); } } -} \ No newline at end of file +} diff --git a/app/Swagger/schemas.php b/app/Swagger/schemas.php index 1eff77226..0e6e41d5a 100644 --- a/app/Swagger/schemas.php +++ b/app/Swagger/schemas.php @@ -351,3 +351,17 @@ class RSVPUpdateRequestSchema_{ ] )] class RSVPAdminAddRequestSchema {} + +// Legal Documents + +#[OA\Schema( + schema: 'LegalDocument', + type: 'object', + properties: [ + new OA\Property(property: 'id', type: 'integer', example: 1), + new OA\Property(property: 'title', type: 'string', example: 'Privacy Policy'), + new OA\Property(property: 'slug', type: 'string', example: 'privacy-policy'), + new OA\Property(property: 'content', type: 'string', example: 'This privacy policy describes how we handle your data...'), + ] +)] +class LegalDocumentSchema {} From 1f58f0ec131cb022bc0978c807f5e7fa8724572c Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Tue, 14 Oct 2025 14:27:26 -0300 Subject: [PATCH 2/2] fix: Change "namespace" word positioning --- .../Protected/Main/OAuth2LegalDocumentsApiController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php b/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php index ff6e4fa72..96a3e0853 100644 --- a/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php +++ b/app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php @@ -1,4 +1,7 @@ -