Skip to content

Commit f49a684

Browse files
committed
Update notification annotations
1 parent cf4da36 commit f49a684

3 files changed

Lines changed: 84 additions & 56 deletions

File tree

‎ProcessMaker/Http/Controllers/Api/NotificationController.php‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ class NotificationController extends Controller
6060
* @OA\Property(
6161
* property="data",
6262
* type="array",
63-
* @OA\Items(ref="#/components/schemas/notifications"),
63+
* @OA\Items(ref="#/components/schemas/Notification"),
6464
* ),
6565
* @OA\Property(
6666
* property="meta",
67-
* type="object",
68-
* allOf={@OA\Schema(ref="#/components/schemas/metadata")},
67+
* @OA\Schema(ref="#/components/schemas/metadata"),
6968
* ),
7069
* ),
7170
* ),
@@ -139,12 +138,12 @@ public function index(Request $request)
139138
* tags={"Notifications"},
140139
* @OA\RequestBody(
141140
* required=true,
142-
* @OA\JsonContent(ref="#/components/schemas/notificationsEditable")
141+
* @OA\JsonContent(ref="#/components/schemas/NotificationEditable")
143142
* ),
144143
* @OA\Response(
145144
* response=201,
146145
* description="success",
147-
* @OA\JsonContent(ref="#/components/schemas/notifications")
146+
* @OA\JsonContent(ref="#/components/schemas/Notification")
148147
* ),
149148
* )
150149
*/
@@ -184,7 +183,7 @@ public function store(Request $request)
184183
* @OA\Response(
185184
* response=200,
186185
* description="Successfully found the notification",
187-
* @OA\JsonContent(ref="#/components/schemas/notifications")
186+
* @OA\JsonContent(ref="#/components/schemas/Notification")
188187
* ),
189188
* )
190189
*/
@@ -219,7 +218,7 @@ public function show(Notification $notification)
219218
* ),
220219
* @OA\RequestBody(
221220
* required=true,
222-
* @OA\JsonContent(ref="#/components/schemas/notificationsEditable")
221+
* @OA\JsonContent(ref="#/components/schemas/NotificationEditable")
223222
* ),
224223
* @OA\Response(
225224
* response=204,
@@ -230,6 +229,7 @@ public function show(Notification $notification)
230229
public function update(Notification $notification, Request $request)
231230
{
232231
$request->validate(Notification::rules($notification));
232+
\Log::info("UPDATE", $request->input());
233233
$notification->fill($request->input());
234234
$notification->saveOrFail();
235235
return response([], 204);
@@ -271,15 +271,16 @@ public function destroy(Notification $notification)
271271

272272

273273
/**
274-
* Update notifications
274+
* Update notification as read
275275
*
276276
* @param Request $request
277277
*
278278
* @return Response
279279
*
280-
* @OA\Put(
280+
* @OA\Put(
281281
* path="/read_notifications",
282282
* summary="Mark notifications as read by the user",
283+
* operationId="markNotificationAsRead",
283284
* tags={"Notifications"},
284285
*
285286
* @OA\RequestBody(
@@ -322,9 +323,10 @@ public function updateAsRead(Request $request)
322323
*
323324
* @return Response
324325
*
325-
* @OA\Put(
326+
* @OA\Put(
326327
* path="/unread_notifications",
327328
* summary="Mark notifications as unread by the user",
329+
* operationId="markNotificationAsUnread",
328330
* tags={"Notifications"},
329331
*
330332
* @OA\RequestBody(
@@ -377,18 +379,19 @@ public function updateAsUnread(Request $request)
377379
* @OA\Put(
378380
* path="/read_all_notifications",
379381
* summary="Mark notifications as read by id and type",
382+
* operationId="markAllAsRead",
380383
* tags={"Notifications"},
381384
*
382385
* @OA\RequestBody(
383386
* required=true,
384387
* @OA\JsonContent(
385388
* @OA\Property(
386-
* property="notifiable_id",
389+
* property="id",
387390
* type="integer",
388391
* description="Polymorphic relation id",
389392
* @OA\Items (type="integer")),
390393
* @OA\Property(
391-
* property="notifiable_type",
394+
* property="type",
392395
* type="string",
393396
* description="Polymorphic relation type",
394397
* @OA\Items (type="string"))

‎ProcessMaker/Models/Notification.php‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,29 @@
1919
* @property \Carbon\Carbon $updated_at
2020
* @property \Carbon\Carbon $created_at
2121
*
22-
* @OA\Schema(
23-
* schema="notificationsEditable",
22+
* @OA\Schema(
23+
* schema="NotificationEditable",
2424
* @OA\Property(property="type", type="string"),
2525
* @OA\Property(property="notifiable_type", type="string"),
2626
* @OA\Property(property="notifiable_id", type="integer"),
2727
* @OA\Property(property="data", type="string"),
28+
* @OA\Property(property="name", type="string"),
29+
* @OA\Property(property="message", type="string"),
30+
* @OA\Property(property="processName", type="string"),
31+
* @OA\Property(property="userName", type="string"),
32+
* @OA\Property(property="request_id", type="string"),
2833
* ),
2934
* @OA\Schema(
30-
* schema="notifications",
31-
* allOf={@OA\Schema(ref="#/components/schemas/notificationsEditable")},
32-
* @OA\Property(property="id", type="string"),
33-
* @OA\Property(property="read_at", type="string", format="date-time"),
34-
* @OA\Property(property="created_at", type="string", format="date-time"),
35-
* @OA\Property(property="updated_at", type="string", format="date-time"),
35+
* schema="Notification",
36+
* allOf={
37+
* @OA\Schema(ref="#/components/schemas/NotificationEditable"),
38+
* @OA\Schema(
39+
* @OA\Property(property="id", type="string"),
40+
* @OA\Property(property="read_at", type="string", format="date-time"),
41+
* @OA\Property(property="created_at", type="string", format="date-time"),
42+
* @OA\Property(property="updated_at", type="string", format="date-time"),
43+
* ),
44+
* },
3645
* )
3746
*
3847
*/

‎storage/api-docs/api-docs.json‎

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,17 +1042,11 @@
10421042
"description": "Display a listing of the resource.",
10431043
"type": "array",
10441044
"items": {
1045-
"$ref": "#/components/schemas/notifications"
1045+
"$ref": "#/components/schemas/Notification"
10461046
}
10471047
},
10481048
"meta": {
1049-
"description": "Display a listing of the resource.",
1050-
"type": "object",
1051-
"allOf": [
1052-
{
1053-
"$ref": "#/components/schemas/metadata"
1054-
}
1055-
]
1049+
"description": "Display a listing of the resource."
10561050
}
10571051
},
10581052
"type": "object"
@@ -1073,7 +1067,7 @@
10731067
"content": {
10741068
"application/json": {
10751069
"schema": {
1076-
"$ref": "#/components/schemas/notificationsEditable"
1070+
"$ref": "#/components/schemas/NotificationEditable"
10771071
}
10781072
}
10791073
}
@@ -1084,7 +1078,7 @@
10841078
"content": {
10851079
"application/json": {
10861080
"schema": {
1087-
"$ref": "#/components/schemas/notifications"
1081+
"$ref": "#/components/schemas/Notification"
10881082
}
10891083
}
10901084
}
@@ -1116,7 +1110,7 @@
11161110
"content": {
11171111
"application/json": {
11181112
"schema": {
1119-
"$ref": "#/components/schemas/notifications"
1113+
"$ref": "#/components/schemas/Notification"
11201114
}
11211115
}
11221116
}
@@ -1145,7 +1139,7 @@
11451139
"content": {
11461140
"application/json": {
11471141
"schema": {
1148-
"$ref": "#/components/schemas/notificationsEditable"
1142+
"$ref": "#/components/schemas/NotificationEditable"
11491143
}
11501144
}
11511145
}
@@ -1186,7 +1180,7 @@
11861180
"Notifications"
11871181
],
11881182
"summary": "Mark notifications as read by the user",
1189-
"operationId": "ProcessMaker\\Http\\Controllers\\Api\\NotificationController::updateAsRead",
1183+
"operationId": "markNotificationAsRead",
11901184
"requestBody": {
11911185
"required": true,
11921186
"content": {
@@ -1226,7 +1220,7 @@
12261220
"Notifications"
12271221
],
12281222
"summary": "Mark notifications as unread by the user",
1229-
"operationId": "ProcessMaker\\Http\\Controllers\\Api\\NotificationController::updateAsUnread",
1223+
"operationId": "markNotificationAsUnread",
12301224
"requestBody": {
12311225
"required": true,
12321226
"content": {
@@ -1266,21 +1260,21 @@
12661260
"Notifications"
12671261
],
12681262
"summary": "Mark notifications as read by id and type",
1269-
"operationId": "ProcessMaker\\Http\\Controllers\\Api\\NotificationController::updateAsReadAll",
1263+
"operationId": "markAllAsRead",
12701264
"requestBody": {
12711265
"required": true,
12721266
"content": {
12731267
"application/json": {
12741268
"schema": {
12751269
"properties": {
1276-
"notifiable_id": {
1270+
"id": {
12771271
"description": "Polymorphic relation id",
12781272
"type": "integer",
12791273
"items": {
12801274
"type": "integer"
12811275
}
12821276
},
1283-
"notifiable_type": {
1277+
"type": {
12841278
"description": "Polymorphic relation type",
12851279
"type": "string",
12861280
"items": {
@@ -4237,7 +4231,7 @@
42374231
},
42384232
"type": "object"
42394233
},
4240-
"notificationsEditable": {
4234+
"NotificationEditable": {
42414235
"properties": {
42424236
"type": {
42434237
"description": "Represents a notification definition.",
@@ -4254,36 +4248,58 @@
42544248
"data": {
42554249
"description": "Represents a notification definition.",
42564250
"type": "string"
4257-
}
4258-
},
4259-
"type": "object"
4260-
},
4261-
"notifications": {
4262-
"properties": {
4263-
"id": {
4251+
},
4252+
"name": {
42644253
"description": "Represents a notification definition.",
42654254
"type": "string"
42664255
},
4267-
"read_at": {
4256+
"message": {
42684257
"description": "Represents a notification definition.",
4269-
"type": "string",
4270-
"format": "date-time"
4258+
"type": "string"
42714259
},
4272-
"created_at": {
4260+
"processName": {
42734261
"description": "Represents a notification definition.",
4274-
"type": "string",
4275-
"format": "date-time"
4262+
"type": "string"
42764263
},
4277-
"updated_at": {
4264+
"userName": {
42784265
"description": "Represents a notification definition.",
4279-
"type": "string",
4280-
"format": "date-time"
4266+
"type": "string"
4267+
},
4268+
"request_id": {
4269+
"description": "Represents a notification definition.",
4270+
"type": "string"
42814271
}
42824272
},
4283-
"type": "object",
4273+
"type": "object"
4274+
},
4275+
"Notification": {
42844276
"allOf": [
42854277
{
4286-
"$ref": "#/components/schemas/notificationsEditable"
4278+
"$ref": "#/components/schemas/NotificationEditable"
4279+
},
4280+
{
4281+
"properties": {
4282+
"id": {
4283+
"description": "Represents a notification definition.",
4284+
"type": "string"
4285+
},
4286+
"read_at": {
4287+
"description": "Represents a notification definition.",
4288+
"type": "string",
4289+
"format": "date-time"
4290+
},
4291+
"created_at": {
4292+
"description": "Represents a notification definition.",
4293+
"type": "string",
4294+
"format": "date-time"
4295+
},
4296+
"updated_at": {
4297+
"description": "Represents a notification definition.",
4298+
"type": "string",
4299+
"format": "date-time"
4300+
}
4301+
},
4302+
"type": "object"
42874303
}
42884304
]
42894305
},

0 commit comments

Comments
 (0)