From f04bb43856e72d3c0265bc7e2c38661fac268c7c Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sun, 24 Sep 2023 12:41:36 +0300 Subject: docs: add delete record, update discussion and main (#56) Former-commit-id: 8abea862f066e06fc31df3d5ddd921334fe76f5c --- backend/handlers/discussions.go | 1 - backend/handlers/record.go | 10 ++++++++ docs/docs.go | 53 ++++++++++++++++++++++++++++++++++------- docs/swagger.json | 53 ++++++++++++++++++++++++++++++++++------- docs/swagger.yaml | 37 ++++++++++++++++++++++------ main.go | 4 ++-- 6 files changed, 130 insertions(+), 28 deletions(-) diff --git a/backend/handlers/discussions.go b/backend/handlers/discussions.go index 605c7c3..6687a53 100644 --- a/backend/handlers/discussions.go +++ b/backend/handlers/discussions.go @@ -154,7 +154,6 @@ func FetchMapDiscussion(c *gin.Context) { // @Produce json // @Param Authorization header string true "JWT Token" // @Param mapid path int true "Map ID" -// @Param discussionid path int true "Discussion ID" // @Param request body CreateMapDiscussionRequest true "Body" // @Success 200 {object} models.Response{data=CreateMapDiscussionRequest} // @Router /maps/{mapid}/discussions [post] diff --git a/backend/handlers/record.go b/backend/handlers/record.go index 70095bf..4b0fafa 100644 --- a/backend/handlers/record.go +++ b/backend/handlers/record.go @@ -210,6 +210,16 @@ func CreateRecordWithDemo(c *gin.Context) { }) } +// DELETE Record +// +// @Description Delete record with specified map and record id. +// @Tags maps +// @Produce json +// @Param mapid path int true "Map ID" +// @Param recordid path int true "Record ID" +// @Param Authorization header string true "JWT Token" +// @Success 200 {object} models.Response +// @Router /maps/{mapid}/record/{recordid} [delete] func DeleteRecord(c *gin.Context) { mapID, err := strconv.Atoi(c.Param("mapid")) if err != nil { diff --git a/docs/docs.go b/docs/docs.go index 9712377..5a107c1 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -344,13 +344,6 @@ const docTemplate = `{ "in": "path", "required": true }, - { - "type": "integer", - "description": "Discussion ID", - "name": "discussionid", - "in": "path", - "required": true - }, { "description": "Body", "name": "request", @@ -714,6 +707,48 @@ const docTemplate = `{ } } }, + "/maps/{mapid}/record/{recordid}": { + "delete": { + "description": "Delete record with specified map and record id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Record ID", + "name": "recordid", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/maps/{mapid}/summary": { "get": { "description": "Get map summary with specified id.", @@ -1937,8 +1972,8 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ Version: "1.0", - Host: "lp.ardapektezol.com/api", - BasePath: "/v1", + Host: "lp.ardapektezol.com", + BasePath: "/api/v1", Schemes: []string{}, Title: "Least Portals Database API", Description: "Backend API endpoints for the Least Portals Database.", diff --git a/docs/swagger.json b/docs/swagger.json index 226cadd..d118ce7 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -10,8 +10,8 @@ }, "version": "1.0" }, - "host": "lp.ardapektezol.com/api", - "basePath": "/v1", + "host": "lp.ardapektezol.com", + "basePath": "/api/v1", "paths": { "/chapters/{chapterid}": { "get": { @@ -337,13 +337,6 @@ "in": "path", "required": true }, - { - "type": "integer", - "description": "Discussion ID", - "name": "discussionid", - "in": "path", - "required": true - }, { "description": "Body", "name": "request", @@ -707,6 +700,48 @@ } } }, + "/maps/{mapid}/record/{recordid}": { + "delete": { + "description": "Delete record with specified map and record id.", + "produces": [ + "application/json" + ], + "tags": [ + "maps" + ], + "parameters": [ + { + "type": "integer", + "description": "Map ID", + "name": "mapid", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "Record ID", + "name": "recordid", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "JWT Token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/maps/{mapid}/summary": { "get": { "description": "Get map summary with specified id.", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index b20f762..3e83fe8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1,4 +1,4 @@ -basePath: /v1 +basePath: /api/v1 definitions: handlers.ChapterMapsResponse: properties: @@ -462,7 +462,7 @@ definitions: user_name: type: string type: object -host: lp.ardapektezol.com/api +host: lp.ardapektezol.com info: contact: {} description: Backend API endpoints for the Least Portals Database. @@ -660,11 +660,6 @@ paths: name: mapid required: true type: integer - - description: Discussion ID - in: path - name: discussionid - required: true - type: integer - description: Body in: body name: request @@ -890,6 +885,34 @@ paths: type: object tags: - maps + /maps/{mapid}/record/{recordid}: + delete: + description: Delete record with specified map and record id. + parameters: + - description: Map ID + in: path + name: mapid + required: true + type: integer + - description: Record ID + in: path + name: recordid + required: true + type: integer + - description: JWT Token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.Response' + tags: + - maps /maps/{mapid}/summary: delete: description: Delete map summary with specified map id. diff --git a/main.go b/main.go index 868db1e..059ac5d 100644 --- a/main.go +++ b/main.go @@ -19,8 +19,8 @@ import ( // @license.name GNU General Public License, Version 2 // @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html -// @host lp.ardapektezol.com/api -// @BasePath /v1 +// @host lp.ardapektezol.com +// @BasePath /api/v1 func main() { if os.Getenv("ENV") == "PROD" { gin.SetMode(gin.ReleaseMode) -- cgit v1.2.3