Skip to content

Commit 3d9c2d7

Browse files
Feature | Extend Swagger Coverage for controller OAuth2LegalDocumentsApiController (#388)
* feat: Extend Swagger Coverage for controller OAuth2LegalDocumentsApiController.php * fix: Change "namespace" word positioning --------- Co-authored-by: sebastian marcet <smarcet@gmail.com>
1 parent 83f563b commit 3d9c2d7

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

app/Http/Controllers/Apis/Protected/Main/OAuth2LegalDocumentsApiController.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<?php namespace App\Http\Controllers;
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
25
/**
36
* Copyright 2021 OpenStack Foundation
47
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,11 +15,13 @@
1215
* limitations under the License.
1316
**/
1417
use App\Models\Foundation\Main\Repositories\ILegalDocumentRepository;
18+
use Illuminate\Http\Response;
1519
use Illuminate\Support\Facades\Log;
1620
use models\exceptions\EntityNotFoundException;
1721
use models\exceptions\ValidationException;
1822
use models\oauth2\IResourceServerContext;
1923
use ModelSerializers\SerializerRegistry;
24+
use OpenApi\Attributes as OA;
2025
use Exception;
2126
/**
2227
* Class OAuth2LegalDocumentsApiController
@@ -39,6 +44,37 @@ public function __construct
3944
$this->repository = $repository;
4045
}
4146

47+
// OpenAPI Documentation
48+
49+
#[OA\Get(
50+
path: '/api/public/v1/legal-documents/{id}',
51+
summary: 'Get a legal document by ID or slug',
52+
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.',
53+
tags: ['Legal Documents'],
54+
parameters: [
55+
new OA\Parameter(
56+
name: 'id',
57+
in: 'path',
58+
required: true,
59+
description: 'Legal document ID (numeric) or slug (string)',
60+
schema: new OA\Schema(
61+
type: 'string',
62+
example: 'privacy-policy'
63+
)
64+
),
65+
],
66+
responses: [
67+
new OA\Response(
68+
response: 200,
69+
description: 'Legal document retrieved successfully',
70+
content: new OA\JsonContent(ref: '#/components/schemas/LegalDocument')
71+
),
72+
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Legal document not found"),
73+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
74+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
75+
]
76+
)]
77+
4278
/**
4379
* @param $id
4480
* @return \Illuminate\Http\JsonResponse|mixed
@@ -71,4 +107,4 @@ public function getById($id){
71107
return $this->error500($ex);
72108
}
73109
}
74-
}
110+
}

app/Swagger/schemas.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,21 @@ class PaginatedCSVRSVPInvitationsResponseSchema {}
120120
new OA\Property(property: 'event', ref: '#/components/schemas/SummitEvent'),
121121
]
122122
)]
123-
class RSVPInvitationSchema {}
123+
class RSVPInvitationSchema {}curl 'https://purchases-api.dev.fnopen.com/api/v1/summits/63/sponsors/359/carts/current/forms?access_token=zA4BHSUmTlR5cvK0x2w52yyO2NeSTQwS_aRm-yFTcYxQWBEHQNO5WhXH9Vmmk9uCBuqHpiOaki0K4sAoOSIAUUciHDpz0kITLXxiQcqlRZeIuA75pLMfxyzKBCGH6SxB' \
124+
-H 'accept: */*' \
125+
-H 'accept-language: es-AR,es;q=0.9,en-US;q=0.8,en;q=0.7' \
126+
-H 'content-type: application/json' \
127+
-H 'origin: https://localhost:8000' \
128+
-H 'priority: u=1, i' \
129+
-H 'referer: https://localhost:8000/' \
130+
-H 'sec-ch-ua: "Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"' \
131+
-H 'sec-ch-ua-mobile: ?0' \
132+
-H 'sec-ch-ua-platform: "Linux"' \
133+
-H 'sec-fetch-dest: empty' \
134+
-H 'sec-fetch-mode: cors' \
135+
-H 'sec-fetch-site: cross-site' \
136+
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36' \
137+
--data-raw '{"form_id":"19","addon_id":"none","items":[{"form_item_id":10,"meta_fields":[{"type_id":61,"class_field":"Item","current_value":""},{"type_id":62,"class_field":"Item","current_value":false},{"type_id":40,"class_field":"Form","current_value":"tst1"},{"type_id":41,"class_field":"Form","current_value":false},{"type_id":42,"class_field":"Form","current_value":[46]},{"type_id":43,"class_field":"Form","current_value":48},{"type_id":44,"class_field":"Form","current_value":1},{"type_id":45,"class_field":"Form","current_value":1},{"type_id":46,"class_field":"Form","current_value":"2025-11-14T08:00:00.000Z"}],"notes":"a note"},{"form_item_id":11,"meta_fields":[{"type_id":63,"class_field":"Item","current_value":""},{"type_id":64,"class_field":"Item","current_value":false},{"type_id":40,"class_field":"Form","current_value":"tst2"},{"type_id":41,"class_field":"Form","current_value":true},{"type_id":42,"class_field":"Form","current_value":[47]},{"type_id":43,"class_field":"Form","current_value":49},{"type_id":44,"class_field":"Form","current_value":1},{"type_id":45,"class_field":"Form","current_value":1},{"type_id":46,"class_field":"Form","current_value":"2025-11-14T20:00:00.000Z"}],"notes":"note 2"}]}'
124138

125139

126140
#[OA\Schema(
@@ -351,6 +365,20 @@ class RSVPUpdateRequestSchema_{
351365
)]
352366
class RSVPAdminAddRequestSchema {}
353367

368+
// Legal Documents
369+
370+
#[OA\Schema(
371+
schema: 'LegalDocument',
372+
type: 'object',
373+
properties: [
374+
new OA\Property(property: 'id', type: 'integer', example: 1),
375+
new OA\Property(property: 'title', type: 'string', example: 'Privacy Policy'),
376+
new OA\Property(property: 'slug', type: 'string', example: 'privacy-policy'),
377+
new OA\Property(property: 'content', type: 'string', example: 'This privacy policy describes how we handle your data...'),
378+
]
379+
)]
380+
class LegalDocumentSchema {}
381+
354382
#[OA\Schema(
355383
schema: 'ChunkedFileUploadProgressResponse',
356384
type: 'object',

0 commit comments

Comments
 (0)