diff --git a/docs/docs.go b/docs/docs.go index 72edffea..1e94494a 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,10 +1,13 @@ // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2018-04-15 16:49:38.431538396 +0800 HKT m=+0.041242537 +// 2019-02-02 17:46:50.428407 +0800 CST m=+0.087414608 package docs import ( + "bytes" + + "github.com/alecthomas/template" "github.com/swaggo/swag" ) @@ -21,38 +24,54 @@ var doc = `{ }, "version": "1.0" }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", "paths": { "/api/v1/articles": { "get": { "produces": [ "application/json" ], - "summary": "获取多个文章", + "summary": "Get multiple articles", "parameters": [ { - "type": "integer", "description": "TagID", "name": "tag_id", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "CreatedBy", "name": "created_by", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":[{\"id\":3,\"created_on\":1516937037,\"modified_on\":0,\"tag_id\":11,\"tag\":{\"id\":11,\"created_on\":1516851591,\"modified_on\":0,\"name\":\"312321\",\"created_by\":\"4555\",\"modified_by\":\"\",\"state\":1},\"content\":\"5555\",\"created_by\":\"2412\",\"modified_by\":\"\",\"state\":1}],\"msg\":\"ok\"}", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -61,56 +80,76 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "新增文章", + "summary": "Add article", "parameters": [ { - "type": "integer", "description": "TagID", "name": "tag_id", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Title", "name": "title", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Desc", "name": "desc", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Content", "name": "content", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "CreatedBy", "name": "created_by", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -121,15 +160,29 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "获取单个文章", + "summary": "Get a single article", "parameters": [ - {} + { + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{\"id\":3,\"created_on\":1516937037,\"modified_on\":0,\"tag_id\":11,\"tag\":{\"id\":11,\"created_on\":1516851591,\"modified_on\":0,\"name\":\"312321\",\"created_by\":\"4555\",\"modified_by\":\"\",\"state\":1},\"content\":\"5555\",\"created_by\":\"2412\",\"modified_by\":\"\",\"state\":1},\"msg\":\"ok\"}", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -138,52 +191,78 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "修改文章", + "summary": "Update article", "parameters": [ - {}, { - "type": "string", + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + }, + { "description": "TagID", "name": "tag_id", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Title", "name": "title", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Desc", "name": "desc", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Content", "name": "content", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "ModifiedBy", "name": "modified_by", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":400,\"data\":{},\"msg\":\"请求参数错误\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -192,15 +271,29 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "删除文章", + "summary": "Delete article", "parameters": [ - {} + { + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + } ], "responses": { "200": { - "description": "{\"code\":400,\"data\":{},\"msg\":\"请求参数错误\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -211,7 +304,7 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "获取多个文章标签", + "summary": "Get multiple article tags", "parameters": [ { "type": "string", @@ -228,9 +321,17 @@ var doc = `{ ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{\"lists\":[{\"id\":3,\"created_on\":1516849721,\"modified_on\":0,\"name\":\"3333\",\"created_by\":\"4555\",\"modified_by\":\"\",\"state\":0}],\"total\":29},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -239,33 +340,124 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "新增文章标签", + "summary": "Add article tag", "parameters": [ { - "type": "string", "description": "Name", "name": "name", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "CreatedBy", "name": "created_by", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/tags/export": { + "post": { + "produces": [ + "application/json" + ], + "summary": "Export article tag", + "parameters": [ + { + "description": "Name", + "name": "name", + "in": "body", + "schema": { + "type": "object" + } + }, + { + "description": "State", + "name": "state", + "in": "body", + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/tags/import": { + "post": { + "produces": [ + "application/json" + ], + "summary": "Import article tag", + "parameters": [ + { + "description": "Excel File", + "name": "file", + "in": "body", + "required": true, + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -276,35 +468,55 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "修改文章标签", + "summary": "Update article tag", "parameters": [ - {}, { - "type": "string", + "type": "integer", "description": "ID", - "name": "name", - "in": "query", + "name": "id", + "in": "path", "required": true }, { - "type": "integer", + "description": "ID", + "name": "name", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + }, + { "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "ModifiedBy", "name": "modified_by", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -313,28 +525,80 @@ var doc = `{ "produces": [ "application/json" ], - "summary": "删除文章标签", + "summary": "Delete article tag", "parameters": [ - {} + { + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } } } + }, + "definitions": { + "app.Response": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "data": { + "type": "object" + }, + "msg": { + "type": "string" + } + } + } } }` +type swaggerInfo struct { + Version string + Host string + BasePath string + Title string + Description string +} + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo swaggerInfo + type s struct{} func (s *s) ReadDoc() string { - return doc + t, err := template.New("swagger_info").Parse(doc) + if err != nil { + return doc + } + + var tpl bytes.Buffer + if err := t.Execute(&tpl, SwaggerInfo); err != nil { + return doc + } + + return tpl.String() } + func init() { swag.Register(swag.Name, &s{}) } diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index e6532045..82d1b749 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -11,38 +11,54 @@ }, "version": "1.0" }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", "paths": { "/api/v1/articles": { "get": { "produces": [ "application/json" ], - "summary": "获取多个文章", + "summary": "Get multiple articles", "parameters": [ { - "type": "integer", "description": "TagID", "name": "tag_id", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "CreatedBy", "name": "created_by", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":[{\"id\":3,\"created_on\":1516937037,\"modified_on\":0,\"tag_id\":11,\"tag\":{\"id\":11,\"created_on\":1516851591,\"modified_on\":0,\"name\":\"312321\",\"created_by\":\"4555\",\"modified_by\":\"\",\"state\":1},\"content\":\"5555\",\"created_by\":\"2412\",\"modified_by\":\"\",\"state\":1}],\"msg\":\"ok\"}", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -51,56 +67,76 @@ "produces": [ "application/json" ], - "summary": "新增文章", + "summary": "Add article", "parameters": [ { - "type": "integer", "description": "TagID", "name": "tag_id", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Title", "name": "title", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Desc", "name": "desc", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Content", "name": "content", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "string", "description": "CreatedBy", "name": "created_by", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -111,15 +147,29 @@ "produces": [ "application/json" ], - "summary": "获取单个文章", + "summary": "Get a single article", "parameters": [ - {} + { + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{\"id\":3,\"created_on\":1516937037,\"modified_on\":0,\"tag_id\":11,\"tag\":{\"id\":11,\"created_on\":1516851591,\"modified_on\":0,\"name\":\"312321\",\"created_by\":\"4555\",\"modified_by\":\"\",\"state\":1},\"content\":\"5555\",\"created_by\":\"2412\",\"modified_by\":\"\",\"state\":1},\"msg\":\"ok\"}", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -128,52 +178,78 @@ "produces": [ "application/json" ], - "summary": "修改文章", + "summary": "Update article", "parameters": [ - {}, { - "type": "string", + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + }, + { "description": "TagID", "name": "tag_id", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Title", "name": "title", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Desc", "name": "desc", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "Content", "name": "content", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "ModifiedBy", "name": "modified_by", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":400,\"data\":{},\"msg\":\"请求参数错误\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -182,15 +258,29 @@ "produces": [ "application/json" ], - "summary": "删除文章", + "summary": "Delete article", "parameters": [ - {} + { + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + } ], "responses": { "200": { - "description": "{\"code\":400,\"data\":{},\"msg\":\"请求参数错误\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -201,7 +291,7 @@ "produces": [ "application/json" ], - "summary": "获取多个文章标签", + "summary": "Get multiple article tags", "parameters": [ { "type": "string", @@ -218,9 +308,17 @@ ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{\"lists\":[{\"id\":3,\"created_on\":1516849721,\"modified_on\":0,\"name\":\"3333\",\"created_by\":\"4555\",\"modified_by\":\"\",\"state\":0}],\"total\":29},\"msg\":\"ok\"}", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -229,33 +327,124 @@ "produces": [ "application/json" ], - "summary": "新增文章标签", + "summary": "Add article tag", "parameters": [ { - "type": "string", "description": "Name", "name": "name", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "integer", "description": "CreatedBy", "name": "created_by", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/tags/export": { + "post": { + "produces": [ + "application/json" + ], + "summary": "Export article tag", + "parameters": [ + { + "description": "Name", + "name": "name", + "in": "body", + "schema": { + "type": "object" + } + }, + { + "description": "State", + "name": "state", + "in": "body", + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + } + } + } + }, + "/api/v1/tags/import": { + "post": { + "produces": [ + "application/json" + ], + "summary": "Import article tag", + "parameters": [ + { + "description": "Excel File", + "name": "file", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -266,35 +455,55 @@ "produces": [ "application/json" ], - "summary": "修改文章标签", + "summary": "Update article tag", "parameters": [ - {}, { - "type": "string", + "type": "integer", "description": "ID", - "name": "name", - "in": "query", + "name": "id", + "in": "path", "required": true }, { - "type": "integer", + "description": "ID", + "name": "name", + "in": "body", + "required": true, + "schema": { + "type": "object" + } + }, + { "description": "State", "name": "state", - "in": "query" + "in": "body", + "schema": { + "type": "object" + } }, { - "type": "string", "description": "ModifiedBy", "name": "modified_by", - "in": "query", - "required": true + "in": "body", + "required": true, + "schema": { + "type": "object" + } } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" } } } @@ -303,19 +512,49 @@ "produces": [ "application/json" ], - "summary": "删除文章标签", + "summary": "Delete article tag", "parameters": [ - {} + { + "type": "integer", + "description": "ID", + "name": "id", + "in": "path", + "required": true + } ], "responses": { "200": { - "description": "{\"code\":200,\"data\":{},\"msg\":\"ok\"}", + "description": "OK", "schema": { - "type": "string" + "type": "object", + "$ref": "#/definitions/app.Response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "$ref": "#/definitions/app.Response" } } } } } + }, + "definitions": { + "app.Response": { + "type": "object", + "properties": { + "code": { + "type": "integer" + }, + "data": { + "type": "object" + }, + "msg": { + "type": "string" + } + } + } } } \ No newline at end of file diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 94b7d2d9..a581267a 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -1,3 +1,15 @@ +basePath: '{{.BasePath}}' +definitions: + app.Response: + properties: + code: + type: integer + data: + type: object + msg: + type: string + type: object +host: '{{.Host}}' info: contact: {} description: An example of gin @@ -12,124 +24,181 @@ paths: get: parameters: - description: TagID - in: query + in: body name: tag_id - type: integer + schema: + type: object - description: State - in: query + in: body name: state - type: integer + schema: + type: object - description: CreatedBy - in: query + in: body name: created_by - type: integer + schema: + type: object produces: - application/json responses: "200": - description: '{"code":200,"data":[{"id":3,"created_on":1516937037,"modified_on":0,"tag_id":11,"tag":{"id":11,"created_on":1516851591,"modified_on":0,"name":"312321","created_by":"4555","modified_by":"","state":1},"content":"5555","created_by":"2412","modified_by":"","state":1}],"msg":"ok"}' + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error schema: - type: string - summary: 获取多个文章 + $ref: '#/definitions/app.Response' + type: object + summary: Get multiple articles post: parameters: - description: TagID - in: query + in: body name: tag_id required: true - type: integer + schema: + type: object - description: Title - in: query + in: body name: title required: true - type: string + schema: + type: object - description: Desc - in: query + in: body name: desc required: true - type: string + schema: + type: object - description: Content - in: query + in: body name: content required: true - type: string + schema: + type: object - description: CreatedBy - in: query + in: body name: created_by required: true - type: string + schema: + type: object - description: State - in: query + in: body name: state required: true - type: integer + schema: + type: object produces: - application/json responses: "200": - description: '{"code":200,"data":{},"msg":"ok"}' + description: OK schema: - type: string - summary: 新增文章 + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/app.Response' + type: object + summary: Add article /api/v1/articles/{id}: delete: parameters: - - {} + - description: ID + in: path + name: id + required: true + type: integer produces: - application/json responses: "200": - description: '{"code":400,"data":{},"msg":"请求参数错误"}' + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error schema: - type: string - summary: 删除文章 + $ref: '#/definitions/app.Response' + type: object + summary: Delete article get: parameters: - - {} + - description: ID + in: path + name: id + required: true + type: integer produces: - application/json responses: "200": - description: '{"code":200,"data":{"id":3,"created_on":1516937037,"modified_on":0,"tag_id":11,"tag":{"id":11,"created_on":1516851591,"modified_on":0,"name":"312321","created_by":"4555","modified_by":"","state":1},"content":"5555","created_by":"2412","modified_by":"","state":1},"msg":"ok"}' + description: OK schema: - type: string - summary: 获取单个文章 + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/app.Response' + type: object + summary: Get a single article put: parameters: - - {} + - description: ID + in: path + name: id + required: true + type: integer - description: TagID - in: query + in: body name: tag_id - type: string + schema: + type: object - description: Title - in: query + in: body name: title - type: string + schema: + type: object - description: Desc - in: query + in: body name: desc - type: string + schema: + type: object - description: Content - in: query + in: body name: content - type: string + schema: + type: object - description: ModifiedBy - in: query + in: body name: modified_by required: true - type: string + schema: + type: object - description: State - in: query + in: body name: state - type: integer + schema: + type: object produces: - application/json responses: "200": - description: '{"code":400,"data":{},"msg":"请求参数错误"}' + description: OK schema: - type: string - summary: 修改文章 + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/app.Response' + type: object + summary: Update article /api/v1/tags: get: parameters: @@ -145,68 +214,156 @@ paths: - application/json responses: "200": - description: '{"code":200,"data":{"lists":[{"id":3,"created_on":1516849721,"modified_on":0,"name":"3333","created_by":"4555","modified_by":"","state":0}],"total":29},"msg":"ok"}' + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error schema: - type: string - summary: 获取多个文章标签 + $ref: '#/definitions/app.Response' + type: object + summary: Get multiple article tags post: parameters: - description: Name - in: query + in: body name: name required: true - type: string + schema: + type: object - description: State - in: query + in: body name: state - type: integer + schema: + type: object - description: CreatedBy - in: query + in: body name: created_by - type: integer + schema: + type: object produces: - application/json responses: "200": - description: '{"code":200,"data":{},"msg":"ok"}' + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error schema: - type: string - summary: 新增文章标签 + $ref: '#/definitions/app.Response' + type: object + summary: Add article tag /api/v1/tags/{id}: delete: parameters: - - {} + - description: ID + in: path + name: id + required: true + type: integer produces: - application/json responses: "200": - description: '{"code":200,"data":{},"msg":"ok"}' + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error schema: - type: string - summary: 删除文章标签 + $ref: '#/definitions/app.Response' + type: object + summary: Delete article tag put: parameters: - - {} - description: ID - in: query + in: path + name: id + required: true + type: integer + - description: ID + in: body name: name required: true - type: string + schema: + type: object - description: State - in: query + in: body name: state - type: integer + schema: + type: object - description: ModifiedBy - in: query + in: body name: modified_by required: true - type: string + schema: + type: object produces: - application/json responses: "200": - description: '{"code":200,"data":{},"msg":"ok"}' + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/app.Response' + type: object + summary: Update article tag + /api/v1/tags/export: + post: + parameters: + - description: Name + in: body + name: name + schema: + type: object + - description: State + in: body + name: state + schema: + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/app.Response' + type: object + summary: Export article tag + /api/v1/tags/import: + post: + parameters: + - description: Excel File + in: body + name: file + required: true + schema: + type: object + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/app.Response' + type: object + "500": + description: Internal Server Error schema: - type: string - summary: 修改文章标签 + $ref: '#/definitions/app.Response' + type: object + summary: Import article tag swagger: "2.0" diff --git a/pkg/app/response.go b/pkg/app/response.go index 84da3f4c..bce6ae20 100644 --- a/pkg/app/response.go +++ b/pkg/app/response.go @@ -10,12 +10,17 @@ type Gin struct { C *gin.Context } +type Response struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data interface{} `json:"data"` +} + func (g *Gin) Response(httpCode, errCode int, data interface{}) { - g.C.JSON(httpCode, gin.H{ - "code": httpCode, - "msg": e.GetMsg(errCode), - "data": data, + g.C.JSON(httpCode, Response{ + Code: httpCode, + Msg: e.GetMsg(errCode), + Data: data, }) - return } diff --git a/routers/api/upload.go b/routers/api/upload.go index 6215353f..3fd1a1c5 100644 --- a/routers/api/upload.go +++ b/routers/api/upload.go @@ -11,10 +11,11 @@ import ( "github.com/EDDYCJY/go-gin-example/pkg/upload" ) -// @Summary 上传图片 +// @Summary Import Image // @Produce json -// @Param image post file true "图片文件" -// @Success 200 {string} json "{"code":200,"data":{"image_save_url":"upload/images/96a.jpg", "image_url": "http://..."}" +// @Param image formData file true "Image File" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags/import [post] func UploadImage(c *gin.Context) { appG := app.Gin{C: c} diff --git a/routers/api/v1/article.go b/routers/api/v1/article.go index 2a7aac5f..8e88de93 100755 --- a/routers/api/v1/article.go +++ b/routers/api/v1/article.go @@ -17,16 +17,17 @@ import ( "github.com/EDDYCJY/go-gin-example/service/tag_service" ) -// @Summary 获取单个文章 +// @Summary Get a single article // @Produce json -// @Param id param int true "ID" -// @Success 200 {string} json "{"code":200,"data":{"id":3,"created_on":1516937037,"modified_on":0,"tag_id":11,"tag":{"id":11,"created_on":1516851591,"modified_on":0,"name":"312321","created_by":"4555","modified_by":"","state":1},"content":"5555","created_by":"2412","modified_by":"","state":1},"msg":"ok"}" +// @Param id path int true "ID" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/articles/{id} [get] func GetArticle(c *gin.Context) { appG := app.Gin{C: c} id := com.StrTo(c.Param("id")).MustInt() valid := validation.Validation{} - valid.Min(id, 1, "id").Message("ID必须大于0") + valid.Min(id, 1, "id") if valid.HasErrors() { app.MarkErrors(valid.Errors) @@ -54,12 +55,13 @@ func GetArticle(c *gin.Context) { appG.Response(http.StatusOK, e.SUCCESS, article) } -// @Summary 获取多个文章 +// @Summary Get multiple articles // @Produce json -// @Param tag_id query int false "TagID" -// @Param state query int false "State" -// @Param created_by query int false "CreatedBy" -// @Success 200 {string} json "{"code":200,"data":[{"id":3,"created_on":1516937037,"modified_on":0,"tag_id":11,"tag":{"id":11,"created_on":1516851591,"modified_on":0,"name":"312321","created_by":"4555","modified_by":"","state":1},"content":"5555","created_by":"2412","modified_by":"","state":1}],"msg":"ok"}" +// @Param tag_id body int false "TagID" +// @Param state body int false "State" +// @Param created_by body int false "CreatedBy" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/articles [get] func GetArticles(c *gin.Context) { appG := app.Gin{C: c} @@ -68,13 +70,13 @@ func GetArticles(c *gin.Context) { state := -1 if arg := c.PostForm("state"); arg != "" { state = com.StrTo(arg).MustInt() - valid.Range(state, 0, 1, "state").Message("状态只允许0或1") + valid.Range(state, 0, 1, "state") } tagId := -1 if arg := c.PostForm("tag_id"); arg != "" { tagId = com.StrTo(arg).MustInt() - valid.Min(tagId, 1, "tag_id").Message("标签ID必须大于0") + valid.Min(tagId, 1, "tag_id") } if valid.HasErrors() { @@ -119,15 +121,16 @@ type AddArticleForm struct { State int `form:"state" valid:"Range(0,1)"` } -// @Summary 新增文章 +// @Summary Add article // @Produce json -// @Param tag_id query int true "TagID" -// @Param title query string true "Title" -// @Param desc query string true "Desc" -// @Param content query string true "Content" -// @Param created_by query string true "CreatedBy" -// @Param state query int true "State" -// @Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}" +// @Param tag_id body int true "TagID" +// @Param title body string true "Title" +// @Param desc body string true "Desc" +// @Param content body string true "Content" +// @Param created_by body string true "CreatedBy" +// @Param state body int true "State" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/articles [post] func AddArticle(c *gin.Context) { var ( @@ -180,17 +183,17 @@ type EditArticleForm struct { State int `form:"state" valid:"Range(0,1)"` } -// @Summary 修改文章 +// @Summary Update article // @Produce json -// @Param id param int true "ID" -// @Param tag_id query string false "TagID" -// @Param title query string false "Title" -// @Param desc query string false "Desc" -// @Param content query string false "Content" -// @Param modified_by query string true "ModifiedBy" -// @Param state query int false "State" -// @Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}" -// @Failure 200 {string} json "{"code":400,"data":{},"msg":"请求参数错误"}" +// @Param id path int true "ID" +// @Param tag_id body string false "TagID" +// @Param title body string false "Title" +// @Param desc body string false "Desc" +// @Param content body string false "Content" +// @Param modified_by body string true "ModifiedBy" +// @Param state body int false "State" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/articles/{id} [put] func EditArticle(c *gin.Context) { var ( @@ -205,7 +208,7 @@ func EditArticle(c *gin.Context) { } articleService := article_service.Article{ - ID: form.ID, + ID: form.ID, TagID: form.TagID, Title: form.Title, Desc: form.Desc, @@ -245,11 +248,11 @@ func EditArticle(c *gin.Context) { appG.Response(http.StatusOK, e.SUCCESS, nil) } -// @Summary 删除文章 +// @Summary Delete article // @Produce json -// @Param id param int true "ID" -// @Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}" -// @Failure 200 {string} json "{"code":400,"data":{},"msg":"请求参数错误"}" +// @Param id path int true "ID" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/articles/{id} [delete] func DeleteArticle(c *gin.Context) { appG := app.Gin{C: c} diff --git a/routers/api/v1/tag.go b/routers/api/v1/tag.go index 70f3ecee..51f98479 100755 --- a/routers/api/v1/tag.go +++ b/routers/api/v1/tag.go @@ -16,11 +16,12 @@ import ( "github.com/EDDYCJY/go-gin-example/service/tag_service" ) -// @Summary 获取多个文章标签 +// @Summary Get multiple article tags // @Produce json // @Param name query string false "Name" // @Param state query int false "State" -// @Success 200 {string} json "{"code":200,"data":{"lists":[{"id":3,"created_on":1516849721,"modified_on":0,"name":"3333","created_by":"4555","modified_by":"","state":0}],"total":29},"msg":"ok"}" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags [get] func GetTags(c *gin.Context) { appG := app.Gin{C: c} @@ -60,12 +61,13 @@ type AddTagForm struct { State int `form:"state" valid:"Range(0,1)"` } -// @Summary 新增文章标签 +// @Summary Add article tag // @Produce json -// @Param name query string true "Name" -// @Param state query int false "State" -// @Param created_by query int false "CreatedBy" -// @Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}" +// @Param name body string true "Name" +// @Param state body int false "State" +// @Param created_by body int false "CreatedBy" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags [post] func AddTag(c *gin.Context) { var ( @@ -110,13 +112,14 @@ type EditTagForm struct { State int `form:"state" valid:"Range(0,1)"` } -// @Summary 修改文章标签 +// @Summary Update article tag // @Produce json -// @Param id param int true "ID" -// @Param name query string true "ID" -// @Param state query int false "State" -// @Param modified_by query string true "ModifiedBy" -// @Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}" +// @Param id path int true "ID" +// @Param name body string true "ID" +// @Param state body int false "State" +// @Param modified_by body string true "ModifiedBy" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags/{id} [put] func EditTag(c *gin.Context) { var ( @@ -157,10 +160,11 @@ func EditTag(c *gin.Context) { appG.Response(http.StatusOK, e.SUCCESS, nil) } -// @Summary 删除文章标签 +// @Summary Delete article tag // @Produce json -// @Param id param int true "ID" -// @Success 200 {string} json "{"code":200,"data":{},"msg":"ok"}" +// @Param id path int true "ID" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags/{id} [delete] func DeleteTag(c *gin.Context) { appG := app.Gin{C: c} @@ -193,11 +197,12 @@ func DeleteTag(c *gin.Context) { appG.Response(http.StatusOK, e.SUCCESS, nil) } -// @Summary 导出文章标签 +// @Summary Export article tag // @Produce json -// @Param name post string false "Name" -// @Param state post int false "State" -// @Success 200 {string} json "{"code":200,"data":{"export_save_url":"export/abc.xlsx", "export_url": "http://..."},"msg":"ok"}" +// @Param name body string false "Name" +// @Param state body int false "State" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags/export [post] func ExportTag(c *gin.Context) { appG := app.Gin{C: c} @@ -224,10 +229,11 @@ func ExportTag(c *gin.Context) { }) } -// @Summary 导入文章标签 +// @Summary Import article tag // @Produce json -// @Param file post file true "标签Excel文件" -// @Success 200 {string} json "{"code":200,"data":null,"msg":"ok"}" +// @Param file body file true "Excel File" +// @Success 200 {object} app.Response +// @Failure 500 {object} app.Response // @Router /api/v1/tags/import [post] func ImportTag(c *gin.Context) { appG := app.Gin{C: c} diff --git a/vendor/github.com/swaggo/gin-swagger/README.md b/vendor/github.com/swaggo/gin-swagger/README.md index 2820ff23..d4b27fcd 100644 --- a/vendor/github.com/swaggo/gin-swagger/README.md +++ b/vendor/github.com/swaggo/gin-swagger/README.md @@ -11,10 +11,10 @@ gin middleware to automatically generate RESTful API documentation with Swagger ## Usage ### Start using it -1. Add comments to your API source code, [See Declarative Comments Format](https://github.com/swaggo/swag#declarative-comments-format). +1. Add comments to your API source code, [See Declarative Comments Format](https://swaggo.github.io/swaggo.io/declarative_comments_format/). 2. Download [Swag](https://github.com/swaggo/swag) for Go by using: ```sh -$ go get github.com/swaggo/swag/cmd/swag +$ go get -u github.com/swaggo/swag/cmd/swag ``` 3. Run the [Swag](https://github.com/swaggo/swag) in your Go project root folder which contains `main.go` file, [Swag](https://github.com/swaggo/swag) will parse comments and generate required files(`docs` folder and `docs/doc.go`). @@ -75,3 +75,44 @@ func main() { ![swagger_index.html](https://user-images.githubusercontent.com/8943871/31943004-dd08a10e-b88c-11e7-9e77-19d2c759a586.png) +6. If you want to disable swagger when some environment variable is set, use `DisablingWrapHandler` + +### Example with disabling: + +```go +package main + +import ( + "github.com/gin-gonic/gin" + "github.com/swaggo/gin-swagger" + "github.com/swaggo/gin-swagger/swaggerFiles" + + _ "./docs" // docs is generated by Swag CLI, you have to import it. +) + +// @title Swagger Example API +// @version 1.0 +// @description This is a sample server Petstore server. +// @termsOfService http://swagger.io/terms/ + +// @contact.name API Support +// @contact.url http://www.swagger.io/support +// @contact.email support@swagger.io + +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html + +// @host petstore.swagger.io +// @BasePath /v2 +func main() { + r := gin.New() + + // use ginSwagger middleware to + r.GET("/swagger/*any", ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "NAME_OF_ENV_VARIABLE")) + + r.Run() +} +``` + +Then, if you set envioment variable `NAME_OF_ENV_VARIABLE` to anything, `/swagger/*any` +will respond 404, just like when route unspecified. diff --git a/vendor/github.com/swaggo/gin-swagger/go.mod b/vendor/github.com/swaggo/gin-swagger/go.mod new file mode 100644 index 00000000..a0740e3e --- /dev/null +++ b/vendor/github.com/swaggo/gin-swagger/go.mod @@ -0,0 +1,18 @@ +module github.com/swaggo/gin-swagger + +require ( + github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect + github.com/gin-gonic/gin v1.3.0 + github.com/go-openapi/jsonreference v0.18.0 // indirect + github.com/go-openapi/spec v0.18.0 // indirect + github.com/golang/protobuf v1.2.0 // indirect + github.com/mattn/go-isatty v0.0.4 // indirect + github.com/pkg/errors v0.8.1 // indirect + github.com/stretchr/testify v1.3.0 + github.com/swaggo/swag v1.4.0 + github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect + golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e + golang.org/x/tools v0.0.0-20190110015856-aa033095749b // indirect + gopkg.in/go-playground/validator.v8 v8.18.2 // indirect + gopkg.in/yaml.v2 v2.2.2 // indirect +) diff --git a/vendor/github.com/swaggo/gin-swagger/go.sum b/vendor/github.com/swaggo/gin-swagger/go.sum new file mode 100644 index 00000000..dca68129 --- /dev/null +++ b/vendor/github.com/swaggo/gin-swagger/go.sum @@ -0,0 +1,52 @@ +github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 h1:AzN37oI0cOS+cougNAV9szl6CVoj2RYwzS3DpUQNtlY= +github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= +github.com/gin-gonic/gin v1.3.0 h1:kCmZyPklC0gVdL728E6Aj20uYBJV93nj/TkwBTKhFbs= +github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y= +github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.18.0 h1:oP2OUNdG1l2r5kYhrfVMXO54gWmzcfAwP/GFuHpNTkE= +github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/spec v0.18.0 h1:aIjeyG5mo5/FrvDkpKKEGZPmF9MPHahS72mzfVqeQXQ= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/swaggo/swag v1.4.0 h1:exX5ES4CdJWCCKmVPE+FAIN66cnHeMHU3i2SCMibBZc= +github.com/swaggo/swag v1.4.0/go.mod h1:hog2WgeMOrQ/LvQ+o1YGTeT+vWVrbi0SiIslBtxKTyM= +github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 h1:EICbibRW4JNKMcY+LsWmuwob+CRS1BmdRdjphAm9mH4= +github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190110015856-aa033095749b h1:G5tsw1T5VA7PD7VmXyGtX/hQp3ABPSCPRKVfsdUcVxs= +golang.org/x/tools v0.0.0-20190110015856-aa033095749b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= +gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/swaggo/gin-swagger/swagger.go b/vendor/github.com/swaggo/gin-swagger/swagger.go index c7f49f84..fd58935c 100644 --- a/vendor/github.com/swaggo/gin-swagger/swagger.go +++ b/vendor/github.com/swaggo/gin-swagger/swagger.go @@ -1,10 +1,12 @@ package ginSwagger import ( - "golang.org/x/net/webdav" "html/template" + "os" "regexp" + "golang.org/x/net/webdav" + "github.com/gin-gonic/gin" "github.com/swaggo/swag" ) @@ -49,6 +51,21 @@ func WrapHandler(h *webdav.Handler) gin.HandlerFunc { } } +// DisablingWrapHandler turn handler off +// if specified environment variable passed +func DisablingWrapHandler(h *webdav.Handler, envName string) gin.HandlerFunc { + eFlag := os.Getenv(envName) + if eFlag != "" { + return func(c *gin.Context) { + // Simulate behavior when route unspecified and + // return 404 HTTP code + c.String(404, "") + } + } + + return WrapHandler(h) +} + const swagger_index_templ = ` diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/ab0x.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/ab0x.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__favicon-16x16.png.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__favicon-16x16.png.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__favicon-32x32.png.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__favicon-32x32.png.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__index.html.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__index.html.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__oauth2-redirect.html.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__oauth2-redirect.html.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-bundle.js.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-bundle.js.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-bundle.js.map.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-bundle.js.map.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-standalone-preset.js.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-standalone-preset.js.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-standalone-preset.js.map.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui-standalone-preset.js.map.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.css.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.css.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.css.map.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.css.map.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.js.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.js.go old mode 100644 new mode 100755 diff --git a/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.js.map.go b/vendor/github.com/swaggo/gin-swagger/swaggerFiles/b0xfile__swagger-ui.js.map.go old mode 100644 new mode 100755 diff --git a/vendor/vendor.json b/vendor/vendor.json index 14e07d9f..724f0a7d 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -225,16 +225,16 @@ "revisionTime": "2018-03-20T13:32:07Z" }, { - "checksumSHA1": "H58GLzZlyb7pZwiW/rNqOFwWLyw=", + "checksumSHA1": "2ZtoiNLdlpaj6B0FCwAD78w+fw0=", "path": "github.com/swaggo/gin-swagger", - "revision": "1510a6d46f01820f88b3a62d13353ccc8c6faa8e", - "revisionTime": "2018-02-26T04:19:29Z" + "revision": "0c6fcfd3c7f3c4e6a9e9eeba49105253c48d590e", + "revisionTime": "2019-01-10T07:07:02Z" }, { "checksumSHA1": "A1gNAXglJwicLgCC7OIE7+a6KyQ=", "path": "github.com/swaggo/gin-swagger/swaggerFiles", - "revision": "1510a6d46f01820f88b3a62d13353ccc8c6faa8e", - "revisionTime": "2018-02-26T04:19:29Z" + "revision": "0c6fcfd3c7f3c4e6a9e9eeba49105253c48d590e", + "revisionTime": "2019-01-10T07:07:02Z" }, { "checksumSHA1": "0EK232N5ejw2ZnSK76aEeMEVWCw=",