Skip to content

Commit 3c1a973

Browse files
Fix | Issue on doc generation OAuth2CompaniesApiController (#472)
* feat: Extend Swagger Coverage for controller `OAuth2CompaniesApiController` * fix: Change "namespace" word positioning * fix: Add security schema * chore: Move the security schema for the controller to its own file * chore: add operationId and fix schema name * fix: main rebase conflict --------- Co-authored-by: Matias Perrone <github@matiasperrone.com>
1 parent 6f44b3f commit 3c1a973

1 file changed

Lines changed: 130 additions & 135 deletions

File tree

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

Lines changed: 130 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,135 @@ public function __construct
6868
$this->service = $service;
6969
}
7070

71+
#[OA\Get(
72+
path: "/api/v1/companies",
73+
operationId: "getAllCompanies",
74+
summary: "Get all companies",
75+
description: "Returns a paginated list of companies. Allows ordering, filtering and pagination.",
76+
security: [
77+
[
78+
"companies_oauth2" => [
79+
CompanyScopes::Read,
80+
SummitScopes::ReadSummitData,
81+
SummitScopes::ReadAllSummitData,
82+
]
83+
]
84+
],
85+
tags: ["Companies"],
86+
parameters: [
87+
new OA\Parameter(
88+
name: 'page',
89+
in: 'query',
90+
required: false,
91+
schema: new OA\Schema(type: 'integer'),
92+
description: 'The page number'
93+
),
94+
new OA\Parameter(
95+
name: 'per_page',
96+
in: 'query',
97+
required: false,
98+
schema: new OA\Schema(type: 'integer'),
99+
description: 'The number of items per page',
100+
),
101+
new OA\Parameter(
102+
name: "filter[]",
103+
in: "query",
104+
required: false,
105+
description: "Filter companies. Available filters: name (=@, ==, @@), member_level (=@, ==, @@), display_on_site (==)",
106+
schema: new OA\Schema(type: "array", items: new OA\Items(type: "string")),
107+
explode: true
108+
),
109+
new OA\Parameter(
110+
name: "order",
111+
in: "query",
112+
required: false,
113+
description: "Order by field. Valid fields: id, name, member_level",
114+
schema: new OA\Schema(type: "string")
115+
),
116+
new OA\Parameter(
117+
name: "expand",
118+
in: "query",
119+
required: false,
120+
description: "Expand related entities. Available expansions: sponsorships, project_sponsorships",
121+
schema: new OA\Schema(type: "string")
122+
),
123+
new OA\Parameter(
124+
name: "relations",
125+
in: "query",
126+
required: false,
127+
description: "Load relations. Available: sponsorships, project_sponsorships",
128+
schema: new OA\Schema(type: "string")
129+
),
130+
],
131+
responses: [
132+
new OA\Response(
133+
response: Response::HTTP_OK,
134+
description: "Success",
135+
content: new OA\JsonContent(ref: "#/components/schemas/PaginatedCompaniesResponse")
136+
),
137+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
138+
]
139+
)]
140+
#[OA\Get(
141+
path: "/api/public/v1/companies",
142+
operationId: "getAllCompaniesPublic",
143+
summary: "Get all companies (Public)",
144+
description: "Returns a paginated list of companies. Allows ordering, filtering and pagination.",
145+
tags: ["Companies (Public)"],
146+
parameters: [
147+
new OA\Parameter(
148+
name: 'page',
149+
in: 'query',
150+
required: false,
151+
schema: new OA\Schema(type: 'integer'),
152+
description: 'The page number'
153+
),
154+
new OA\Parameter(
155+
name: 'per_page',
156+
in: 'query',
157+
required: false,
158+
schema: new OA\Schema(type: 'integer'),
159+
description: 'The number of items per page',
160+
),
161+
new OA\Parameter(
162+
name: "filter[]",
163+
in: "query",
164+
required: false,
165+
description: "Filter companies. Available filters: name (=@, ==, @@), member_level (=@, ==, @@), display_on_site (==)",
166+
schema: new OA\Schema(type: "array", items: new OA\Items(type: "string")),
167+
explode: true
168+
),
169+
new OA\Parameter(
170+
name: "order",
171+
in: "query",
172+
required: false,
173+
description: "Order by field. Valid fields: id, name, member_level",
174+
schema: new OA\Schema(type: "string")
175+
),
176+
new OA\Parameter(
177+
name: "expand",
178+
in: "query",
179+
required: false,
180+
description: "Expand related entities. Available expansions: sponsorships, project_sponsorships",
181+
schema: new OA\Schema(type: "string")
182+
),
183+
new OA\Parameter(
184+
name: "relations",
185+
in: "query",
186+
required: false,
187+
description: "Load relations. Available: sponsorships, project_sponsorships",
188+
schema: new OA\Schema(type: "string")
189+
),
190+
],
191+
responses: [
192+
new OA\Response(
193+
response: Response::HTTP_OK,
194+
description: "Success",
195+
content: new OA\JsonContent(ref: "#/components/schemas/PaginatedCompaniesResponse")
196+
),
197+
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
198+
]
199+
)]
71200
#[OA\Get(
72201
path: "/api/v1/companies/{id}",
73202
operationId: "getCompany",
@@ -113,10 +242,6 @@ public function __construct
113242
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Company not found"),
114243
]
115244
)]
116-
/**
117-
* Class OAuth2CompaniesApiController
118-
* @package App\Http\Controllers
119-
*/
120245
#[OA\Get(
121246
path: "/api/public/v1/companies/{id}",
122247
operationId: "getCompanyPublic",
@@ -270,136 +395,6 @@ public function __construct
270395
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "Company not found"),
271396
]
272397
)]
273-
#[OA\Get(
274-
path: "/api/v1/companies",
275-
operationId: "getAllCompanies",
276-
summary: "Get all companies",
277-
description: "Returns a paginated list of companies. Allows ordering, filtering and pagination.",
278-
security: [
279-
[
280-
"companies_oauth2" => [
281-
CompanyScopes::Read,
282-
SummitScopes::ReadSummitData,
283-
SummitScopes::ReadAllSummitData,
284-
]
285-
]
286-
],
287-
tags: ["Companies"],
288-
parameters: [
289-
new OA\Parameter(
290-
name: 'page',
291-
in: 'query',
292-
required: false,
293-
schema: new OA\Schema(type: 'integer'),
294-
description: 'The page number'
295-
),
296-
new OA\Parameter(
297-
name: 'per_page',
298-
in: 'query',
299-
required: false,
300-
schema: new OA\Schema(type: 'integer'),
301-
description: 'The number of pages in each page',
302-
),
303-
new OA\Parameter(
304-
name: "filter[]",
305-
in: "query",
306-
required: false,
307-
description: "Filter companies. Available filters: name (=@, ==, @@), member_level (=@, ==, @@), display_on_site (==)",
308-
schema: new OA\Schema(type: "array", items: new OA\Items(type: "string")),
309-
explode: true
310-
),
311-
new OA\Parameter(
312-
name: "order",
313-
in: "query",
314-
required: false,
315-
description: "Order by field. Valid fields: id, name, member_level",
316-
schema: new OA\Schema(type: "string")
317-
),
318-
new OA\Parameter(
319-
name: "expand",
320-
in: "query",
321-
required: false,
322-
description: "Expand related entities. Available expansions: sponsorships, project_sponsorships",
323-
schema: new OA\Schema(type: "string")
324-
),
325-
new OA\Parameter(
326-
name: "relations",
327-
in: "query",
328-
required: false,
329-
description: "Load relations. Available: sponsorships, project_sponsorships",
330-
schema: new OA\Schema(type: "string")
331-
),
332-
],
333-
responses: [
334-
new OA\Response(
335-
response: Response::HTTP_OK,
336-
description: "Success",
337-
content: new OA\JsonContent(ref: "#/components/schemas/PaginatedCompaniesResponse")
338-
),
339-
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
340-
]
341-
)]
342-
343-
#[OA\Get(
344-
path: "/api/public/v1/companies",
345-
operationId: "getAllCompaniesPublic",
346-
summary: "Get all companies (Public)",
347-
description: "Returns a paginated list of companies. Allows ordering, filtering and pagination.",
348-
tags: ["Companies (Public)"],
349-
parameters: [
350-
new OA\Parameter(
351-
name: 'page',
352-
in: 'query',
353-
required: false,
354-
schema: new OA\Schema(type: 'integer'),
355-
description: 'The page number'
356-
),
357-
new OA\Parameter(
358-
name: 'per_page',
359-
in: 'query',
360-
required: false,
361-
schema: new OA\Schema(type: 'integer'),
362-
description: 'The number of pages in each page',
363-
),
364-
new OA\Parameter(
365-
name: "filter[]",
366-
in: "query",
367-
required: false,
368-
description: "Filter companies. Available filters: name (=@, ==, @@), member_level (=@, ==, @@), display_on_site (==)",
369-
schema: new OA\Schema(type: "array", items: new OA\Items(type: "string")),
370-
explode: true
371-
),
372-
new OA\Parameter(
373-
name: "order",
374-
in: "query",
375-
required: false,
376-
description: "Order by field. Valid fields: id, name, member_level",
377-
schema: new OA\Schema(type: "string")
378-
),
379-
new OA\Parameter(
380-
name: "expand",
381-
in: "query",
382-
required: false,
383-
description: "Expand related entities. Available expansions: sponsorships, project_sponsorships",
384-
schema: new OA\Schema(type: "string")
385-
),
386-
new OA\Parameter(
387-
name: "relations",
388-
in: "query",
389-
required: false,
390-
description: "Load relations. Available: sponsorships, project_sponsorships",
391-
schema: new OA\Schema(type: "string")
392-
),
393-
],
394-
responses: [
395-
new OA\Response(
396-
response: Response::HTTP_OK,
397-
description: "Success",
398-
content: new OA\JsonContent(ref: "#/components/schemas/PaginatedCompaniesResponse")
399-
),
400-
new OA\Response(response: Response::HTTP_BAD_REQUEST, description: "Bad Request"),
401-
]
402-
)]
403398
public function getAllCompanies()
404399
{
405400

@@ -739,4 +734,4 @@ public function deleteCompanyBigLogo($company_id)
739734
return $this->deleted();
740735
});
741736
}
742-
}
737+
}

0 commit comments

Comments
 (0)