This commit is contained in:
konrad 2018-08-29 14:40:03 +02:00 committed by kolaente
parent bdff353e78
commit 4e70486a9b
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
3 changed files with 296 additions and 418 deletions

View File

@ -1,24 +1,6 @@
{ {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"http",
"https"
],
"swagger": "2.0", "swagger": "2.0",
"info": { "info": {},
"description": "This documentation describes the List API.",
"title": "List API.",
"license": {
"name": "GPLv3"
},
"version": "0.1"
},
"basePath": "/api/v1",
"paths": { "paths": {
"/item/{itemID}": { "/item/{itemID}": {
"put": { "put": {
@ -589,7 +571,7 @@
"name": "body", "name": "body",
"in": "body", "in": "body",
"schema": { "schema": {
"$ref": "#/definitions/ApiUserPassword" "$ref": "#/definitions/APIUserPassword"
} }
} }
], ],
@ -608,9 +590,9 @@
} }
}, },
"definitions": { "definitions": {
"ApiUserPassword": { "APIUserPassword": {
"type": "object", "type": "object",
"title": "ApiUserPassword represents a user object without timestamps and a json password field.", "title": "APIUserPassword represents a user object without timestamps and a json password field.",
"properties": { "properties": {
"email": { "email": {
"type": "string", "type": "string",
@ -630,7 +612,7 @@
"x-go-name": "Username" "x-go-name": "Username"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"List": { "List": {
"description": "List represents a list of items", "description": "List represents a list of items",
@ -670,7 +652,7 @@
"x-go-name": "Updated" "x-go-name": "Updated"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"ListItem": { "ListItem": {
"description": "ListItem represents an item in a todolist", "description": "ListItem represents an item in a todolist",
@ -722,7 +704,7 @@
"x-go-name": "Updated" "x-go-name": "Updated"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"Message": { "Message": {
"description": "Message is a standard message", "description": "Message is a standard message",
@ -733,7 +715,7 @@
"x-go-name": "Message" "x-go-name": "Message"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"Namespace": { "Namespace": {
"description": "Namespace holds informations about a namespace", "description": "Namespace holds informations about a namespace",
@ -766,7 +748,7 @@
"x-go-name": "Updated" "x-go-name": "Updated"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"User": { "User": {
"description": "User holds information about an user", "description": "User holds information about an user",
@ -786,7 +768,7 @@
"x-go-name": "Username" "x-go-name": "Username"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
}, },
"UserLogin": { "UserLogin": {
"description": "UserLogin Object to recive user credentials in JSON format", "description": "UserLogin Object to recive user credentials in JSON format",
@ -801,7 +783,7 @@
"x-go-name": "Username" "x-go-name": "Username"
} }
}, },
"x-go-package": "git.kolaente.de/konrad/list/models" "x-go-package": "code.vikunja.io/api/models"
} }
}, },
"responses": { "responses": {
@ -857,17 +839,5 @@
"$ref": "#/definitions/Namespace" "$ref": "#/definitions/Namespace"
} }
} }
},
"securityDefinitions": {
"AuthorizationHeaderToken": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
} }
},
"security": [
{
"AuthorizationHeaderToken": []
}
]
} }

View File

@ -1,12 +1,5 @@
package v1 package v1
import (
"github.com/labstack/echo"
"net/http"
)
// DeleteListItemByIDtemByID is the web handler to delete a list item
func DeleteListItemByIDtemByID(c echo.Context) error {
// swagger:operation DELETE /item/{itemID} lists deleteListItem // swagger:operation DELETE /item/{itemID} lists deleteListItem
// --- // ---
// summary: Deletes a list item // summary: Deletes a list item
@ -32,11 +25,6 @@ func DeleteListItemByIDtemByID(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// DeleteListByID ...
func DeleteListByID(c echo.Context) error {
// swagger:operation DELETE /lists/{listID} lists deleteList // swagger:operation DELETE /lists/{listID} lists deleteList
// --- // ---
// summary: Deletes a list with all items on it // summary: Deletes a list with all items on it
@ -62,11 +50,6 @@ func DeleteListByID(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// AddListItem ...
func AddListItem(c echo.Context) error {
// swagger:operation PUT /lists/{listID} lists addListItem // swagger:operation PUT /lists/{listID} lists addListItem
// --- // ---
// summary: Adds an item to a list // summary: Adds an item to a list
@ -92,11 +75,6 @@ func AddListItem(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// UpdateListItem ...
func UpdateListItem(c echo.Context) error {
// swagger:operation PUT /item/{itemID} lists updateListItem // swagger:operation PUT /item/{itemID} lists updateListItem
// --- // ---
// summary: Updates a list item // summary: Updates a list item
@ -122,11 +100,6 @@ func UpdateListItem(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// GetListByID Adds or updates a new list
func GetListByID(c echo.Context) error {
// swagger:operation GET /lists/{listID} lists getList // swagger:operation GET /lists/{listID} lists getList
// --- // ---
// summary: gets one list with all todo items // summary: gets one list with all todo items
@ -148,11 +121,6 @@ func GetListByID(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// AddList ...
func AddList(c echo.Context) error {
// swagger:operation PUT /namespaces/{namespaceID}/lists lists addList // swagger:operation PUT /namespaces/{namespaceID}/lists lists addList
// --- // ---
// summary: Creates a new list owned by the currently logged in user in that namespace // summary: Creates a new list owned by the currently logged in user in that namespace
@ -181,11 +149,6 @@ func AddList(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// UpdateList ...
func UpdateList(c echo.Context) error {
// swagger:operation POST /lists/{listID} lists upadteList // swagger:operation POST /lists/{listID} lists upadteList
// --- // ---
// summary: Updates a list // summary: Updates a list
@ -213,11 +176,6 @@ func UpdateList(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// GetListsByUser gets all lists a user owns
func GetListsByUser(c echo.Context) error {
// swagger:operation GET /lists lists getLists // swagger:operation GET /lists lists getLists
// --- // ---
// summary: Gets all lists owned by the current user // summary: Gets all lists owned by the current user
@ -231,11 +189,6 @@ func GetListsByUser(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// AddNamespace ...
func AddNamespace(c echo.Context) error {
// swagger:operation PUT /namespaces namespaces addNamespace // swagger:operation PUT /namespaces namespaces addNamespace
// --- // ---
// summary: Creates a new namespace owned by the currently logged in user // summary: Creates a new namespace owned by the currently logged in user
@ -258,11 +211,6 @@ func AddNamespace(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// UpdateNamespace ...
func UpdateNamespace(c echo.Context) error {
// swagger:operation POST /namespaces/{namespaceID} namespaces upadteNamespace // swagger:operation POST /namespaces/{namespaceID} namespaces upadteNamespace
// --- // ---
// summary: Updates a namespace // summary: Updates a namespace
@ -290,11 +238,6 @@ func UpdateNamespace(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// DeleteNamespaceByID ...
func DeleteNamespaceByID(c echo.Context) error {
// swagger:operation DELETE /namespaces/{namespaceID} namespaces deleteNamespace // swagger:operation DELETE /namespaces/{namespaceID} namespaces deleteNamespace
// --- // ---
// summary: Deletes a namespace with all lists // summary: Deletes a namespace with all lists
@ -320,11 +263,6 @@ func DeleteNamespaceByID(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// ShowNamespace ...
func ShowNamespace(c echo.Context) error {
// swagger:operation GET /namespaces/{namespaceID} namespaces getNamespace // swagger:operation GET /namespaces/{namespaceID} namespaces getNamespace
// --- // ---
// summary: gets one namespace with all todo items // summary: gets one namespace with all todo items
@ -346,11 +284,6 @@ func ShowNamespace(c echo.Context) error {
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}
// GetAllNamespacesByCurrentUser ...
func GetAllNamespacesByCurrentUser(c echo.Context) error {
// swagger:operation GET /namespaces namespaces getNamespaces // swagger:operation GET /namespaces namespaces getNamespaces
// --- // ---
// summary: Get all namespaces the currently logged in user has at least read access // summary: Get all namespaces the currently logged in user has at least read access
@ -363,6 +296,3 @@ func GetAllNamespacesByCurrentUser(c echo.Context) error {
// "$ref": "#/responses/Namespace" // "$ref": "#/responses/Namespace"
// "500": // "500":
// "$ref": "#/responses/Message" // "$ref": "#/responses/Message"
return echo.NewHTTPError(http.StatusNotImplemented)
}

View File

@ -34,7 +34,6 @@ import (
apiv1 "code.vikunja.io/api/routes/api/v1" apiv1 "code.vikunja.io/api/routes/api/v1"
_ "code.vikunja.io/api/routes/api/v1/swagger" // for docs generation _ "code.vikunja.io/api/routes/api/v1/swagger" // for docs generation
"code.vikunja.io/api/routes/crud" "code.vikunja.io/api/routes/crud"
"net/http"
) )
// NewEcho registers a new Echo instance // NewEcho registers a new Echo instance
@ -83,27 +82,6 @@ func RegisterRoutes(e *echo.Echo) {
a.POST("/login", apiv1.Login) a.POST("/login", apiv1.Login)
a.POST("/register", apiv1.RegisterUser) a.POST("/register", apiv1.RegisterUser)
a.POST("/test/:infi/:Käsebrot/blub/:gedöns", func(c echo.Context) error {
type testStruct struct {
Integ int64 `param:"infi" form:"infi"`
Cheese string `param:"Käsebrot"`
Kram string `param:"gedöns"`
Other string
Whooo int64
Blub float64
Test string `form:"test"`
}
t := testStruct{}
if err := crud.ParamBinder(&t, c); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "No or invalid model provided.")
}
return c.JSON(http.StatusOK, &t)
})
// ===== Routes with Authetification ===== // ===== Routes with Authetification =====
// Authetification // Authetification
a.Use(middleware.JWT(models.Config.JWTLoginSecret)) a.Use(middleware.JWT(models.Config.JWTLoginSecret))