From 9cd44de9be62e1291f84763bc029f995301e1e03 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 22 Sep 2023 23:58:26 +0300 Subject: feat: discussions (#59) Former-commit-id: ac6ac59367650b6a37650f5aec0587c6ce4d3dd1 --- docs/docs.go | 527 ++++++++++++++++++++++++++++++++++++++---------------- docs/swagger.json | 527 ++++++++++++++++++++++++++++++++++++++---------------- docs/swagger.yaml | 353 +++++++++++++++++++++++++----------- 3 files changed, 997 insertions(+), 410 deletions(-) (limited to 'docs') diff --git a/docs/docs.go b/docs/docs.go index 1db1bba..9712377 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -20,7 +20,7 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { - "/chapters/{id}": { + "/chapters/{chapterid}": { "get": { "description": "Get maps from the specified chapter id.", "produces": [ @@ -33,7 +33,7 @@ const docTemplate = `{ { "type": "integer", "description": "Chapter ID", - "name": "id", + "name": "chapterid", "in": "path", "required": true } @@ -93,12 +93,6 @@ const docTemplate = `{ "schema": { "type": "file" } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -143,7 +137,7 @@ const docTemplate = `{ } } }, - "/games/{id}": { + "/games/{gameid}": { "get": { "description": "Get chapters from the specified game id.", "produces": [ @@ -156,7 +150,7 @@ const docTemplate = `{ { "type": "integer", "description": "Game ID", - "name": "id", + "name": "gameid", "in": "path", "required": true } @@ -179,12 +173,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -219,12 +207,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -265,12 +247,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -302,19 +278,159 @@ const docTemplate = `{ } ] } + } + } + } + }, + "/maps/{mapid}/discussions": { + "get": { + "description": "Get map discussions with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.MapDiscussionsResponse" + } + } + } + ] + } + } + } + }, + "post": { + "description": "Create map discussion with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true }, - "400": { - "description": "Bad Request", + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", + "in": "path", + "required": true + }, + { + "description": "Body", + "name": "request", + "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/models.Response" + "$ref": "#/definitions/handlers.CreateMapDiscussionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.CreateMapDiscussionRequest" + } + } + } + ] } } } } }, - "/maps/{id}/image": { + "/maps/{mapid}/discussions/{discussionid}": { + "get": { + "description": "Get map discussion with specified map and discussion id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.MapDiscussionResponse" + } + } + } + ] + } + } + } + }, "put": { - "description": "Edit map image with specified map id.", + "description": "Edit map discussion with specified map id.", "produces": [ "application/json" ], @@ -332,7 +448,14 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", "in": "path", "required": true }, @@ -342,7 +465,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/handlers.EditMapImageRequest" + "$ref": "#/definitions/handlers.EditMapDiscussionRequest" } } ], @@ -358,15 +481,49 @@ const docTemplate = `{ "type": "object", "properties": { "data": { - "$ref": "#/definitions/handlers.EditMapImageRequest" + "$ref": "#/definitions/handlers.EditMapDiscussionRequest" } } } ] } + } + } + }, + "delete": { + "description": "Delete map summary with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true }, - "400": { - "description": "Bad Request", + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", "schema": { "$ref": "#/definitions/models.Response" } @@ -374,7 +531,63 @@ const docTemplate = `{ } } }, - "/maps/{id}/leaderboards": { + "/maps/{mapid}/image": { + "put": { + "description": "Edit map image with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "description": "Body", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.EditMapImageRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.EditMapImageRequest" + } + } + } + ] + } + } + } + } + }, + "/maps/{mapid}/leaderboards": { "get": { "description": "Get map leaderboards with specified id.", "produces": [ @@ -387,7 +600,7 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -422,17 +635,11 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } }, - "/maps/{id}/record": { + "/maps/{mapid}/record": { "post": { "description": "Post record with demo of a specific map.", "consumes": [ @@ -448,7 +655,7 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -503,23 +710,11 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } }, - "/maps/{id}/summary": { + "/maps/{mapid}/summary": { "get": { "description": "Get map summary with specified id.", "produces": [ @@ -532,7 +727,7 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true } @@ -555,12 +750,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -583,7 +772,7 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -615,12 +804,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -643,7 +826,7 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -675,12 +858,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -703,7 +880,7 @@ const docTemplate = `{ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -735,12 +912,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -784,18 +955,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -832,18 +991,6 @@ const docTemplate = `{ "schema": { "$ref": "#/definitions/models.Response" } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -885,18 +1032,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -928,12 +1063,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -973,12 +1102,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -1055,7 +1178,7 @@ const docTemplate = `{ } } }, - "/users/{id}": { + "/users/{userid}": { "get": { "description": "Get profile page of another user.", "consumes": [ @@ -1071,7 +1194,7 @@ const docTemplate = `{ { "type": "integer", "description": "User ID", - "name": "id", + "name": "userid", "in": "path", "required": true } @@ -1094,18 +1217,6 @@ const docTemplate = `{ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -1140,6 +1251,21 @@ const docTemplate = `{ } } }, + "handlers.CreateMapDiscussionRequest": { + "type": "object", + "required": [ + "content", + "title" + ], + "properties": { + "content": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, "handlers.CreateMapSummaryRequest": { "type": "object", "required": [ @@ -1181,6 +1307,21 @@ const docTemplate = `{ } } }, + "handlers.EditMapDiscussionRequest": { + "type": "object", + "required": [ + "content", + "title" + ], + "properties": { + "content": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, "handlers.EditMapImageRequest": { "type": "object", "required": [ @@ -1255,6 +1396,90 @@ const docTemplate = `{ } } }, + "handlers.MapDiscussion": { + "type": "object", + "properties": { + "comments": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.MapDiscussionComment" + } + }, + "content": { + "type": "string" + }, + "creator": { + "$ref": "#/definitions/models.UserShortWithAvatar" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "updated_at": { + "description": "Upvotes int ` + "`" + `json:\"upvotes\"` + "`" + `", + "type": "string" + } + } + }, + "handlers.MapDiscussionComment": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "date": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/models.UserShortWithAvatar" + } + } + }, + "handlers.MapDiscussionOnlyTitle": { + "type": "object", + "properties": { + "comments": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.MapDiscussionComment" + } + }, + "creator": { + "$ref": "#/definitions/models.UserShortWithAvatar" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "updated_at": { + "description": "Upvotes int ` + "`" + `json:\"upvotes\"` + "`" + `", + "type": "string" + } + } + }, + "handlers.MapDiscussionResponse": { + "type": "object", + "properties": { + "discussion": { + "$ref": "#/definitions/handlers.MapDiscussion" + } + } + }, + "handlers.MapDiscussionsResponse": { + "type": "object", + "properties": { + "discussions": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.MapDiscussionOnlyTitle" + } + } + } + }, "handlers.MapLeaderboardsResponse": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index ae83321..226cadd 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -13,7 +13,7 @@ "host": "lp.ardapektezol.com/api", "basePath": "/v1", "paths": { - "/chapters/{id}": { + "/chapters/{chapterid}": { "get": { "description": "Get maps from the specified chapter id.", "produces": [ @@ -26,7 +26,7 @@ { "type": "integer", "description": "Chapter ID", - "name": "id", + "name": "chapterid", "in": "path", "required": true } @@ -86,12 +86,6 @@ "schema": { "type": "file" } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -136,7 +130,7 @@ } } }, - "/games/{id}": { + "/games/{gameid}": { "get": { "description": "Get chapters from the specified game id.", "produces": [ @@ -149,7 +143,7 @@ { "type": "integer", "description": "Game ID", - "name": "id", + "name": "gameid", "in": "path", "required": true } @@ -172,12 +166,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -212,12 +200,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -258,12 +240,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -295,19 +271,159 @@ } ] } + } + } + } + }, + "/maps/{mapid}/discussions": { + "get": { + "description": "Get map discussions with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.MapDiscussionsResponse" + } + } + } + ] + } + } + } + }, + "post": { + "description": "Create map discussion with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true }, - "400": { - "description": "Bad Request", + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", + "in": "path", + "required": true + }, + { + "description": "Body", + "name": "request", + "in": "body", + "required": true, "schema": { - "$ref": "#/definitions/models.Response" + "$ref": "#/definitions/handlers.CreateMapDiscussionRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.CreateMapDiscussionRequest" + } + } + } + ] } } } } }, - "/maps/{id}/image": { + "/maps/{mapid}/discussions/{discussionid}": { + "get": { + "description": "Get map discussion with specified map and discussion id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.MapDiscussionResponse" + } + } + } + ] + } + } + } + }, "put": { - "description": "Edit map image with specified map id.", + "description": "Edit map discussion with specified map id.", "produces": [ "application/json" ], @@ -325,7 +441,14 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", "in": "path", "required": true }, @@ -335,7 +458,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/handlers.EditMapImageRequest" + "$ref": "#/definitions/handlers.EditMapDiscussionRequest" } } ], @@ -351,15 +474,49 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/handlers.EditMapImageRequest" + "$ref": "#/definitions/handlers.EditMapDiscussionRequest" } } } ] } + } + } + }, + "delete": { + "description": "Delete map summary with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true }, - "400": { - "description": "Bad Request", + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Discussion ID", + "name": "discussionid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", "schema": { "$ref": "#/definitions/models.Response" } @@ -367,7 +524,63 @@ } } }, - "/maps/{id}/leaderboards": { + "/maps/{mapid}/image": { + "put": { + "description": "Edit map image with specified map id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "description": "Body", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/handlers.EditMapImageRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/models.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/handlers.EditMapImageRequest" + } + } + } + ] + } + } + } + } + }, + "/maps/{mapid}/leaderboards": { "get": { "description": "Get map leaderboards with specified id.", "produces": [ @@ -380,7 +593,7 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -415,17 +628,11 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } }, - "/maps/{id}/record": { + "/maps/{mapid}/record": { "post": { "description": "Post record with demo of a specific map.", "consumes": [ @@ -441,7 +648,7 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -496,23 +703,11 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } }, - "/maps/{id}/summary": { + "/maps/{mapid}/summary": { "get": { "description": "Get map summary with specified id.", "produces": [ @@ -525,7 +720,7 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true } @@ -548,12 +743,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -576,7 +765,7 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -608,12 +797,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -636,7 +819,7 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -668,12 +851,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -696,7 +873,7 @@ { "type": "integer", "description": "Map ID", - "name": "id", + "name": "mapid", "in": "path", "required": true }, @@ -728,12 +905,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -777,18 +948,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -825,18 +984,6 @@ "schema": { "$ref": "#/definitions/models.Response" } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } }, @@ -878,18 +1025,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "401": { - "description": "Unauthorized", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -921,12 +1056,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -966,12 +1095,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -1048,7 +1171,7 @@ } } }, - "/users/{id}": { + "/users/{userid}": { "get": { "description": "Get profile page of another user.", "consumes": [ @@ -1064,7 +1187,7 @@ { "type": "integer", "description": "User ID", - "name": "id", + "name": "userid", "in": "path", "required": true } @@ -1087,18 +1210,6 @@ } ] } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/models.Response" - } - }, - "404": { - "description": "Not Found", - "schema": { - "$ref": "#/definitions/models.Response" - } } } } @@ -1133,6 +1244,21 @@ } } }, + "handlers.CreateMapDiscussionRequest": { + "type": "object", + "required": [ + "content", + "title" + ], + "properties": { + "content": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, "handlers.CreateMapSummaryRequest": { "type": "object", "required": [ @@ -1174,6 +1300,21 @@ } } }, + "handlers.EditMapDiscussionRequest": { + "type": "object", + "required": [ + "content", + "title" + ], + "properties": { + "content": { + "type": "string" + }, + "title": { + "type": "string" + } + } + }, "handlers.EditMapImageRequest": { "type": "object", "required": [ @@ -1248,6 +1389,90 @@ } } }, + "handlers.MapDiscussion": { + "type": "object", + "properties": { + "comments": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.MapDiscussionComment" + } + }, + "content": { + "type": "string" + }, + "creator": { + "$ref": "#/definitions/models.UserShortWithAvatar" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "updated_at": { + "description": "Upvotes int `json:\"upvotes\"`", + "type": "string" + } + } + }, + "handlers.MapDiscussionComment": { + "type": "object", + "properties": { + "comment": { + "type": "string" + }, + "date": { + "type": "string" + }, + "user": { + "$ref": "#/definitions/models.UserShortWithAvatar" + } + } + }, + "handlers.MapDiscussionOnlyTitle": { + "type": "object", + "properties": { + "comments": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.MapDiscussionComment" + } + }, + "creator": { + "$ref": "#/definitions/models.UserShortWithAvatar" + }, + "id": { + "type": "integer" + }, + "title": { + "type": "string" + }, + "updated_at": { + "description": "Upvotes int `json:\"upvotes\"`", + "type": "string" + } + } + }, + "handlers.MapDiscussionResponse": { + "type": "object", + "properties": { + "discussion": { + "$ref": "#/definitions/handlers.MapDiscussion" + } + } + }, + "handlers.MapDiscussionsResponse": { + "type": "object", + "properties": { + "discussions": { + "type": "array", + "items": { + "$ref": "#/definitions/handlers.MapDiscussionOnlyTitle" + } + } + } + }, "handlers.MapLeaderboardsResponse": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 98bd042..b20f762 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -18,6 +18,16 @@ definitions: game: $ref: '#/definitions/models.Game' type: object + handlers.CreateMapDiscussionRequest: + properties: + content: + type: string + title: + type: string + required: + - content + - title + type: object handlers.CreateMapSummaryRequest: properties: category_id: @@ -46,6 +56,16 @@ definitions: required: - route_id type: object + handlers.EditMapDiscussionRequest: + properties: + content: + type: string + title: + type: string + required: + - content + - title + type: object handlers.EditMapImageRequest: properties: image: @@ -95,6 +115,61 @@ definitions: user: $ref: '#/definitions/models.UserShort' type: object + handlers.MapDiscussion: + properties: + comments: + items: + $ref: '#/definitions/handlers.MapDiscussionComment' + type: array + content: + type: string + creator: + $ref: '#/definitions/models.UserShortWithAvatar' + id: + type: integer + title: + type: string + updated_at: + description: Upvotes int `json:"upvotes"` + type: string + type: object + handlers.MapDiscussionComment: + properties: + comment: + type: string + date: + type: string + user: + $ref: '#/definitions/models.UserShortWithAvatar' + type: object + handlers.MapDiscussionOnlyTitle: + properties: + comments: + items: + $ref: '#/definitions/handlers.MapDiscussionComment' + type: array + creator: + $ref: '#/definitions/models.UserShortWithAvatar' + id: + type: integer + title: + type: string + updated_at: + description: Upvotes int `json:"upvotes"` + type: string + type: object + handlers.MapDiscussionResponse: + properties: + discussion: + $ref: '#/definitions/handlers.MapDiscussion' + type: object + handlers.MapDiscussionsResponse: + properties: + discussions: + items: + $ref: '#/definitions/handlers.MapDiscussionOnlyTitle' + type: array + type: object handlers.MapLeaderboardsResponse: properties: map: @@ -397,13 +472,13 @@ info: title: Least Portals Database API version: "1.0" paths: - /chapters/{id}: + /chapters/{chapterid}: get: description: Get maps from the specified chapter id. parameters: - description: Chapter ID in: path - name: id + name: chapterid required: true type: integer produces: @@ -442,10 +517,6 @@ paths: description: Demo File schema: type: file - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - demo /games: @@ -471,13 +542,13 @@ paths: $ref: '#/definitions/models.Response' tags: - games & chapters - /games/{id}: + /games/{gameid}: get: description: Get chapters from the specified game id. parameters: - description: Game ID in: path - name: id + name: gameid required: true type: integer produces: @@ -492,10 +563,6 @@ paths: data: $ref: '#/definitions/handlers.ChaptersResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - games & chapters /login: @@ -515,10 +582,6 @@ paths: data: $ref: '#/definitions/handlers.LoginResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - login /logs/mod: @@ -542,10 +605,6 @@ paths: data: $ref: '#/definitions/handlers.LogsResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - logs /logs/score: @@ -563,13 +622,163 @@ paths: data: $ref: '#/definitions/handlers.ScoreLogsResponse' type: object - "400": - description: Bad Request + tags: + - logs + /maps/{mapid}/discussions: + get: + description: Get map discussions with specified map id. + parameters: + - description: Map ID + in: path + name: mapid + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/models.Response' + - properties: + data: + $ref: '#/definitions/handlers.MapDiscussionsResponse' + type: object + tags: + - maps + post: + description: Create map discussion with specified map id. + parameters: + - description: JWT Token + in: header + name: Authorization + required: true + type: string + - description: Map ID + in: path + name: mapid + required: true + type: integer + - description: Discussion ID + in: path + name: discussionid + required: true + type: integer + - description: Body + in: body + name: request + required: true + schema: + $ref: '#/definitions/handlers.CreateMapDiscussionRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/models.Response' + - properties: + data: + $ref: '#/definitions/handlers.CreateMapDiscussionRequest' + type: object + tags: + - maps + /maps/{mapid}/discussions/{discussionid}: + delete: + description: Delete map summary with specified map id. + parameters: + - description: JWT Token + in: header + name: Authorization + required: true + type: string + - description: Map ID + in: path + name: mapid + required: true + type: integer + - description: Discussion ID + in: path + name: discussionid + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK schema: $ref: '#/definitions/models.Response' tags: - - logs - /maps/{id}/image: + - maps + get: + description: Get map discussion with specified map and discussion id. + parameters: + - description: Map ID + in: path + name: mapid + required: true + type: integer + - description: Discussion ID + in: path + name: discussionid + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/models.Response' + - properties: + data: + $ref: '#/definitions/handlers.MapDiscussionResponse' + type: object + tags: + - maps + put: + description: Edit map discussion with specified map id. + parameters: + - description: JWT Token + in: header + name: Authorization + required: true + type: string + - description: Map ID + in: path + name: mapid + required: true + type: integer + - description: Discussion ID + in: path + name: discussionid + required: true + type: integer + - description: Body + in: body + name: request + required: true + schema: + $ref: '#/definitions/handlers.EditMapDiscussionRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + allOf: + - $ref: '#/definitions/models.Response' + - properties: + data: + $ref: '#/definitions/handlers.EditMapDiscussionRequest' + type: object + tags: + - maps + /maps/{mapid}/image: put: description: Edit map image with specified map id. parameters: @@ -580,7 +789,7 @@ paths: type: string - description: Map ID in: path - name: id + name: mapid required: true type: integer - description: Body @@ -601,19 +810,15 @@ paths: data: $ref: '#/definitions/handlers.EditMapImageRequest' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - maps - /maps/{id}/leaderboards: + /maps/{mapid}/leaderboards: get: description: Get map leaderboards with specified id. parameters: - description: Map ID in: path - name: id + name: mapid required: true type: integer - description: 'Page Number (default: 1)' @@ -636,13 +841,9 @@ paths: data: $ref: '#/definitions/handlers.MapLeaderboardsResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - maps - /maps/{id}/record: + /maps/{mapid}/record: post: consumes: - multipart/form-data @@ -650,7 +851,7 @@ paths: parameters: - description: Map ID in: path - name: id + name: mapid required: true type: integer - description: JWT Token @@ -687,17 +888,9 @@ paths: data: $ref: '#/definitions/handlers.RecordResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/models.Response' tags: - maps - /maps/{id}/summary: + /maps/{mapid}/summary: delete: description: Delete map summary with specified map id. parameters: @@ -708,7 +901,7 @@ paths: type: string - description: Map ID in: path - name: id + name: mapid required: true type: integer - description: Body @@ -729,10 +922,6 @@ paths: data: $ref: '#/definitions/handlers.DeleteMapSummaryRequest' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - maps get: @@ -740,7 +929,7 @@ paths: parameters: - description: Map ID in: path - name: id + name: mapid required: true type: integer produces: @@ -755,10 +944,6 @@ paths: data: $ref: '#/definitions/handlers.MapSummaryResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - maps post: @@ -771,7 +956,7 @@ paths: type: string - description: Map ID in: path - name: id + name: mapid required: true type: integer - description: Body @@ -792,10 +977,6 @@ paths: data: $ref: '#/definitions/handlers.CreateMapSummaryRequest' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - maps put: @@ -808,7 +989,7 @@ paths: type: string - description: Map ID in: path - name: id + name: mapid required: true type: integer - description: Body @@ -829,10 +1010,6 @@ paths: data: $ref: '#/definitions/handlers.EditMapSummaryRequest' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - maps /profile: @@ -858,14 +1035,6 @@ paths: data: $ref: '#/definitions/handlers.ProfileResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/models.Response' tags: - users post: @@ -890,14 +1059,6 @@ paths: data: $ref: '#/definitions/handlers.ProfileResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/models.Response' tags: - users put: @@ -922,14 +1083,6 @@ paths: description: OK schema: $ref: '#/definitions/models.Response' - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' - "401": - description: Unauthorized - schema: - $ref: '#/definitions/models.Response' tags: - users /rankings: @@ -947,10 +1100,6 @@ paths: data: $ref: '#/definitions/handlers.RankingsResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - rankings /search: @@ -973,10 +1122,6 @@ paths: data: $ref: '#/definitions/handlers.SearchResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' tags: - search /token: @@ -1020,7 +1165,7 @@ paths: $ref: '#/definitions/models.Response' tags: - auth - /users/{id}: + /users/{userid}: get: consumes: - application/json @@ -1028,7 +1173,7 @@ paths: parameters: - description: User ID in: path - name: id + name: userid required: true type: integer produces: @@ -1043,14 +1188,6 @@ paths: data: $ref: '#/definitions/handlers.ProfileResponse' type: object - "400": - description: Bad Request - schema: - $ref: '#/definitions/models.Response' - "404": - description: Not Found - schema: - $ref: '#/definitions/models.Response' tags: - users swagger: "2.0" -- cgit v1.2.3