From 007d8ec375d20649795656bebb7d25f615e19a39 Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 1 Dec 2018 01:59:17 +0000 Subject: [PATCH] Fixed generation of swagger docs (#29) --- docs/docs.go | 161 +++++------ docs/swagger/swagger.json | 143 +++++----- docs/swagger/swagger.yaml | 139 +++++---- go.mod | 2 +- go.sum | 6 +- pkg/models/list.go | 4 +- pkg/models/list_create_update.go | 8 +- pkg/models/list_delete.go | 6 +- pkg/models/list_tasks_create_update.go | 8 +- pkg/models/list_tasks_delete.go | 6 +- pkg/models/list_users_create.go | 6 +- pkg/models/list_users_delete.go | 6 +- pkg/models/list_users_readall.go | 2 +- pkg/models/list_users_update.go | 6 +- pkg/models/namespace.go | 2 +- pkg/models/namespace_create.go | 4 +- pkg/models/namespace_delete.go | 6 +- pkg/models/namespace_update.go | 6 +- pkg/models/namespace_users_create.go | 6 +- pkg/models/namespace_users_delete.go | 6 +- pkg/models/namespace_users_readall.go | 2 +- pkg/models/namespace_users_update.go | 6 +- pkg/models/team_list_create.go | 6 +- pkg/models/team_list_delete.go | 6 +- pkg/models/team_list_readall.go | 2 +- pkg/models/team_list_update.go | 6 +- pkg/models/team_members_create.go | 4 +- pkg/models/team_namespace_create.go | 6 +- pkg/models/team_namespace_delete.go | 6 +- pkg/models/team_namespace_readall.go | 2 +- pkg/models/team_namespace_update.go | 6 +- pkg/models/teams.go | 2 +- pkg/models/teams_create.go | 2 +- pkg/models/teams_delete.go | 4 +- pkg/models/teams_update.go | 4 +- pkg/routes/api/v1/user_add_update.go | 2 +- pkg/routes/api/v1/user_confirm_email.go | 2 +- pkg/routes/api/v1/user_list.go | 2 +- pkg/routes/api/v1/user_password_reset.go | 4 +- pkg/routes/api/v1/user_show.go | 2 +- pkg/routes/api/v1/user_update_password.go | 4 +- vendor/github.com/swaggo/swag/.gitignore | 1 - vendor/github.com/swaggo/swag/README.md | 34 ++- .../github.com/swaggo/swag/cmd/swag/main.go | 65 +++++ vendor/github.com/swaggo/swag/parser.go | 270 +++++++++++++----- vendor/github.com/swaggo/swag/property.go | 16 +- vendor/modules.txt | 2 +- 47 files changed, 590 insertions(+), 411 deletions(-) create mode 100644 vendor/github.com/swaggo/swag/cmd/swag/main.go diff --git a/docs/docs.go b/docs/docs.go index 096c7a759c..716b1bdbdc 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -1,22 +1,6 @@ -// Vikunja is a todo-list application to facilitate your life. -// Copyright 2018 Vikunja and contributors. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - // GENERATED BY THE COMMAND ABOVE; DO NOT EDIT // This file was generated by swaggo/swag at -// 2018-11-26 18:08:08.504247606 +0100 CET m=+0.124662709 +// 2018-12-01 02:54:44.444779863 +0100 CET m=+0.257728460 package docs @@ -87,7 +71,7 @@ var doc = `{ "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -139,7 +123,7 @@ var doc = `{ "description": "The user does not have access to the team", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -199,14 +183,14 @@ var doc = `{ "description": "Invalid task object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -266,14 +250,14 @@ var doc = `{ "description": "Invalid list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -320,14 +304,14 @@ var doc = `{ "description": "Invalid list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -393,7 +377,7 @@ var doc = `{ "description": "No right to see the list.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -453,21 +437,21 @@ var doc = `{ "description": "Invalid team list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The team does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -533,7 +517,7 @@ var doc = `{ "description": "No right to see the list.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -593,21 +577,21 @@ var doc = `{ "description": "Invalid user list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The user does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -676,14 +660,14 @@ var doc = `{ "description": "The user does not have admin-access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "Team or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -737,14 +721,14 @@ var doc = `{ "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "Team or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -813,14 +797,14 @@ var doc = `{ "description": "The user does not have admin-access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "User or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -874,14 +858,14 @@ var doc = `{ "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "user or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -993,14 +977,14 @@ var doc = `{ "description": "Invalid namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1105,14 +1089,14 @@ var doc = `{ "description": "Invalid namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1164,7 +1148,7 @@ var doc = `{ "description": "The user does not have access to that namespace.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1211,14 +1195,14 @@ var doc = `{ "description": "Invalid namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1345,7 +1329,7 @@ var doc = `{ "description": "No right to see the namespace.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1405,21 +1389,21 @@ var doc = `{ "description": "Invalid team namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The team does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The team does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1485,7 +1469,7 @@ var doc = `{ "description": "No right to see the namespace.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1545,21 +1529,21 @@ var doc = `{ "description": "Invalid user namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The user does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1621,14 +1605,14 @@ var doc = `{ "description": "Invalid list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1697,14 +1681,14 @@ var doc = `{ "description": "The team does not have admin-access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "Team or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1758,14 +1742,14 @@ var doc = `{ "description": "The team does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "team or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1834,14 +1818,14 @@ var doc = `{ "description": "The user does not have admin-access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "User or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1895,14 +1879,14 @@ var doc = `{ "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "user or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1952,7 +1936,7 @@ var doc = `{ "description": "No or invalid user register object provided / User already exists.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2097,14 +2081,14 @@ var doc = `{ "description": "Invalid task object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the task (aka its list)", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2151,14 +2135,14 @@ var doc = `{ "description": "Invalid task ID provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2263,7 +2247,7 @@ var doc = `{ "description": "Invalid team object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2325,7 +2309,7 @@ var doc = `{ "description": "Invalid team object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2372,7 +2356,7 @@ var doc = `{ "description": "Invalid team object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2434,14 +2418,14 @@ var doc = `{ "description": "Invalid member object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the team", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2533,7 +2517,7 @@ var doc = `{ "description": "User does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2583,7 +2567,7 @@ var doc = `{ "description": "Bad token provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2638,14 +2622,14 @@ var doc = `{ "description": "Something's invalid.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "User does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2695,7 +2679,7 @@ var doc = `{ "description": "Bad token provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2745,7 +2729,7 @@ var doc = `{ "description": "The user does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2798,7 +2782,7 @@ var doc = `{ "description": "Something's invalid.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2838,17 +2822,6 @@ var doc = `{ } } }, - "models.HTTPError": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "message": { - "type": "string" - } - } - }, "models.List": { "type": "object", "properties": { diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 180ebb1ea7..d062d637c6 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -58,7 +58,7 @@ "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -110,7 +110,7 @@ "description": "The user does not have access to the team", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -170,14 +170,14 @@ "description": "Invalid task object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -237,14 +237,14 @@ "description": "Invalid list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -291,14 +291,14 @@ "description": "Invalid list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -364,7 +364,7 @@ "description": "No right to see the list.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -424,21 +424,21 @@ "description": "Invalid team list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The team does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -504,7 +504,7 @@ "description": "No right to see the list.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -564,21 +564,21 @@ "description": "Invalid user list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The user does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -647,14 +647,14 @@ "description": "The user does not have admin-access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "Team or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -708,14 +708,14 @@ "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "Team or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -784,14 +784,14 @@ "description": "The user does not have admin-access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "User or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -845,14 +845,14 @@ "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "user or list does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -964,14 +964,14 @@ "description": "Invalid namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1076,14 +1076,14 @@ "description": "Invalid namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1135,7 +1135,7 @@ "description": "The user does not have access to that namespace.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1182,14 +1182,14 @@ "description": "Invalid namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1316,7 +1316,7 @@ "description": "No right to see the namespace.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1376,21 +1376,21 @@ "description": "Invalid team namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The team does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The team does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1456,7 +1456,7 @@ "description": "No right to see the namespace.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1516,21 +1516,21 @@ "description": "Invalid user namespace object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "The user does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1592,14 +1592,14 @@ "description": "Invalid list object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1668,14 +1668,14 @@ "description": "The team does not have admin-access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "Team or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1729,14 +1729,14 @@ "description": "The team does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "team or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1805,14 +1805,14 @@ "description": "The user does not have admin-access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "User or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1866,14 +1866,14 @@ "description": "The user does not have access to the namespace", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "user or namespace does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -1923,7 +1923,7 @@ "description": "No or invalid user register object provided / User already exists.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2068,14 +2068,14 @@ "description": "Invalid task object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the task (aka its list)", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2122,14 +2122,14 @@ "description": "Invalid task ID provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the list", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2234,7 +2234,7 @@ "description": "Invalid team object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2296,7 +2296,7 @@ "description": "Invalid team object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2343,7 +2343,7 @@ "description": "Invalid team object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2405,14 +2405,14 @@ "description": "Invalid member object provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "403": { "description": "The user does not have access to the team", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2504,7 +2504,7 @@ "description": "User does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2554,7 +2554,7 @@ "description": "Bad token provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2609,14 +2609,14 @@ "description": "Something's invalid.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "404": { "description": "User does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2666,7 +2666,7 @@ "description": "Bad token provided.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2716,7 +2716,7 @@ "description": "The user does not exist.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2769,7 +2769,7 @@ "description": "Something's invalid.", "schema": { "type": "object", - "$ref": "#/definitions/models.HTTPError" + "$ref": "#/definitions/code.vikunja.io/web.HTTPError" } }, "500": { @@ -2809,17 +2809,6 @@ } } }, - "models.HTTPError": { - "type": "object", - "properties": { - "code": { - "type": "integer" - }, - "message": { - "type": "string" - } - } - }, "models.List": { "type": "object", "properties": { diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index ee77001ea5..8615735305 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -16,13 +16,6 @@ definitions: token: type: string type: object - models.HTTPError: - properties: - code: - type: integer - message: - type: string - type: object models.List: properties: created: @@ -339,7 +332,7 @@ paths: "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -371,12 +364,12 @@ paths: "400": description: Invalid list object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -409,7 +402,7 @@ paths: "403": description: The user does not have access to the team schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -449,12 +442,12 @@ paths: "400": description: Invalid list object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -494,12 +487,12 @@ paths: "400": description: Invalid task object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -543,7 +536,7 @@ paths: "403": description: No right to see the list. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -583,17 +576,17 @@ paths: "400": description: Invalid team list object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: The team does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -637,7 +630,7 @@ paths: "403": description: No right to see the list. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -677,17 +670,17 @@ paths: "400": description: Invalid user list object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: The user does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -725,12 +718,12 @@ paths: "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: Team or list does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -776,12 +769,12 @@ paths: "403": description: The user does not have admin-access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: Team or list does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -819,12 +812,12 @@ paths: "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: user or list does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -870,12 +863,12 @@ paths: "403": description: The user does not have admin-access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: User or list does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -950,12 +943,12 @@ paths: "400": description: Invalid namespace object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1024,12 +1017,12 @@ paths: "400": description: Invalid namespace object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1061,12 +1054,12 @@ paths: "400": description: Invalid namespace object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1099,7 +1092,7 @@ paths: "403": description: The user does not have access to that namespace. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1184,7 +1177,7 @@ paths: "403": description: No right to see the namespace. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1224,17 +1217,17 @@ paths: "400": description: Invalid team namespace object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The team does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: The team does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1279,7 +1272,7 @@ paths: "403": description: No right to see the namespace. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1319,17 +1312,17 @@ paths: "400": description: Invalid user namespace object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: The user does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1371,12 +1364,12 @@ paths: "400": description: Invalid list object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1414,12 +1407,12 @@ paths: "403": description: The team does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: team or namespace does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1465,12 +1458,12 @@ paths: "403": description: The team does not have admin-access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: Team or namespace does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1508,12 +1501,12 @@ paths: "403": description: The user does not have access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: user or namespace does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1559,12 +1552,12 @@ paths: "403": description: The user does not have admin-access to the namespace schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: User or namespace does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1601,7 +1594,7 @@ paths: description: No or invalid user register object provided / User already exists. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1665,12 +1658,12 @@ paths: "400": description: Invalid task ID provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the list schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1710,12 +1703,12 @@ paths: "400": description: Invalid task object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the task (aka its list) schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1806,7 +1799,7 @@ paths: "400": description: Invalid team object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1839,7 +1832,7 @@ paths: "400": description: Invalid team object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1879,7 +1872,7 @@ paths: "400": description: Invalid team object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1920,12 +1913,12 @@ paths: "400": description: Invalid member object provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "403": description: The user does not have access to the team schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -1986,7 +1979,7 @@ paths: "404": description: User does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal server error. @@ -2022,7 +2015,7 @@ paths: "412": description: Bad token provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -2056,12 +2049,12 @@ paths: "400": description: Something's invalid. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "404": description: User does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal server error. @@ -2097,7 +2090,7 @@ paths: "400": description: Bad token provided. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -2132,7 +2125,7 @@ paths: "404": description: The user does not exist. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal error @@ -2165,7 +2158,7 @@ paths: "400": description: Something's invalid. schema: - $ref: '#/definitions/models.HTTPError' + $ref: '#/definitions/code.vikunja.io/web.HTTPError' type: object "500": description: Internal server error. diff --git a/go.mod b/go.mod index 53e597d89f..10c02c68ab 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/swaggo/echo-swagger v0.0.0-20180315045949-97f46bb9e5a5 github.com/swaggo/files v0.0.0-20180215091130-49c8a91ea3fa // indirect github.com/swaggo/gin-swagger v1.0.0 // indirect - github.com/swaggo/swag v1.3.3-0.20181109030545-8f09470d62b2 + github.com/swaggo/swag v1.4.1-0.20181129020348-1c8533a91397 github.com/urfave/cli v1.20.0 // indirect github.com/ziutek/mymysql v1.5.4 // indirect golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85 diff --git a/go.sum b/go.sum index 7bbe1811f5..b3cc208a96 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,10 @@ github.com/swaggo/files v0.0.0-20180215091130-49c8a91ea3fa h1:194s4modF+3X3POBfG github.com/swaggo/files v0.0.0-20180215091130-49c8a91ea3fa/go.mod h1:gxQT6pBGRuIGunNf/+tSOB5OHvguWi8Tbt82WOkf35E= github.com/swaggo/gin-swagger v1.0.0 h1:k6Nn1jV49u+SNIWt7kejQS/iENZKZVMCNQrKOYatNF8= github.com/swaggo/gin-swagger v1.0.0/go.mod h1:Mt37wE46iUaTAOv+HSnHbJYssKGqbS25X19lNF4YpBo= -github.com/swaggo/swag v1.3.3-0.20181109030545-8f09470d62b2 h1:HMUGTfTJJZ2fRHar570Q2SdUhiCEGwcRRJ2doOOnCJE= -github.com/swaggo/swag v1.3.3-0.20181109030545-8f09470d62b2/go.mod h1:hog2WgeMOrQ/LvQ+o1YGTeT+vWVrbi0SiIslBtxKTyM= +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/swaggo/swag v1.4.1-0.20181129020348-1c8533a91397 h1:xhlin3d0mSsxQlwxS+fHILT6PgG4Cmc2OZgzZL2bemI= +github.com/swaggo/swag v1.4.1-0.20181129020348-1c8533a91397/go.mod h1:hog2WgeMOrQ/LvQ+o1YGTeT+vWVrbi0SiIslBtxKTyM= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= diff --git a/pkg/models/list.go b/pkg/models/list.go index 30aeabbc1e..463110ebba 100644 --- a/pkg/models/list.go +++ b/pkg/models/list.go @@ -55,7 +55,7 @@ func GetListsByNamespaceID(nID int64) (lists []*List, err error) { // @Param s query string false "Search lists by title." // @Security ApiKeyAuth // @Success 200 {array} models.List "The lists" -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists [get] func (l *List) ReadAll(search string, a web.Auth, page int) (interface{}, error) { @@ -84,7 +84,7 @@ func (l *List) ReadAll(search string, a web.Auth, page int) (interface{}, error) // @Security ApiKeyAuth // @Param id path int true "List ID" // @Success 200 {object} models.List "The list" -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id} [get] func (l *List) ReadOne() (err error) { diff --git a/pkg/models/list_create_update.go b/pkg/models/list_create_update.go index c44a0c8919..34b1a7a280 100644 --- a/pkg/models/list_create_update.go +++ b/pkg/models/list_create_update.go @@ -59,8 +59,8 @@ func CreateOrUpdateList(list *List) (err error) { // @Param id path int true "List ID" // @Param list body models.List true "The list with updated values you want to update." // @Success 200 {object} models.List "The updated list." -// @Failure 400 {object} models.HTTPError "Invalid list object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid list object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id} [post] func (l *List) Update() (err error) { @@ -82,8 +82,8 @@ func (l *List) Update() (err error) { // @Param namespaceID path int true "Namespace ID" // @Param list body models.List true "The list you want to create." // @Success 200 {object} models.List "The created list." -// @Failure 400 {object} models.HTTPError "Invalid list object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid list object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/lists [put] func (l *List) Create(a web.Auth) (err error) { diff --git a/pkg/models/list_delete.go b/pkg/models/list_delete.go index 805205fc38..ab56a35845 100644 --- a/pkg/models/list_delete.go +++ b/pkg/models/list_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete implements the delete method of CRUDable // @Summary Deletes a list // @Description Delets a list @@ -24,8 +26,8 @@ package models // @Security ApiKeyAuth // @Param id path int true "List ID" // @Success 200 {object} models.Message "The list was successfully deleted." -// @Failure 400 {object} models.HTTPError "Invalid list object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid list object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id} [delete] func (l *List) Delete() (err error) { diff --git a/pkg/models/list_tasks_create_update.go b/pkg/models/list_tasks_create_update.go index 268b0f8785..ed12c98a80 100644 --- a/pkg/models/list_tasks_create_update.go +++ b/pkg/models/list_tasks_create_update.go @@ -31,8 +31,8 @@ import ( // @Param id path int true "List ID" // @Param task body models.ListTask true "The task object" // @Success 200 {object} models.ListTask "The created task object." -// @Failure 400 {object} models.HTTPError "Invalid task object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid task object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id} [put] func (i *ListTask) Create(a web.Auth) (err error) { @@ -75,8 +75,8 @@ func (i *ListTask) Create(a web.Auth) (err error) { // @Param id path int true "Task ID" // @Param task body models.ListTask true "The task object" // @Success 200 {object} models.ListTask "The updated task object." -// @Failure 400 {object} models.HTTPError "Invalid task object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the task (aka its list)" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid task object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the task (aka its list)" // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{id} [post] func (i *ListTask) Update() (err error) { diff --git a/pkg/models/list_tasks_delete.go b/pkg/models/list_tasks_delete.go index cb6e7023e1..a0e890965d 100644 --- a/pkg/models/list_tasks_delete.go +++ b/pkg/models/list_tasks_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete implements the delete method for listTask // @Summary Delete a task // @Description Deletes a task from a list. This does not mean "mark it done". @@ -24,8 +26,8 @@ package models // @Security ApiKeyAuth // @Param id path int true "Task ID" // @Success 200 {object} models.Message "The created task object." -// @Failure 400 {object} models.HTTPError "Invalid task ID provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid task ID provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /tasks/{id} [delete] func (i *ListTask) Delete() (err error) { diff --git a/pkg/models/list_users_create.go b/pkg/models/list_users_create.go index 6ae0aed739..e95e5cc54c 100644 --- a/pkg/models/list_users_create.go +++ b/pkg/models/list_users_create.go @@ -28,9 +28,9 @@ import "code.vikunja.io/web" // @Param id path int true "List ID" // @Param list body models.ListUser true "The user you want to add to the list." // @Success 200 {object} models.ListUser "The created user<->list relation." -// @Failure 400 {object} models.HTTPError "Invalid user list object provided." -// @Failure 404 {object} models.HTTPError "The user does not exist." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid user list object provided." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "The user does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id}/users [put] func (ul *ListUser) Create(a web.Auth) (err error) { diff --git a/pkg/models/list_users_delete.go b/pkg/models/list_users_delete.go index 8acf68de8b..137b6290e7 100644 --- a/pkg/models/list_users_delete.go +++ b/pkg/models/list_users_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete deletes a list <-> user relation // @Summary Delete a user from a list // @Description Delets a user from a list. The user won't have access to the list anymore. @@ -25,8 +27,8 @@ package models // @Param listID path int true "List ID" // @Param userID path int true "User ID" // @Success 200 {object} models.Message "The user was successfully removed from the list." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" -// @Failure 404 {object} models.HTTPError "user or list does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "user or list does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{listID}/users/{userID} [delete] func (lu *ListUser) Delete() (err error) { diff --git a/pkg/models/list_users_readall.go b/pkg/models/list_users_readall.go index 70e6258f46..6cbaa62d37 100644 --- a/pkg/models/list_users_readall.go +++ b/pkg/models/list_users_readall.go @@ -29,7 +29,7 @@ import "code.vikunja.io/web" // @Param s query string false "Search users by its name." // @Security ApiKeyAuth // @Success 200 {array} models.UserWithRight "The users with the right they have." -// @Failure 403 {object} models.HTTPError "No right to see the list." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "No right to see the list." // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id}/users [get] func (ul *ListUser) ReadAll(search string, a web.Auth, page int) (interface{}, error) { diff --git a/pkg/models/list_users_update.go b/pkg/models/list_users_update.go index df09de2609..cf41b618de 100644 --- a/pkg/models/list_users_update.go +++ b/pkg/models/list_users_update.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Update updates a user <-> list relation // @Summary Update a user <-> list relation // @Description Update a user <-> list relation. Mostly used to update the right that user has. @@ -27,8 +29,8 @@ package models // @Param list body models.ListUser true "The user you want to update." // @Security ApiKeyAuth // @Success 200 {object} models.ListUser "The updated user <-> list relation." -// @Failure 403 {object} models.HTTPError "The user does not have admin-access to the list" -// @Failure 404 {object} models.HTTPError "User or list does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have admin-access to the list" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "User or list does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{listID}/users/{userID} [post] func (lu *ListUser) Update() (err error) { diff --git a/pkg/models/namespace.go b/pkg/models/namespace.go index 3861234983..86be4d3942 100644 --- a/pkg/models/namespace.go +++ b/pkg/models/namespace.go @@ -76,7 +76,7 @@ func GetNamespaceByID(id int64) (namespace Namespace, err error) { // @Security ApiKeyAuth // @Param id path int true "Namespace ID" // @Success 200 {object} models.Namespace "The Namespace" -// @Failure 403 {object} models.HTTPError "The user does not have access to that namespace." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to that namespace." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{id} [get] func (n *Namespace) ReadOne() (err error) { diff --git a/pkg/models/namespace_create.go b/pkg/models/namespace_create.go index ceeaf321ef..dcb53c9f8e 100644 --- a/pkg/models/namespace_create.go +++ b/pkg/models/namespace_create.go @@ -27,8 +27,8 @@ import "code.vikunja.io/web" // @Security ApiKeyAuth // @Param namespace body models.Namespace true "The namespace you want to create." // @Success 200 {object} models.Namespace "The created namespace." -// @Failure 400 {object} models.HTTPError "Invalid namespace object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the namespace" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid namespace object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the namespace" // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces [put] func (n *Namespace) Create(a web.Auth) (err error) { diff --git a/pkg/models/namespace_delete.go b/pkg/models/namespace_delete.go index eef6037af3..cb31974f16 100644 --- a/pkg/models/namespace_delete.go +++ b/pkg/models/namespace_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete deletes a namespace // @Summary Deletes a namespace // @Description Delets a namespace @@ -24,8 +26,8 @@ package models // @Security ApiKeyAuth // @Param id path int true "Namespace ID" // @Success 200 {object} models.Message "The namespace was successfully deleted." -// @Failure 400 {object} models.HTTPError "Invalid namespace object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the namespace" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid namespace object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the namespace" // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{id} [delete] func (n *Namespace) Delete() (err error) { diff --git a/pkg/models/namespace_update.go b/pkg/models/namespace_update.go index 2aef5d444a..d92def1a13 100644 --- a/pkg/models/namespace_update.go +++ b/pkg/models/namespace_update.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Update implements the update method via the interface // @Summary Updates a namespace // @Description Updates a namespace. @@ -26,8 +28,8 @@ package models // @Param id path int true "Namespace ID" // @Param namespace body models.Namespace true "The namespace with updated values you want to update." // @Success 200 {object} models.Namespace "The updated namespace." -// @Failure 400 {object} models.HTTPError "Invalid namespace object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the namespace" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid namespace object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the namespace" // @Failure 500 {object} models.Message "Internal error" // @Router /namespace/{id} [post] func (n *Namespace) Update() (err error) { diff --git a/pkg/models/namespace_users_create.go b/pkg/models/namespace_users_create.go index d924366d4c..28c5670be1 100644 --- a/pkg/models/namespace_users_create.go +++ b/pkg/models/namespace_users_create.go @@ -28,9 +28,9 @@ import "code.vikunja.io/web" // @Param id path int true "Namespace ID" // @Param namespace body models.NamespaceUser true "The user you want to add to the namespace." // @Success 200 {object} models.NamespaceUser "The created user<->namespace relation." -// @Failure 400 {object} models.HTTPError "Invalid user namespace object provided." -// @Failure 404 {object} models.HTTPError "The user does not exist." -// @Failure 403 {object} models.HTTPError "The user does not have access to the namespace" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid user namespace object provided." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "The user does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the namespace" // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{id}/users [put] func (un *NamespaceUser) Create(a web.Auth) (err error) { diff --git a/pkg/models/namespace_users_delete.go b/pkg/models/namespace_users_delete.go index 3477682dae..154d83d2b4 100644 --- a/pkg/models/namespace_users_delete.go +++ b/pkg/models/namespace_users_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete deletes a namespace <-> user relation // @Summary Delete a user from a namespace // @Description Delets a user from a namespace. The user won't have access to the namespace anymore. @@ -25,8 +27,8 @@ package models // @Param namespaceID path int true "Namespace ID" // @Param userID path int true "user ID" // @Success 200 {object} models.Message "The user was successfully deleted." -// @Failure 403 {object} models.HTTPError "The user does not have access to the namespace" -// @Failure 404 {object} models.HTTPError "user or namespace does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the namespace" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "user or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/users/{userID} [delete] func (nu *NamespaceUser) Delete() (err error) { diff --git a/pkg/models/namespace_users_readall.go b/pkg/models/namespace_users_readall.go index e56c19ab4c..b3435998c5 100644 --- a/pkg/models/namespace_users_readall.go +++ b/pkg/models/namespace_users_readall.go @@ -29,7 +29,7 @@ import "code.vikunja.io/web" // @Param s query string false "Search users by its name." // @Security ApiKeyAuth // @Success 200 {array} models.UserWithRight "The users with the right they have." -// @Failure 403 {object} models.HTTPError "No right to see the namespace." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "No right to see the namespace." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{id}/users [get] func (un *NamespaceUser) ReadAll(search string, a web.Auth, page int) (interface{}, error) { diff --git a/pkg/models/namespace_users_update.go b/pkg/models/namespace_users_update.go index 241513b46b..dd50db515b 100644 --- a/pkg/models/namespace_users_update.go +++ b/pkg/models/namespace_users_update.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Update updates a user <-> namespace relation // @Summary Update a user <-> namespace relation // @Description Update a user <-> namespace relation. Mostly used to update the right that user has. @@ -27,8 +29,8 @@ package models // @Param namespace body models.NamespaceUser true "The user you want to update." // @Security ApiKeyAuth // @Success 200 {object} models.NamespaceUser "The updated user <-> namespace relation." -// @Failure 403 {object} models.HTTPError "The user does not have admin-access to the namespace" -// @Failure 404 {object} models.HTTPError "User or namespace does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have admin-access to the namespace" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "User or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/users/{userID} [post] func (nu *NamespaceUser) Update() (err error) { diff --git a/pkg/models/team_list_create.go b/pkg/models/team_list_create.go index 26b4a4b7de..82bf3cd212 100644 --- a/pkg/models/team_list_create.go +++ b/pkg/models/team_list_create.go @@ -28,9 +28,9 @@ import "code.vikunja.io/web" // @Param id path int true "List ID" // @Param list body models.TeamList true "The team you want to add to the list." // @Success 200 {object} models.TeamList "The created team<->list relation." -// @Failure 400 {object} models.HTTPError "Invalid team list object provided." -// @Failure 404 {object} models.HTTPError "The team does not exist." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid team list object provided." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "The team does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id}/teams [put] func (tl *TeamList) Create(a web.Auth) (err error) { diff --git a/pkg/models/team_list_delete.go b/pkg/models/team_list_delete.go index 479065bc76..41b93d3b7e 100644 --- a/pkg/models/team_list_delete.go +++ b/pkg/models/team_list_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete deletes a team <-> list relation based on the list & team id // @Summary Delete a team from a list // @Description Delets a team from a list. The team won't have access to the list anymore. @@ -25,8 +27,8 @@ package models // @Param listID path int true "List ID" // @Param teamID path int true "Team ID" // @Success 200 {object} models.Message "The team was successfully deleted." -// @Failure 403 {object} models.HTTPError "The user does not have access to the list" -// @Failure 404 {object} models.HTTPError "Team or list does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the list" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "Team or list does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{listID}/teams/{teamID} [delete] func (tl *TeamList) Delete() (err error) { diff --git a/pkg/models/team_list_readall.go b/pkg/models/team_list_readall.go index 6f1ecb2edc..3e9c82fa0d 100644 --- a/pkg/models/team_list_readall.go +++ b/pkg/models/team_list_readall.go @@ -29,7 +29,7 @@ import "code.vikunja.io/web" // @Param s query string false "Search teams by its name." // @Security ApiKeyAuth // @Success 200 {array} models.TeamWithRight "The teams with their right." -// @Failure 403 {object} models.HTTPError "No right to see the list." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "No right to see the list." // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id}/teams [get] func (tl *TeamList) ReadAll(search string, a web.Auth, page int) (interface{}, error) { diff --git a/pkg/models/team_list_update.go b/pkg/models/team_list_update.go index eecec74567..edd64b1a4b 100644 --- a/pkg/models/team_list_update.go +++ b/pkg/models/team_list_update.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Update updates a team <-> list relation // @Summary Update a team <-> list relation // @Description Update a team <-> list relation. Mostly used to update the right that team has. @@ -27,8 +29,8 @@ package models // @Param list body models.TeamList true "The team you want to update." // @Security ApiKeyAuth // @Success 200 {object} models.TeamList "The updated team <-> list relation." -// @Failure 403 {object} models.HTTPError "The user does not have admin-access to the list" -// @Failure 404 {object} models.HTTPError "Team or list does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have admin-access to the list" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "Team or list does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{listID}/teams/{teamID} [post] func (tl *TeamList) Update() (err error) { diff --git a/pkg/models/team_members_create.go b/pkg/models/team_members_create.go index 7e77952f70..3c84b065ac 100644 --- a/pkg/models/team_members_create.go +++ b/pkg/models/team_members_create.go @@ -28,8 +28,8 @@ import "code.vikunja.io/web" // @Param id path int true "Team ID" // @Param team body models.TeamMember true "The user to be added to a team." // @Success 200 {object} models.TeamMember "The newly created member object" -// @Failure 400 {object} models.HTTPError "Invalid member object provided." -// @Failure 403 {object} models.HTTPError "The user does not have access to the team" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid member object provided." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the team" // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id}/members [put] func (tm *TeamMember) Create(a web.Auth) (err error) { diff --git a/pkg/models/team_namespace_create.go b/pkg/models/team_namespace_create.go index da9a1ae68a..44455f3176 100644 --- a/pkg/models/team_namespace_create.go +++ b/pkg/models/team_namespace_create.go @@ -28,9 +28,9 @@ import "code.vikunja.io/web" // @Param id path int true "Namespace ID" // @Param namespace body models.TeamNamespace true "The team you want to add to the namespace." // @Success 200 {object} models.TeamNamespace "The created team<->namespace relation." -// @Failure 400 {object} models.HTTPError "Invalid team namespace object provided." -// @Failure 404 {object} models.HTTPError "The team does not exist." -// @Failure 403 {object} models.HTTPError "The team does not have access to the namespace" +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid team namespace object provided." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "The team does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The team does not have access to the namespace" // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{id}/teams [put] func (tn *TeamNamespace) Create(a web.Auth) (err error) { diff --git a/pkg/models/team_namespace_delete.go b/pkg/models/team_namespace_delete.go index 81482305b2..2e883c0300 100644 --- a/pkg/models/team_namespace_delete.go +++ b/pkg/models/team_namespace_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete deletes a team <-> namespace relation based on the namespace & team id // @Summary Delete a team from a namespace // @Description Delets a team from a namespace. The team won't have access to the namespace anymore. @@ -25,8 +27,8 @@ package models // @Param namespaceID path int true "Namespace ID" // @Param teamID path int true "team ID" // @Success 200 {object} models.Message "The team was successfully deleted." -// @Failure 403 {object} models.HTTPError "The team does not have access to the namespace" -// @Failure 404 {object} models.HTTPError "team or namespace does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The team does not have access to the namespace" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "team or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/teams/{teamID} [delete] func (tn *TeamNamespace) Delete() (err error) { diff --git a/pkg/models/team_namespace_readall.go b/pkg/models/team_namespace_readall.go index b0f0fccb0d..0aebb1869f 100644 --- a/pkg/models/team_namespace_readall.go +++ b/pkg/models/team_namespace_readall.go @@ -29,7 +29,7 @@ import "code.vikunja.io/web" // @Param s query string false "Search teams by its name." // @Security ApiKeyAuth // @Success 200 {array} models.TeamWithRight "The teams with the right they have." -// @Failure 403 {object} models.HTTPError "No right to see the namespace." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "No right to see the namespace." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{id}/teams [get] func (tn *TeamNamespace) ReadAll(search string, a web.Auth, page int) (interface{}, error) { diff --git a/pkg/models/team_namespace_update.go b/pkg/models/team_namespace_update.go index f18eedf112..6eee4dbed2 100644 --- a/pkg/models/team_namespace_update.go +++ b/pkg/models/team_namespace_update.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Update updates a team <-> namespace relation // @Summary Update a team <-> namespace relation // @Description Update a team <-> namespace relation. Mostly used to update the right that team has. @@ -27,8 +29,8 @@ package models // @Param namespace body models.TeamNamespace true "The team you want to update." // @Security ApiKeyAuth // @Success 200 {object} models.TeamNamespace "The updated team <-> namespace relation." -// @Failure 403 {object} models.HTTPError "The team does not have admin-access to the namespace" -// @Failure 404 {object} models.HTTPError "Team or namespace does not exist." +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The team does not have admin-access to the namespace" +// @Failure 404 {object} code.vikunja.io/web.HTTPError "Team or namespace does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /namespaces/{namespaceID}/teams/{teamID} [post] func (tl *TeamNamespace) Update() (err error) { diff --git a/pkg/models/teams.go b/pkg/models/teams.go index 9c8fd603d2..8806e992e1 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -104,7 +104,7 @@ func GetTeamByID(id int64) (team Team, err error) { // @Security ApiKeyAuth // @Param id path int true "Team ID" // @Success 200 {object} models.Team "The team" -// @Failure 403 {object} models.HTTPError "The user does not have access to the team" +// @Failure 403 {object} code.vikunja.io/web.HTTPError "The user does not have access to the team" // @Failure 500 {object} models.Message "Internal error" // @Router /lists/{id} [get] func (t *Team) ReadOne() (err error) { diff --git a/pkg/models/teams_create.go b/pkg/models/teams_create.go index 64ba56d05a..5e0360356e 100644 --- a/pkg/models/teams_create.go +++ b/pkg/models/teams_create.go @@ -27,7 +27,7 @@ import "code.vikunja.io/web" // @Security ApiKeyAuth // @Param team body models.Team true "The team you want to create." // @Success 200 {object} models.Team "The created team." -// @Failure 400 {object} models.HTTPError "Invalid team object provided." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid team object provided." // @Failure 500 {object} models.Message "Internal error" // @Router /teams [put] func (t *Team) Create(a web.Auth) (err error) { diff --git a/pkg/models/teams_delete.go b/pkg/models/teams_delete.go index c4f87f4652..2a0aeeb86a 100644 --- a/pkg/models/teams_delete.go +++ b/pkg/models/teams_delete.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Delete deletes a team // @Summary Deletes a team // @Description Delets a team. This will also remove the access for all users in that team. @@ -24,7 +26,7 @@ package models // @Security ApiKeyAuth // @Param id path int true "Team ID" // @Success 200 {object} models.Message "The team was successfully deleted." -// @Failure 400 {object} models.HTTPError "Invalid team object provided." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid team object provided." // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id} [delete] func (t *Team) Delete() (err error) { diff --git a/pkg/models/teams_update.go b/pkg/models/teams_update.go index 4584f7d204..f605b1d2a9 100644 --- a/pkg/models/teams_update.go +++ b/pkg/models/teams_update.go @@ -16,6 +16,8 @@ package models +import _ "code.vikunja.io/web" // For swaggerdocs generation + // Update is the handler to create a team // @Summary Updates a team // @Description Updates a team. @@ -26,7 +28,7 @@ package models // @Param id path int true "Team ID" // @Param team body models.Team true "The team with updated values you want to update." // @Success 200 {object} models.Team "The updated team." -// @Failure 400 {object} models.HTTPError "Invalid team object provided." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid team object provided." // @Failure 500 {object} models.Message "Internal error" // @Router /teams/{id} [post] func (t *Team) Update() (err error) { diff --git a/pkg/routes/api/v1/user_add_update.go b/pkg/routes/api/v1/user_add_update.go index 2988e687be..0047564c4c 100644 --- a/pkg/routes/api/v1/user_add_update.go +++ b/pkg/routes/api/v1/user_add_update.go @@ -31,7 +31,7 @@ import ( // @Produce json // @Param credentials body models.APIUserPassword true "The user credentials" // @Success 200 {object} models.User -// @Failure 400 {object} models.HTTPError "No or invalid user register object provided / User already exists." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "No or invalid user register object provided / User already exists." // @Failure 500 {object} models.Message "Internal error" // @Router /register [post] func RegisterUser(c echo.Context) error { diff --git a/pkg/routes/api/v1/user_confirm_email.go b/pkg/routes/api/v1/user_confirm_email.go index f79f7c3f8e..d3a4d97bfb 100644 --- a/pkg/routes/api/v1/user_confirm_email.go +++ b/pkg/routes/api/v1/user_confirm_email.go @@ -31,7 +31,7 @@ import ( // @Produce json // @Param credentials body models.EmailConfirm true "The token." // @Success 200 {object} models.Message -// @Failure 412 {object} models.HTTPError "Bad token provided." +// @Failure 412 {object} code.vikunja.io/web.HTTPError "Bad token provided." // @Failure 500 {object} models.Message "Internal error" // @Router /user/confirm [post] func UserConfirmEmail(c echo.Context) error { diff --git a/pkg/routes/api/v1/user_list.go b/pkg/routes/api/v1/user_list.go index a4e40cff1e..cbb3a10877 100644 --- a/pkg/routes/api/v1/user_list.go +++ b/pkg/routes/api/v1/user_list.go @@ -32,7 +32,7 @@ import ( // @Param s query string false "Search for a user by its name." // @Security ApiKeyAuth // @Success 200 {array} models.User "All (found) users." -// @Failure 400 {object} models.HTTPError "Something's invalid." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Something's invalid." // @Failure 500 {object} models.Message "Internal server error." // @Router /users [get] func UserList(c echo.Context) error { diff --git a/pkg/routes/api/v1/user_password_reset.go b/pkg/routes/api/v1/user_password_reset.go index 8c7bb0bc9b..7e7f199f41 100644 --- a/pkg/routes/api/v1/user_password_reset.go +++ b/pkg/routes/api/v1/user_password_reset.go @@ -31,7 +31,7 @@ import ( // @Produce json // @Param credentials body models.PasswordReset true "The token with the new password." // @Success 200 {object} models.Message -// @Failure 400 {object} models.HTTPError "Bad token provided." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Bad token provided." // @Failure 500 {object} models.Message "Internal error" // @Router /user/password/reset [post] func UserResetPassword(c echo.Context) error { @@ -57,7 +57,7 @@ func UserResetPassword(c echo.Context) error { // @Produce json // @Param credentials body models.PasswordTokenRequest true "The username of the user to request a token for." // @Success 200 {object} models.Message -// @Failure 404 {object} models.HTTPError "The user does not exist." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "The user does not exist." // @Failure 500 {object} models.Message "Internal error" // @Router /user/password/token [post] func UserRequestResetPasswordToken(c echo.Context) error { diff --git a/pkg/routes/api/v1/user_show.go b/pkg/routes/api/v1/user_show.go index 5797d1b7b4..84ecf3adf0 100644 --- a/pkg/routes/api/v1/user_show.go +++ b/pkg/routes/api/v1/user_show.go @@ -31,7 +31,7 @@ import ( // @Produce json // @Security ApiKeyAuth // @Success 200 {object} models.User -// @Failure 404 {object} models.HTTPError "User does not exist." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "User does not exist." // @Failure 500 {object} models.Message "Internal server error." // @Router /user [get] func UserShow(c echo.Context) error { diff --git a/pkg/routes/api/v1/user_update_password.go b/pkg/routes/api/v1/user_update_password.go index 9013e575ae..66a27b793e 100644 --- a/pkg/routes/api/v1/user_update_password.go +++ b/pkg/routes/api/v1/user_update_password.go @@ -38,8 +38,8 @@ type UserPassword struct { // @Param userPassword body v1.UserPassword true "The current and new password." // @Security ApiKeyAuth // @Success 200 {object} models.Message -// @Failure 400 {object} models.HTTPError "Something's invalid." -// @Failure 404 {object} models.HTTPError "User does not exist." +// @Failure 400 {object} code.vikunja.io/web.HTTPError "Something's invalid." +// @Failure 404 {object} code.vikunja.io/web.HTTPError "User does not exist." // @Failure 500 {object} models.Message "Internal server error." // @Router /user/password [post] func UserChangePassword(c echo.Context) error { diff --git a/vendor/github.com/swaggo/swag/.gitignore b/vendor/github.com/swaggo/swag/.gitignore index 6f40cc7d68..d86409b8b5 100644 --- a/vendor/github.com/swaggo/swag/.gitignore +++ b/vendor/github.com/swaggo/swag/.gitignore @@ -1,4 +1,3 @@ -swag testdata/simple/docs cover.out diff --git a/vendor/github.com/swaggo/swag/README.md b/vendor/github.com/swaggo/swag/README.md index 750ef6e253..e5466de81d 100644 --- a/vendor/github.com/swaggo/swag/README.md +++ b/vendor/github.com/swaggo/swag/README.md @@ -22,7 +22,7 @@ - [Getting started](#getting-started) - [Go web frameworks](#supported-web-frameworks) - [Supported Web Frameworks](#supported-web-frameworks) - - [How to use it with `gin`?](#how-to-use-it-with-`gin`?) + - [How to use it with Gin](#how-to-use-it-with-gin) - [Implementation Status](#implementation-status) - [swag cli](#swag-cli) - [General API Info](#general-api-info) @@ -72,7 +72,7 @@ $ swag init - [echo](http://github.com/swaggo/echo-swagger) - [net/http](https://github.com/swaggo/http-swagger) -## How to use it with `gin`? +## How to use it with Gin Find the example source code [here](https://github.com/swaggo/swag/tree/master/example/celler). @@ -307,19 +307,23 @@ OPTIONS: **Example** [celler/main.go](https://github.com/swaggo/swag/blob/master/example/celler/main.go) -| annotation | description | example | -|--------------------|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------| -| title | **Required.** The title of the application. | // @title Swagger Example API | -| version | **Required.** Provides the version of the application API. | // @version 1.0 | -| description | A short description of the application. | // @description This is a sample server celler server. | -| termsOfService | The Terms of Service for the API. | // @termsOfService http://swagger.io/terms/ | -| contact.name | The contact information for the exposed API. | // @contact.name API Support | -| contact.url | The URL pointing to the contact information. MUST be in the format of a URL. | // @contact.url http://www.swagger.io/support | -| contact.email | The email address of the contact person/organization. MUST be in the format of an email address.| // @contact.email support@swagger.io | -| license.name | **Required.** The license name used for the API. | // @license.name Apache 2.0 | -| license.url | A URL to the license used for the API. MUST be in the format of a URL. | // @license.url http://www.apache.org/licenses/LICENSE-2.0.html | -| host | The host (name or ip) serving the API. | // @host localhost:8080 | -| BasePath | The base path on which the API is served. | // @BasePath /api/v1 | +| annotation | description | example | +|-----------------------|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------| +| title | **Required.** The title of the application. | // @title Swagger Example API | +| version | **Required.** Provides the version of the application API. | // @version 1.0 | +| description | A short description of the application. | // @description This is a sample server celler server. | +| tag.name | Name of a tag. | // @tag.name This is the name of the tag | +| tag.description | Description of the tag | // @tag.description Cool Description | +| tag.docs.url | Url of the external Documentation of the tag | // @tag.docs.url https://example.com | +| tag.docs.descripiton | Description of the external Documentation of the tag | // @tag.docs.descirption Best example documentation | +| termsOfService | The Terms of Service for the API. | // @termsOfService http://swagger.io/terms/ | +| contact.name | The contact information for the exposed API. | // @contact.name API Support | +| contact.url | The URL pointing to the contact information. MUST be in the format of a URL. | // @contact.url http://www.swagger.io/support | +| contact.email | The email address of the contact person/organization. MUST be in the format of an email address.| // @contact.email support@swagger.io | +| license.name | **Required.** The license name used for the API. | // @license.name Apache 2.0 | +| license.url | A URL to the license used for the API. MUST be in the format of a URL. | // @license.url http://www.apache.org/licenses/LICENSE-2.0.html | +| host | The host (name or ip) serving the API. | // @host localhost:8080 | +| BasePath | The base path on which the API is served. | // @BasePath /api/v1 | ## Security diff --git a/vendor/github.com/swaggo/swag/cmd/swag/main.go b/vendor/github.com/swaggo/swag/cmd/swag/main.go new file mode 100644 index 0000000000..91590b77b0 --- /dev/null +++ b/vendor/github.com/swaggo/swag/cmd/swag/main.go @@ -0,0 +1,65 @@ +package main + +import ( + "log" + "os" + + "github.com/pkg/errors" + "github.com/swaggo/swag" + "github.com/swaggo/swag/gen" + "github.com/urfave/cli" +) + +func main() { + app := cli.NewApp() + app.Version = swag.Version + app.Usage = "Automatically generate RESTful API documentation with Swagger 2.0 for Go." + app.Commands = []cli.Command{ + { + Name: "init", + Aliases: []string{"i"}, + Usage: "Create docs.go", + Action: func(c *cli.Context) error { + dir := c.String("dir") + mainAPIFile := c.String("generalInfo") + swaggerConfDir := c.String("swagger") + strategy := c.String("propertyStrategy") + switch strategy { + case swag.CamelCase, swag.SnakeCase, swag.PascalCase: + default: + return errors.Errorf("not supported %s propertyStrategy", strategy) + } + + gen.New().Build(dir, mainAPIFile, swaggerConfDir, strategy) + return nil + }, + Flags: []cli.Flag{ + cli.StringFlag{ + Name: "generalInfo, g", + Value: "main.go", + Usage: "Go file path in which 'swagger general API Info' is written", + }, + cli.StringFlag{ + Name: "dir, d", + Value: "./", + Usage: "Directory you want to parse", + }, + cli.StringFlag{ + Name: "swagger, s", + Value: "./docs/swagger", + Usage: "Output the swagger conf for json and yaml", + }, + cli.StringFlag{ + Name: "propertyStrategy, p", + Value: "camelcase", + Usage: "Property Naming Strategy like snakecase,camelcase,pascalcase", + }, + }, + }, + } + + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } +} diff --git a/vendor/github.com/swaggo/swag/parser.go b/vendor/github.com/swaggo/swag/parser.go index de2f0954d5..ad751a6a6d 100644 --- a/vendor/github.com/swaggo/swag/parser.go +++ b/vendor/github.com/swaggo/swag/parser.go @@ -50,6 +50,9 @@ type Parser struct { registerTypes map[string]*ast.TypeSpec PropNamingStrategy string + + // structStack stores full names of the structures that were already parsed or are being parsed now + structStack []string } // New creates a new Parser with default properties. @@ -146,6 +149,34 @@ func (parser *Parser) ParseGeneralAPIInfo(mainAPIFile string) error { parser.swagger.BasePath = strings.TrimSpace(commentLine[len(attribute):]) case "@schemes": parser.swagger.Schemes = GetSchemes(commentLine) + case "@tag.name": + commentInfo := strings.TrimSpace(commentLine[len(attribute):]) + parser.swagger.Tags = append(parser.swagger.Tags, spec.Tag{ + TagProps: spec.TagProps{ + Name: strings.TrimSpace(commentInfo), + }, + }) + case "@tag.description": + commentInfo := strings.TrimSpace(commentLine[len(attribute):]) + tag := parser.swagger.Tags[len(parser.swagger.Tags)-1] + tag.TagProps.Description = commentInfo + replaceLastTag(parser.swagger.Tags, tag) + case "@tag.docs.url": + commentInfo := strings.TrimSpace(commentLine[len(attribute):]) + tag := parser.swagger.Tags[len(parser.swagger.Tags)-1] + tag.TagProps.ExternalDocs = &spec.ExternalDocumentation{ + URL: commentInfo, + } + replaceLastTag(parser.swagger.Tags, tag) + + case "@tag.docs.description": + commentInfo := strings.TrimSpace(commentLine[len(attribute):]) + tag := parser.swagger.Tags[len(parser.swagger.Tags)-1] + if tag.TagProps.ExternalDocs == nil { + log.Panic("@tag.docs.description needs to come after a @tags.docs.url") + } + tag.TagProps.ExternalDocs.Description = commentInfo + replaceLastTag(parser.swagger.Tags, tag) } } @@ -365,47 +396,46 @@ func (parser *Parser) ParseType(astFile *ast.File) { } } +func (parser *Parser) isInStructStack(refTypeName string) bool { + for _, structName := range parser.structStack { + if refTypeName == structName { + return true + } + } + return false +} + // ParseDefinitions parses Swagger Api definitions. func (parser *Parser) ParseDefinitions() { for refTypeName, typeSpec := range parser.registerTypes { ss := strings.Split(refTypeName, ".") pkgName := ss[0] - parser.ParseDefinition(pkgName, typeSpec, typeSpec.Name.Name) + parser.structStack = nil + parser.ParseDefinition(pkgName, typeSpec.Name.Name, typeSpec) } } -var structStacks []string - -// isNotRecurringNestStruct check if a structure that is not a not repeating -func isNotRecurringNestStruct(refTypeName string, structStacks []string) bool { - for _, v := range structStacks { - if refTypeName == v { - return false - } - } - return true -} - -// ParseDefinition TODO: NEEDS COMMENT INFO -func (parser *Parser) ParseDefinition(pkgName string, typeSpec *ast.TypeSpec, typeName string) { - var refTypeName string - if len(pkgName) > 0 { - refTypeName = pkgName + "." + typeName - } else { - refTypeName = typeName - } - if _, already := parser.swagger.Definitions[refTypeName]; already { - log.Println("Skipping '" + refTypeName + "', already present.") +// ParseDefinition parses given type spec that corresponds to the type under +// given name and package, and populates swagger schema definitions registry +// with a schema for the given type +func (parser *Parser) ParseDefinition(pkgName, typeName string, typeSpec *ast.TypeSpec) { + refTypeName := fullTypeName(pkgName, typeName) + if _, isParsed := parser.swagger.Definitions[refTypeName]; isParsed { + log.Println("Skipping '" + refTypeName + "', already parsed.") return } - properties := make(map[string]spec.Schema) - // stop repetitive structural parsing - if isNotRecurringNestStruct(refTypeName, structStacks) { - structStacks = append(structStacks, refTypeName) - parser.parseTypeSpec(pkgName, typeSpec, properties) - } - structStacks = []string{} + if parser.isInStructStack(refTypeName) { + log.Println("Skipping '" + refTypeName + "', recursion detected.") + return + } + parser.structStack = append(parser.structStack, refTypeName) + + log.Println("Generating " + refTypeName) + parser.swagger.Definitions[refTypeName] = parser.parseTypeExpr(pkgName, typeName, typeSpec.Type) +} + +func (parser *Parser) collectRequiredFields(pkgName string, properties map[string]spec.Schema) (requiredFields []string) { // created sorted list of properties keys so when we iterate over them it's deterministic ks := make([]string, 0, len(properties)) for k := range properties { @@ -413,7 +443,7 @@ func (parser *Parser) ParseDefinition(pkgName string, typeSpec *ast.TypeSpec, ty } sort.Strings(ks) - requiredFields := make([]string, 0) + requiredFields = make([]string, 0) // iterate over keys list instead of map to avoid the random shuffle of the order that go does for maps for _, k := range ks { @@ -423,7 +453,7 @@ func (parser *Parser) ParseDefinition(pkgName string, typeSpec *ast.TypeSpec, ty tname := prop.SchemaProps.Type[0] if _, ok := parser.TypeDefinitions[pkgName][tname]; ok { tspec := parser.TypeDefinitions[pkgName][tname] - parser.ParseDefinition(pkgName, tspec, tname) + parser.ParseDefinition(pkgName, tname, tspec) } if tname != "object" { requiredFields = append(requiredFields, prop.SchemaProps.Required...) @@ -431,39 +461,98 @@ func (parser *Parser) ParseDefinition(pkgName string, typeSpec *ast.TypeSpec, ty } properties[k] = prop } - log.Println("Generating " + refTypeName) - parser.swagger.Definitions[refTypeName] = spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: properties, - Required: requiredFields, - }, - } + + return } -func (parser *Parser) parseTypeSpec(pkgName string, typeSpec *ast.TypeSpec, properties map[string]spec.Schema) { - switch typeSpec.Type.(type) { - case *ast.StructType: - structDecl := typeSpec.Type.(*ast.StructType) - fields := structDecl.Fields.List +func fullTypeName(pkgName, typeName string) string { + if pkgName != "" { + return pkgName + "." + typeName + } + return typeName +} - for _, field := range fields { - if field.Names == nil { //anonymous field - parser.parseAnonymousField(pkgName, field, properties) +// parseTypeExpr parses given type expression that corresponds to the type under +// given name and package, and returns swagger schema for it. +func (parser *Parser) parseTypeExpr(pkgName, typeName string, typeExpr ast.Expr) spec.Schema { + switch expr := typeExpr.(type) { + // type Foo struct {...} + case *ast.StructType: + refTypeName := fullTypeName(pkgName, typeName) + if schema, isParsed := parser.swagger.Definitions[refTypeName]; isParsed { + return schema + } + + properties := make(map[string]spec.Schema) + for _, field := range expr.Fields.List { + var fieldProps map[string]spec.Schema + if field.Names == nil { + fieldProps = parser.parseAnonymousField(pkgName, field) } else { - props := parser.parseStruct(pkgName, field) - for k, v := range props { - properties[k] = v - } + fieldProps = parser.parseStruct(pkgName, field) + } + + for k, v := range fieldProps { + properties[k] = v } } + return spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: properties, + Required: parser.collectRequiredFields(pkgName, properties), + }, + } + + // type Foo Baz + case *ast.Ident: + refTypeName := fullTypeName(pkgName, expr.Name) + if _, isParsed := parser.swagger.Definitions[refTypeName]; !isParsed { + typedef := parser.TypeDefinitions[pkgName][expr.Name] + parser.ParseDefinition(pkgName, expr.Name, typedef) + } + return parser.swagger.Definitions[refTypeName] + + // type Foo *Baz + case *ast.StarExpr: + return parser.parseTypeExpr(pkgName, typeName, expr.X) + + // type Foo []Baz case *ast.ArrayType: - log.Println("ParseDefinitions not supported 'Array' yet.") - case *ast.InterfaceType: - log.Println("ParseDefinitions not supported 'Interface' yet.") - case *ast.MapType: - log.Println("ParseDefinitions not supported 'Map' yet.") + itemSchema := parser.parseTypeExpr(pkgName, "", expr.Elt) + return spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &itemSchema, + }, + }, + } + + // type Foo pkg.Bar + case *ast.SelectorExpr: + if xIdent, ok := expr.X.(*ast.Ident); ok { + pkgName = xIdent.Name + typeName = expr.Sel.Name + refTypeName := fullTypeName(pkgName, typeName) + if _, isParsed := parser.swagger.Definitions[refTypeName]; !isParsed { + typedef := parser.TypeDefinitions[pkgName][typeName] + parser.ParseDefinition(pkgName, typeName, typedef) + } + return parser.swagger.Definitions[refTypeName] + } + + // type Foo map[string]Bar + // ... + default: + log.Printf("Type definition of type '%T' is not supported yet. Using 'object' instead.\n", typeExpr) + } + + return spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + }, } } @@ -500,7 +589,8 @@ func (parser *Parser) parseStruct(pkgName string, field *ast.Field) (properties } if _, ok := parser.TypeDefinitions[pkgName][structField.schemaType]; ok { // user type field // write definition if not yet present - parser.ParseDefinition(pkgName, parser.TypeDefinitions[pkgName][structField.schemaType], structField.schemaType) + parser.ParseDefinition(pkgName, structField.schemaType, + parser.TypeDefinitions[pkgName][structField.schemaType]) properties[structField.name] = spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{"object"}, // to avoid swagger validation error @@ -513,7 +603,8 @@ func (parser *Parser) parseStruct(pkgName string, field *ast.Field) (properties } else if structField.schemaType == "array" { // array field type // if defined -- ref it if _, ok := parser.TypeDefinitions[pkgName][structField.arrayType]; ok { // user type in array - parser.ParseDefinition(pkgName, parser.TypeDefinitions[pkgName][structField.arrayType], structField.arrayType) + parser.ParseDefinition(pkgName, structField.arrayType, + parser.TypeDefinitions[pkgName][structField.arrayType]) properties[structField.name] = spec.Schema{ SchemaProps: spec.SchemaProps{ Type: []string{structField.schemaType}, @@ -620,30 +711,48 @@ func (parser *Parser) parseStruct(pkgName string, field *ast.Field) (properties return } -func (parser *Parser) parseAnonymousField(pkgName string, field *ast.Field, properties map[string]spec.Schema) { - // check if ast Field is Ident type - astTypeIdent, okTypeIdent := field.Type.(*ast.Ident) +func (parser *Parser) parseAnonymousField(pkgName string, field *ast.Field) map[string]spec.Schema { + properties := make(map[string]spec.Schema) - // if ast Field is not Ident type we check if it's StarExpr - // because it might be a pointer to an Ident - if !okTypeIdent { - if astTypeStar, okTypeStar := field.Type.(*ast.StarExpr); okTypeStar { - astTypeIdent, okTypeIdent = astTypeStar.X.(*ast.Ident) + fullTypeName := "" + switch ftype := field.Type.(type) { + case *ast.Ident: + fullTypeName = ftype.Name + case *ast.StarExpr: + if ftypeX, ok := ftype.X.(*ast.Ident); ok { + fullTypeName = ftypeX.Name } + default: + log.Printf("Field type of '%T' is unsupported. Skipping", ftype) + return properties } - if okTypeIdent { - findPgkName := pkgName - findBaseTypeName := astTypeIdent.Name - ss := strings.Split(astTypeIdent.Name, ".") - if len(ss) > 1 { - findPgkName = ss[0] - findBaseTypeName = ss[1] - } - - baseTypeSpec := parser.TypeDefinitions[findPgkName][findBaseTypeName] - parser.parseTypeSpec(findPgkName, baseTypeSpec, properties) + typeName := fullTypeName + if splits := strings.Split(fullTypeName, "."); len(splits) > 1 { + pkgName = splits[0] + typeName = splits[1] } + + typeSpec := parser.TypeDefinitions[pkgName][typeName] + schema := parser.parseTypeExpr(pkgName, typeName, typeSpec.Type) + + schemaType := "unknown" + if len(schema.SchemaProps.Type) > 0 { + schemaType = schema.SchemaProps.Type[0] + } + + switch schemaType { + case "object": + for k, v := range schema.SchemaProps.Properties { + properties[k] = v + } + case "array": + properties[typeName] = schema + default: + log.Printf("Can't extract properties from a schema of type '%s'", schemaType) + } + + return properties } func (parser *Parser) parseField(field *ast.Field) *structField { @@ -755,6 +864,11 @@ func (parser *Parser) parseField(field *ast.Field) *structField { return structField } +func replaceLastTag(slice []spec.Tag, element spec.Tag) { + slice = slice[:len(slice)-1] + slice = append(slice, element) +} + func getFloatTag(structTag reflect.StructTag, tagName string) *float64 { strValue := structTag.Get(tagName) if strValue == "" { diff --git a/vendor/github.com/swaggo/swag/property.go b/vendor/github.com/swaggo/swag/property.go index af13a9c07d..3c9ea6cfc8 100644 --- a/vendor/github.com/swaggo/swag/property.go +++ b/vendor/github.com/swaggo/swag/property.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "go/ast" + "log" "strings" ) @@ -52,7 +53,7 @@ func parseFieldSelectorExpr(astTypeSelectorExpr *ast.SelectorExpr, parser *Parse if pkgName, ok := astTypeSelectorExpr.X.(*ast.Ident); ok { if typeDefinitions, ok := parser.TypeDefinitions[pkgName.Name][astTypeSelectorExpr.Sel.Name]; ok { - parser.ParseDefinition(pkgName.Name, typeDefinitions, astTypeSelectorExpr.Sel.Name) + parser.ParseDefinition(pkgName.Name, astTypeSelectorExpr.Sel.Name, typeDefinitions) return propertyNewFunc(astTypeSelectorExpr.Sel.Name, pkgName.Name) } if actualPrimitiveType, isCustomType := parser.CustomPrimitiveTypes[astTypeSelectorExpr.Sel.Name]; isCustomType { @@ -60,7 +61,7 @@ func parseFieldSelectorExpr(astTypeSelectorExpr *ast.SelectorExpr, parser *Parse } } - fmt.Printf("%s is not supported. but it will be set with string temporary. Please report any problems.", astTypeSelectorExpr.Sel.Name) + log.Printf("%s is not supported. but it will be set with string temporary. Please report any problems.\n", astTypeSelectorExpr.Sel.Name) return propertyName{SchemaType: "string", ArrayType: "string"} } @@ -86,6 +87,14 @@ func getPropertyName(field *ast.Field, parser *Parser) propertyName { if astTypeSelectorExpr, ok := ptr.X.(*ast.SelectorExpr); ok { return parseFieldSelectorExpr(astTypeSelectorExpr, parser, newProperty) } + // TODO support custom pointer type? + if _, ok := ptr.X.(*ast.MapType); ok { // if map + //TODO support map + return propertyName{SchemaType: "object", ArrayType: "object"} + } + if _, ok := ptr.X.(*ast.StructType); ok { // if struct + return propertyName{SchemaType: "object", ArrayType: "object"} + } if astTypeIdent, ok := ptr.X.(*ast.Ident); ok { name := astTypeIdent.Name schemeType := TransToValidSchemeType(name) @@ -106,6 +115,9 @@ func getPropertyName(field *ast.Field, parser *Parser) propertyName { return parseFieldSelectorExpr(astTypeArrayExpr, parser, newArrayProperty) } if astTypeArrayExpr, ok := astTypeArray.Elt.(*ast.StarExpr); ok { + if astTypeArraySel, ok := astTypeArrayExpr.X.(*ast.SelectorExpr); ok { + return parseFieldSelectorExpr(astTypeArraySel, parser, newArrayProperty) + } if astTypeArrayIdent, ok := astTypeArrayExpr.X.(*ast.Ident); ok { name := TransToValidSchemeType(astTypeArrayIdent.Name) return propertyName{SchemaType: "array", ArrayType: name} diff --git a/vendor/modules.txt b/vendor/modules.txt index ba79f20abe..f44995e760 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -108,7 +108,7 @@ github.com/stretchr/testify/assert github.com/swaggo/echo-swagger # github.com/swaggo/files v0.0.0-20180215091130-49c8a91ea3fa github.com/swaggo/files -# github.com/swaggo/swag v1.3.3-0.20181109030545-8f09470d62b2 +# github.com/swaggo/swag v1.4.1-0.20181129020348-1c8533a91397 github.com/swaggo/swag/cmd/swag github.com/swaggo/swag github.com/swaggo/swag/gen