Skip to content

Commit da6b3a9

Browse files
authored
Merge pull request #18 from IFRCGo/feature/WN-268
WN-268
2 parents 8c2b732 + 559b81f commit da6b3a9

10 files changed

Lines changed: 2759 additions & 46 deletions

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
# Except swagger file
2+
!storage/api-docs/api-docs.json
3+
14
/node_modules
25
/public/hot
36
/public/storage
47
/public/vendor
58
/storage/*.key
69
/vendor
710
.vapor/
8-
storage/
11+
storage/**/*
12+
!storage/api-docs/
13+
!storage/api-docs/api-docs.json
914
.env
1015
.env.backup
1116
.phpunit.result.cache
@@ -14,4 +19,4 @@ Homestead.yaml
1419
npm-debug.log
1520
yarn-error.log
1621
helm-chart/secrets.yml
17-
.idea/*
22+
.idea/*

app/Http/Controllers/ApplicationController.php

Lines changed: 128 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
use Illuminate\Support\Facades\Log;
1010
use League\Fractal\Manager;
1111

12+
/**
13+
* @OA\Tag(
14+
* name="Aplications",
15+
* description="Operations about Aplications"
16+
* )
17+
*/
1218
class ApplicationController extends Controller
1319
{
1420
/**
@@ -54,6 +60,29 @@ public function __construct(
5460
* @param Request $request
5561
* @return \Symfony\Component\HttpFoundation\Response
5662
*/
63+
/**
64+
* @OA\Get(
65+
* path="/apps",
66+
* tags={"Applications"},
67+
* summary="Get all applications for a user",
68+
* operationId="getAllForUser",
69+
* @OA\Parameter(
70+
* name="userId",
71+
* in="query",
72+
* required=true,
73+
* description="ID of the user to fetch applications for",
74+
* @OA\Schema(type="string")
75+
* ),
76+
* @OA\Response(
77+
* response=200,
78+
* description="Successful response",
79+
* @OA\JsonContent(
80+
* type="object",
81+
* @OA\Property(property="data", type="array", @OA\Items(type="object"))
82+
* )
83+
* )
84+
* )
85+
*/
5786
public function getAllForUser(Request $request)
5887
{
5988
$this->validate($this->request, [
@@ -86,6 +115,29 @@ public function getAllForUser(Request $request)
86115
* @param int $id
87116
* @return \Symfony\Component\HttpFoundation\Response
88117
*/
118+
/**
119+
* @OA\Get(
120+
* path="/apps/{id}",
121+
* tags={"Applications"},
122+
* summary="Get an application by ID",
123+
* operationId="getApplicationById",
124+
* @OA\Parameter(
125+
* name="id",
126+
* in="path",
127+
* required=true,
128+
* description="ID of the application to retrieve",
129+
* @OA\Schema(type="integer", format="int64")
130+
* ),
131+
* @OA\Response(
132+
* response=200,
133+
* description="Successful response",
134+
* @OA\JsonContent(
135+
* type="object",
136+
* @OA\Property(property="data", type="array", @OA\Items(type="object"))
137+
* )
138+
* )
139+
* )
140+
*/
89141
public function getById($id)
90142
{
91143
try {
@@ -119,6 +171,32 @@ public function getById($id)
119171
* @param Request $request
120172
* @return \Symfony\Component\HttpFoundation\Response
121173
*/
174+
/**
175+
* @OA\Post(
176+
* path="/apps",
177+
* tags={"Applications"},
178+
* summary="Create a new application",
179+
* operationId="createApplication",
180+
* @OA\RequestBody(
181+
* required=true,
182+
* @OA\JsonContent(
183+
* required={"name", "userId"},
184+
* @OA\Property(property="name", type="string", example="My Application", description="Name of the application"),
185+
* @OA\Property(property="description", type="string", example="A description of the application", description="Description of the application (optional)"),
186+
* @OA\Property(property="userId", type="string", example="user123", description="ID of the user creating the application"),
187+
* @OA\Property(property="estimatedUsers", type="integer", example=100, description="Estimated number of users (optional)")
188+
* )
189+
* ),
190+
* @OA\Response(
191+
* response=200,
192+
* description="Successful response",
193+
* @OA\JsonContent(
194+
* type="object",
195+
* @OA\Property(property="data", type="array", @OA\Items(type="object"))
196+
* )
197+
* )
198+
* )
199+
*/
122200
public function create(Request $request)
123201
{
124202
$this->validate($this->request, [
@@ -152,6 +230,35 @@ public function create(Request $request)
152230
return response()->json($response->toArray(), 201);
153231
}
154232

233+
/**
234+
* @OA\Patch(
235+
* path="/apps/{id}",
236+
* tags={"Applications"},
237+
* summary="Update an application by ID",
238+
* operationId="updateApplication",
239+
* @OA\Parameter(
240+
* name="id",
241+
* in="path",
242+
* required=true,
243+
* description="ID of the application to update",
244+
* @OA\Schema(type="integer", format="int64")
245+
* ),
246+
* @OA\RequestBody(
247+
* required=true,
248+
* @OA\JsonContent(
249+
* @OA\Property(property="estimatedUsers", type="integer", example=100, description="Estimated number of users (optional)")
250+
* )
251+
* ),
252+
* @OA\Response(
253+
* response=200,
254+
* description="Successful response",
255+
* @OA\JsonContent(
256+
* type="object",
257+
* @OA\Property(property="data", type="array", @OA\Items(type="object"))
258+
* )
259+
* )
260+
* )
261+
*/
155262
public function update(Request $request, $id)
156263
{
157264
$this->validate($this->request, [
@@ -182,8 +289,27 @@ public function update(Request $request, $id)
182289
}
183290

184291
/**
185-
* @param int $id
186-
* @return \Symfony\Component\HttpFoundation\Response
292+
* @OA\Delete(
293+
* path="/apps/{id}",
294+
* tags={"Applications"},
295+
* summary="Delete an application by ID",
296+
* operationId="deleteApplication",
297+
* @OA\Parameter(
298+
* name="id",
299+
* in="path",
300+
* required=true,
301+
* description="ID of the application to delete",
302+
* @OA\Schema(type="integer", format="int64")
303+
* ),
304+
* @OA\Response(
305+
* response=200,
306+
* description="Successful response",
307+
* @OA\JsonContent(
308+
* type="object",
309+
* @OA\Property(property="data", type="array", @OA\Items(type="object"))
310+
* )
311+
* )
312+
* )
187313
*/
188314
public function delete($id)
189315
{

app/Http/Controllers/Controller.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@
88
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
99

1010
/**
11-
* @OA\Info(
12-
* title="Whatnow API",
13-
* description="Whatnow API documentation",
14-
* version="1.0.0",
11+
* @OA\OpenApi(
12+
* @OA\Info(
13+
* title="Whatnow API",
14+
* description="Whatnow API documentation",
15+
* version="1.0.0",
16+
* ),
17+
* @OA\Server(
18+
* url=L5_SWAGGER_CONST_HOST,
19+
* description="API Base URL"
20+
* )
1521
* )
1622
*/
1723
class Controller extends BaseController

app/Http/Controllers/FileUploadController.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,45 @@
55
use Illuminate\Http\Request;
66
use Illuminate\Support\Facades\Storage;
77

8+
/**
9+
* @OA\Tag(
10+
* name="Files",
11+
* description="Operations about Files"
12+
* )
13+
*/
814
class FileUploadController extends Controller
915
{
16+
/**
17+
* @OA\Post(
18+
* path="/upload",
19+
* tags={"Whatnow"},
20+
* summary="Upload a file",
21+
* operationId="uploadFile",
22+
* @OA\RequestBody(
23+
* required=true,
24+
* @OA\MediaType(
25+
* mediaType="multipart/form-data",
26+
* @OA\Schema(
27+
* required={"file"},
28+
* @OA\Property(
29+
* property="file",
30+
* type="string",
31+
* format="binary",
32+
* description="File to upload (allowed types: jpg, png; max size: 10MB)"
33+
* )
34+
* )
35+
* )
36+
* ),
37+
* @OA\Response(
38+
* response=200,
39+
* description="Successful response",
40+
* @OA\JsonContent(
41+
* type="object",
42+
* @OA\Property(property="data", type="array", @OA\Items(type="object"))
43+
* )
44+
* )
45+
* )
46+
*/
1047
public function upload(Request $request)
1148
{
1249
try {

0 commit comments

Comments
 (0)