Skip to content

Commit 823f7e4

Browse files
committed
add comments api
1 parent 35e10db commit 823f7e4

File tree

1 file changed

+190
-2
lines changed

1 file changed

+190
-2
lines changed

web/swagger.json

+190-2
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@
870870
"schema": {
871871
"type": "object",
872872
"properties": {
873-
"posts": {
873+
"likes": {
874874
"type": "array",
875875
"items": {
876876
"$ref": "#/components/schemas/Like"
@@ -922,6 +922,146 @@
922922
}
923923
}
924924
},
925+
"/posts/{postId}/comments": {
926+
"get": {
927+
"description": "Index the post comments",
928+
"tags": [
929+
"Comments"
930+
],
931+
"parameters": [
932+
{
933+
"name": "count",
934+
"in": "query",
935+
"description": "Number of comments to retrieve",
936+
"required": false,
937+
"schema": {
938+
"type": "integer",
939+
"example": 5,
940+
"default": 10
941+
}
942+
},
943+
{
944+
"name": "lastId",
945+
"in": "query",
946+
"description": "ID of the last comment retrieved",
947+
"required": false,
948+
"schema": {
949+
"type": "integer",
950+
"example": 13
951+
}
952+
}
953+
],
954+
"responses": {
955+
"200": {
956+
"description": "list of the comments of a post",
957+
"content": {
958+
"application/json": {
959+
"schema": {
960+
"type": "object",
961+
"properties": {
962+
"comments": {
963+
"type": "array",
964+
"items": {
965+
"$ref": "#/components/schemas/Comment"
966+
}
967+
}
968+
}
969+
}
970+
}
971+
}
972+
}
973+
}
974+
}
975+
},
976+
"/comments": {
977+
"get": {
978+
"description": "Index the user comments",
979+
"tags": [
980+
"Comments"
981+
],
982+
"parameters": [
983+
{
984+
"name": "count",
985+
"in": "query",
986+
"description": "Number of comments to retrieve",
987+
"required": false,
988+
"schema": {
989+
"type": "integer",
990+
"example": 5,
991+
"default": 10
992+
}
993+
},
994+
{
995+
"name": "lastId",
996+
"in": "query",
997+
"description": "ID of the last comment retrieved",
998+
"required": false,
999+
"schema": {
1000+
"type": "integer",
1001+
"example": 13
1002+
}
1003+
}
1004+
],
1005+
"responses": {
1006+
"200": {
1007+
"description": "list of the comments of a post",
1008+
"content": {
1009+
"application/json": {
1010+
"schema": {
1011+
"type": "object",
1012+
"properties": {
1013+
"comments": {
1014+
"type": "array",
1015+
"items": {
1016+
"$ref": "#/components/schemas/Comment"
1017+
}
1018+
}
1019+
}
1020+
}
1021+
}
1022+
}
1023+
}
1024+
}
1025+
},
1026+
"post": {
1027+
"operationId": "comments-store",
1028+
"description": "Store a new comment",
1029+
"tags": [
1030+
"Comments"
1031+
],
1032+
"requestBody": {
1033+
"required": true,
1034+
"content": {
1035+
"application/json": {
1036+
"schema": {
1037+
"$ref": "#/components/schemas/NewComment"
1038+
}
1039+
}
1040+
}
1041+
},
1042+
"responses": {
1043+
"201": {
1044+
"description": "The new comment created."
1045+
}
1046+
}
1047+
}
1048+
},
1049+
"/comments/{commentId}": {
1050+
"delete": {
1051+
"description": "Delete the comment",
1052+
"tags": [
1053+
"Comments"
1054+
],
1055+
"responses": {
1056+
"204": {
1057+
"description": "The comment deleted."
1058+
},
1059+
"404": {
1060+
"description": "The comment not found."
1061+
}
1062+
}
1063+
}
1064+
},
9251065
"/search/posts": {
9261066
"get": {
9271067
"description": "Search posts",
@@ -1213,7 +1353,7 @@
12131353
"id": {
12141354
"type": "integer",
12151355
"example": 13,
1216-
"description": "Unique id of post (uint64)"
1356+
"description": "Unique id (uint64)"
12171357
},
12181358
"user_id": {
12191359
"type": "integer",
@@ -1230,6 +1370,34 @@
12301370
}
12311371
}
12321372
},
1373+
"Comment": {
1374+
"allOf": [
1375+
{
1376+
"$ref": "#/components/schemas/NewPost"
1377+
},
1378+
{
1379+
"type": "object",
1380+
"properties": {
1381+
"id": {
1382+
"type": "integer",
1383+
"example": 13,
1384+
"description": "Unique id (uint64)"
1385+
},
1386+
"user": {
1387+
"$ref": "#/components/schemas/User"
1388+
},
1389+
"post": {
1390+
"$ref": "#/components/schemas/Post"
1391+
},
1392+
"created_at": {
1393+
"type": "string",
1394+
"example": "2023-11-28T13:36:30.956Z",
1395+
"description": "Registration time"
1396+
}
1397+
}
1398+
}
1399+
]
1400+
},
12331401
"Post": {
12341402
"allOf": [
12351403
{
@@ -1329,6 +1497,26 @@
13291497
}
13301498
}
13311499
},
1500+
"NewComment": {
1501+
"type": "object",
1502+
"properties": {
1503+
"user_id": {
1504+
"type": "integer",
1505+
"example": 13,
1506+
"description": "Unique id of user (uint64)"
1507+
},
1508+
"post_id": {
1509+
"type": "integer",
1510+
"example": 13,
1511+
"description": "Unique id of post (uint64)"
1512+
},
1513+
"text": {
1514+
"type": "string",
1515+
"example": "Wow! Nice...",
1516+
"description": "The comment text"
1517+
}
1518+
}
1519+
},
13321520
"Error": {
13331521
"type": "object",
13341522
"properties": {

0 commit comments

Comments
 (0)