add swagger for system

This commit is contained in:
hantmac
2020-05-04 07:48:02 +08:00
parent a14e166320
commit 44a35e69e5
4 changed files with 1206 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2020-05-03 19:45:55.093832 +0800 CST m=+0.085718059
// 2020-05-04 07:44:51.372978 +0800 CST m=+0.135701027
package docs
@@ -186,6 +186,279 @@ var doc = `{
}
}
},
"/nodes/{id}/deps": {
"get": {
"description": "Get dep list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get dep list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "query",
"required": true
},
{
"type": "string",
"description": "dep name",
"name": "dep_name",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/deps/install": {
"post": {
"description": "Install dep",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Install dep",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/deps/installed": {
"get": {
"description": "Get installed dep list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get installed dep list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/deps/uninstall": {
"post": {
"description": "Uninstall dep",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Uninstall dep",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/langs": {
"get": {
"description": "Get language list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get language list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/langs/install": {
"post": {
"description": "Install language",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Install language",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/system": {
"get": {
"description": "Get system info",
@@ -490,14 +763,14 @@ var doc = `{
},
"/schedules": {
"get": {
"description": "Get schedule list",
"description": "Get spider list",
"produces": [
"application/json"
],
"tags": [
"schedule"
"spider"
],
"summary": "Get schedule list",
"summary": "Get spider list",
"parameters": [
{
"type": "string",
@@ -505,6 +778,54 @@ var doc = `{
"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": {
@@ -2172,6 +2493,104 @@ var doc = `{
}
}
},
"/system/deps/": {
"get": {
"description": "Get all dep list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get all dep list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "path",
"required": true
},
{
"type": "string",
"description": "dep name",
"name": "dep_nane",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/system/deps/{lang}/{dep_name}/json": {
"get": {
"description": "Get dep json",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get dep json",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "path",
"required": true
},
{
"type": "string",
"description": "dep name",
"name": "dep_name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/task/{id}": {
"delete": {
"description": "Delete task",

View File

@@ -165,6 +165,279 @@
}
}
},
"/nodes/{id}/deps": {
"get": {
"description": "Get dep list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get dep list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "query",
"required": true
},
{
"type": "string",
"description": "dep name",
"name": "dep_name",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/deps/install": {
"post": {
"description": "Install dep",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Install dep",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/deps/installed": {
"get": {
"description": "Get installed dep list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get installed dep list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/deps/uninstall": {
"post": {
"description": "Uninstall dep",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Uninstall dep",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/langs": {
"get": {
"description": "Get language list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get language list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/langs/install": {
"post": {
"description": "Install language",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Install language",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "node id",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/nodes/{id}/system": {
"get": {
"description": "Get system info",
@@ -469,14 +742,14 @@
},
"/schedules": {
"get": {
"description": "Get schedule list",
"description": "Get spider list",
"produces": [
"application/json"
],
"tags": [
"schedule"
"spider"
],
"summary": "Get schedule list",
"summary": "Get spider list",
"parameters": [
{
"type": "string",
@@ -484,6 +757,54 @@
"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": {
@@ -2151,6 +2472,104 @@
}
}
},
"/system/deps/": {
"get": {
"description": "Get all dep list",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get all dep list",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "path",
"required": true
},
{
"type": "string",
"description": "dep name",
"name": "dep_nane",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/system/deps/{lang}/{dep_name}/json": {
"get": {
"description": "Get dep json",
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Get dep json",
"parameters": [
{
"type": "string",
"description": "Authorization token",
"name": "Authorization",
"in": "header",
"required": true
},
{
"type": "string",
"description": "language",
"name": "lang",
"in": "path",
"required": true
},
{
"type": "string",
"description": "dep name",
"name": "dep_name",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "json"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "json"
}
}
}
}
},
"/task/{id}": {
"delete": {
"description": "Delete task",

View File

@@ -514,6 +514,189 @@ paths:
summary: Post node
tags:
- node
/nodes/{id}/deps:
get:
description: Get dep list
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: node id
in: path
name: id
required: true
type: string
- description: language
in: query
name: lang
required: true
type: string
- description: dep name
in: query
name: dep_name
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Get dep list
tags:
- system
/nodes/{id}/deps/install:
post:
description: Install dep
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: node id
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Install dep
tags:
- system
/nodes/{id}/deps/installed:
get:
description: Get installed dep list
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: node id
in: path
name: id
required: true
type: string
- description: language
in: query
name: lang
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Get installed dep list
tags:
- system
/nodes/{id}/deps/uninstall:
post:
description: Uninstall dep
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: node id
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Uninstall dep
tags:
- system
/nodes/{id}/langs:
get:
description: Get language list
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: node id
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Get language list
tags:
- system
/nodes/{id}/langs/install:
post:
description: Install language
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: node id
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Install language
tags:
- system
/nodes/{id}/system:
get:
description: Get system info
@@ -718,13 +901,45 @@ paths:
- project
/schedules:
get:
description: Get schedule list
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:
@@ -736,9 +951,9 @@ paths:
description: Bad Request
schema:
type: json
summary: Get schedule list
summary: Get spider list
tags:
- schedule
- spider
put:
consumes:
- application/json
@@ -1844,6 +2059,72 @@ paths:
summary: Upload spider by id
tags:
- spider
/system/deps/:
get:
description: Get all dep list
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: language
in: path
name: lang
required: true
type: string
- description: dep name
in: query
name: dep_nane
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Get all dep list
tags:
- system
/system/deps/{lang}/{dep_name}/json:
get:
description: Get dep json
parameters:
- description: Authorization token
in: header
name: Authorization
required: true
type: string
- description: language
in: path
name: lang
required: true
type: string
- description: dep name
in: path
name: dep_name
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
type: json
"400":
description: Bad Request
schema:
type: json
summary: Get dep json
tags:
- system
/task/{id}:
delete:
description: Delete task

View File

@@ -11,6 +11,15 @@ import (
"strings"
)
// @Summary Get language list
// @Description Get language list
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/langs [get]
func GetLangList(c *gin.Context) {
nodeId := c.Param("id")
c.JSON(http.StatusOK, Response{
@@ -20,6 +29,17 @@ func GetLangList(c *gin.Context) {
})
}
// @Summary Get dep list
// @Description Get dep list
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param id path string true "node id"
// @Param lang query string true "language"
// @Param dep_name query string true "dep name"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/deps [get]
func GetDepList(c *gin.Context) {
nodeId := c.Param("id")
lang := c.Query("lang")
@@ -52,6 +72,16 @@ func GetDepList(c *gin.Context) {
})
}
// @Summary Get installed dep list
// @Description Get installed dep list
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param id path string true "node id"
// @Param lang query string true "language"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/deps/installed [get]
func GetInstalledDepList(c *gin.Context) {
nodeId := c.Param("id")
lang := c.Query("lang")
@@ -79,6 +109,16 @@ func GetInstalledDepList(c *gin.Context) {
})
}
// @Summary Get all dep list
// @Description Get all dep list
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param lang path string true "language"
// @Param dep_nane query string true "dep name"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /system/deps/:lang [get]
func GetAllDepList(c *gin.Context) {
lang := c.Param("lang")
depName := c.Query("dep_name")
@@ -121,6 +161,15 @@ func GetAllDepList(c *gin.Context) {
})
}
// @Summary Install dep
// @Description Install dep
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/deps/install [Post]
func InstallDep(c *gin.Context) {
type ReqBody struct {
Lang string `json:"lang"`
@@ -153,6 +202,15 @@ func InstallDep(c *gin.Context) {
})
}
// @Summary Uninstall dep
// @Description Uninstall dep
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/deps/uninstall [Post]
func UninstallDep(c *gin.Context) {
type ReqBody struct {
Lang string `json:"lang"`
@@ -184,6 +242,16 @@ func UninstallDep(c *gin.Context) {
})
}
// @Summary Get dep json
// @Description Get dep json
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param lang path string true "language"
// @Param dep_name path string true "dep name"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /system/deps/{lang}/{dep_name}/json [get]
func GetDepJson(c *gin.Context) {
depName := c.Param("dep_name")
lang := c.Param("lang")
@@ -209,6 +277,15 @@ func GetDepJson(c *gin.Context) {
})
}
// @Summary Install language
// @Description Install language
// @Tags system
// @Produce json
// @Param Authorization header string true "Authorization token"
// @Param id path string true "node id"
// @Success 200 json string Response
// @Failure 400 json string Response
// @Router /nodes/{id}/langs/install [Post]
func InstallLang(c *gin.Context) {
type ReqBody struct {
Lang string `json:"lang"`