From 85a905dc3177bfd23b8bd08927bd4a7a8f1e4b6d Mon Sep 17 00:00:00 2001 From: hantmac Date: Tue, 5 May 2020 11:10:56 +0800 Subject: [PATCH] add swagger for 'config spider','docs', 'file', 'version' --- backend/docs/docs.go | 489 +++++++++++++++++++++++++++++++- backend/docs/swagger.json | 487 ++++++++++++++++++++++++++++++- backend/docs/swagger.yaml | 327 ++++++++++++++++++++- backend/routes/config_spider.go | 65 +++++ backend/routes/doc.go | 8 + backend/routes/file.go | 8 + backend/routes/stats.go | 8 + backend/routes/version.go | 8 + 8 files changed, 1387 insertions(+), 13 deletions(-) diff --git a/backend/docs/docs.go b/backend/docs/docs.go index f2bcfeb2..feaa3214 100644 --- a/backend/docs/docs.go +++ b/backend/docs/docs.go @@ -1,6 +1,6 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2020-05-04 17:53:13.810815 +0800 CST m=+0.105728870 +// 2020-05-05 11:09:10.499886 +0800 CST m=+0.084916029 package docs @@ -26,6 +26,367 @@ var doc = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/config_spiders": { + "put": { + "description": "Put config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Put config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders/{id}/config": { + "get": { + "description": "Get config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Get config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post config spider config", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Post config spider config", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders/{id}/spiderfile": { + "post": { + "description": "Post config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Post config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders/{id}/upload": { + "post": { + "description": "Upload config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Upload config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders_templates": { + "get": { + "description": "Get config spider template list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Get config spider template list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/docs": { + "get": { + "description": "Get docs", + "produces": [ + "application/json" + ], + "tags": [ + "docs" + ], + "summary": "Get docs", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/file": { + "get": { + "description": "Get file", + "produces": [ + "application/json" + ], + "tags": [ + "file" + ], + "summary": "Get file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/nodes": { "get": { "description": "Get nodes", @@ -761,16 +1122,16 @@ var doc = `{ } } }, - "/schedules": { + "/releases/latest": { "get": { - "description": "Get schedule list", + "description": "Get latest release", "produces": [ "application/json" ], "tags": [ - "schedule" + "version" ], - "summary": "Get schedule list", + "summary": "Get latest release", "parameters": [ { "type": "string", @@ -794,6 +1155,89 @@ var doc = `{ } } } + } + }, + "/schedules": { + "get": { + "description": "Get spider list", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "page num", + "name": "page_num", + "in": "query" + }, + { + "type": "string", + "description": "page size", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "keyword", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "description": "project_id", + "name": "project_id", + "in": "query" + }, + { + "type": "string", + "description": "type", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "sort_key", + "name": "sort_key", + "in": "query" + }, + { + "type": "string", + "description": "sort_direction", + "name": "sort_direction", + "in": "query" + }, + { + "type": "string", + "description": "owner_type", + "name": "owner_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } }, "put": { "description": "Put schedule", @@ -2445,6 +2889,41 @@ var doc = `{ } } }, + "/stats/home": { + "get": { + "description": "Get home stats", + "produces": [ + "application/json" + ], + "tags": [ + "version" + ], + "summary": "Get home stats", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/system/deps/": { "get": { "description": "Get all dep list", diff --git a/backend/docs/swagger.json b/backend/docs/swagger.json index bdfc7a72..47986662 100644 --- a/backend/docs/swagger.json +++ b/backend/docs/swagger.json @@ -5,6 +5,367 @@ "license": {} }, "paths": { + "/config_spiders": { + "put": { + "description": "Put config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Put config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders/{id}/config": { + "get": { + "description": "Get config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Get config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + }, + "post": { + "description": "Post config spider config", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Post config spider config", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders/{id}/spiderfile": { + "post": { + "description": "Post config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Post config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders/{id}/upload": { + "post": { + "description": "Upload config spider", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Upload config spider", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "description": "spider item", + "name": "spider", + "in": "body", + "required": true, + "schema": { + "type": "object", + "$ref": "#/definitions/model.Spider" + } + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/config_spiders_templates": { + "get": { + "description": "Get config spider template list", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "config spider" + ], + "summary": "Get config spider template list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "spider id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "json" + } + } + } + } + }, + "/docs": { + "get": { + "description": "Get docs", + "produces": [ + "application/json" + ], + "tags": [ + "docs" + ], + "summary": "Get docs", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, + "/file": { + "get": { + "description": "Get file", + "produces": [ + "application/json" + ], + "tags": [ + "file" + ], + "summary": "Get file", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/nodes": { "get": { "description": "Get nodes", @@ -740,16 +1101,16 @@ } } }, - "/schedules": { + "/releases/latest": { "get": { - "description": "Get schedule list", + "description": "Get latest release", "produces": [ "application/json" ], "tags": [ - "schedule" + "version" ], - "summary": "Get schedule list", + "summary": "Get latest release", "parameters": [ { "type": "string", @@ -773,6 +1134,89 @@ } } } + } + }, + "/schedules": { + "get": { + "description": "Get spider list", + "produces": [ + "application/json" + ], + "tags": [ + "spider" + ], + "summary": "Get spider list", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + }, + { + "type": "string", + "description": "page num", + "name": "page_num", + "in": "query" + }, + { + "type": "string", + "description": "page size", + "name": "page_size", + "in": "query" + }, + { + "type": "string", + "description": "keyword", + "name": "keyword", + "in": "query" + }, + { + "type": "string", + "description": "project_id", + "name": "project_id", + "in": "query" + }, + { + "type": "string", + "description": "type", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "sort_key", + "name": "sort_key", + "in": "query" + }, + { + "type": "string", + "description": "sort_direction", + "name": "sort_direction", + "in": "query" + }, + { + "type": "string", + "description": "owner_type", + "name": "owner_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } }, "put": { "description": "Put schedule", @@ -2424,6 +2868,41 @@ } } }, + "/stats/home": { + "get": { + "description": "Get home stats", + "produces": [ + "application/json" + ], + "tags": [ + "version" + ], + "summary": "Get home stats", + "parameters": [ + { + "type": "string", + "description": "Authorization token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "json" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "json" + } + } + } + } + }, "/system/deps/": { "get": { "description": "Get all dep list", diff --git a/backend/docs/swagger.yaml b/backend/docs/swagger.yaml index 16d6aa18..26598b52 100644 --- a/backend/docs/swagger.yaml +++ b/backend/docs/swagger.yaml @@ -477,6 +477,247 @@ info: contact: {} license: {} paths: + /config_spiders: + put: + consumes: + - application/json + description: Put config spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider item + in: body + name: spider + required: true + schema: + $ref: '#/definitions/model.Spider' + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Put config spider + tags: + - config spider + /config_spiders/{id}/config: + get: + consumes: + - application/json + description: Get config spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Get config spider + tags: + - config spider + post: + consumes: + - application/json + description: Post config spider config + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider item + in: body + name: spider + required: true + schema: + $ref: '#/definitions/model.Spider' + type: object + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Post config spider config + tags: + - config spider + /config_spiders/{id}/spiderfile: + post: + consumes: + - application/json + description: Post config spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Post config spider + tags: + - config spider + /config_spiders/{id}/upload: + post: + consumes: + - application/json + description: Upload config spider + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider item + in: body + name: spider + required: true + schema: + $ref: '#/definitions/model.Spider' + type: object + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Upload config spider + tags: + - config spider + /config_spiders_templates: + get: + consumes: + - application/json + description: Get config spider template list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: spider id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "500": + description: Internal Server Error + schema: + type: json + summary: Get config spider template list + tags: + - config spider + /docs: + get: + description: Get docs + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get docs + tags: + - docs + /file: + get: + description: Get file + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get file + tags: + - file /nodes: get: description: Get nodes @@ -969,9 +1210,9 @@ paths: summary: Get project tags tags: - project - /schedules: + /releases/latest: get: - description: Get schedule list + description: Get latest release parameters: - description: Authorization token in: header @@ -989,9 +1230,64 @@ paths: description: Bad Request schema: type: json - summary: Get schedule list + summary: Get latest release tags: - - schedule + - version + /schedules: + get: + description: Get spider list + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + - description: page num + in: query + name: page_num + type: string + - description: page size + in: query + name: page_size + type: string + - description: keyword + in: query + name: keyword + type: string + - description: project_id + in: query + name: project_id + type: string + - description: type + in: query + name: type + type: string + - description: sort_key + in: query + name: sort_key + type: string + - description: sort_direction + in: query + name: sort_direction + type: string + - description: owner_type + in: query + name: owner_type + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get spider list + tags: + - spider put: consumes: - application/json @@ -2097,6 +2393,29 @@ paths: summary: Upload spider by id tags: - spider + /stats/home: + get: + description: Get home stats + parameters: + - description: Authorization token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: json + "400": + description: Bad Request + schema: + type: json + summary: Get home stats + tags: + - version /system/deps/: get: description: Get all dep list diff --git a/backend/routes/config_spider.go b/backend/routes/config_spider.go index 52b61ff5..bb66c4a9 100644 --- a/backend/routes/config_spider.go +++ b/backend/routes/config_spider.go @@ -20,6 +20,17 @@ import ( ) // 添加可配置爬虫 + +// @Summary Put config spider +// @Description Put config spider +// @Tags config spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param spider body model.Spider true "spider item" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /config_spiders [put] func PutConfigSpider(c *gin.Context) { var spider model.Spider if err := c.ShouldBindJSON(&spider); err != nil { @@ -104,6 +115,18 @@ func PostConfigSpider(c *gin.Context) { } // 上传可配置爬虫Spiderfile + +// @Summary Upload config spider +// @Description Upload config spider +// @Tags config spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param spider body model.Spider true "spider item" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /config_spiders/{id}/upload [post] func UploadConfigSpider(c *gin.Context) { id := c.Param("id") @@ -190,6 +213,16 @@ func UploadConfigSpider(c *gin.Context) { }) } +// @Summary Post config spider +// @Description Post config spider +// @Tags config spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /config_spiders/{id}/spiderfile [post] func PostConfigSpiderSpiderfile(c *gin.Context) { type Body struct { Content string `json:"content"` @@ -249,6 +282,17 @@ func PostConfigSpiderSpiderfile(c *gin.Context) { }) } +// @Summary Post config spider config +// @Description Post config spider config +// @Tags config spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param spider body model.Spider true "spider item" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /config_spiders/{id}/config [post] func PostConfigSpiderConfig(c *gin.Context) { id := c.Param("id") @@ -296,6 +340,16 @@ func PostConfigSpiderConfig(c *gin.Context) { }) } +// @Summary Get config spider +// @Description Get config spider +// @Tags config spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /config_spiders/{id}/config [get] func GetConfigSpiderConfig(c *gin.Context) { id := c.Param("id") @@ -319,6 +373,17 @@ func GetConfigSpiderConfig(c *gin.Context) { } // 获取模版名称列表 + +// @Summary Get config spider template list +// @Description Get config spider template list +// @Tags config spider +// @Accept json +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Param id path string true "spider id" +// @Success 200 json string Response +// @Failure 500 json string Response +// @Router /config_spiders_templates [get] func GetConfigSpiderTemplateList(c *gin.Context) { var data []string for _, fInfo := range utils.ListDir("./template/spiderfile") { diff --git a/backend/routes/doc.go b/backend/routes/doc.go index 6426cdcc..f38c5431 100644 --- a/backend/routes/doc.go +++ b/backend/routes/doc.go @@ -8,6 +8,14 @@ import ( "runtime/debug" ) +// @Summary Get docs +// @Description Get docs +// @Tags docs +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /docs [get] func GetDocs(c *gin.Context) { type ResData struct { String string `json:"string"` diff --git a/backend/routes/file.go b/backend/routes/file.go index eaf43ab5..4c9f8576 100644 --- a/backend/routes/file.go +++ b/backend/routes/file.go @@ -7,6 +7,14 @@ import ( "net/http" ) +// @Summary Get file +// @Description Get file +// @Tags file +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /file [get] func GetFile(c *gin.Context) { path := c.Query("path") fileBytes, err := ioutil.ReadFile(path) diff --git a/backend/routes/stats.go b/backend/routes/stats.go index 46c1afc8..02e0993e 100644 --- a/backend/routes/stats.go +++ b/backend/routes/stats.go @@ -9,6 +9,14 @@ import ( "net/http" ) +// @Summary Get home stats +// @Description Get home stats +// @Tags version +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /stats/home [get] func GetHomeStats(c *gin.Context) { type DataOverview struct { TaskCount int `json:"task_count"` diff --git a/backend/routes/version.go b/backend/routes/version.go index f62d1387..8974e7fa 100644 --- a/backend/routes/version.go +++ b/backend/routes/version.go @@ -8,6 +8,14 @@ import ( "runtime/debug" ) +// @Summary Get latest release +// @Description Get latest release +// @Tags version +// @Produce json +// @Param Authorization header string true "Authorization token" +// @Success 200 json string Response +// @Failure 400 json string Response +// @Router /releases/latest [get] func GetLatestRelease(c *gin.Context) { latestRelease, err := services.GetLatestRelease() if err != nil {