Swagger docs

This commit is contained in:
kolaente 2019-09-25 20:05:49 +02:00
parent 5408bb6c58
commit a5ca661204
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 764 additions and 63 deletions

View File

@ -61,7 +61,7 @@ type TaskRelation struct {
// The ID of the "base" task, the task which has a relation to another.
TaskID int64 `xorm:"int(11) not null" json:"task_id" param:"task"`
// The ID of the other task, the task which is being related.
OtherTaskID int64 `xorm:"int(11) not null" json:"other_task_id" param:"othertask"`
OtherTaskID int64 `xorm:"int(11) not null" json:"other_task_id"`
// The kind of the relation.
RelationKind RelationKind `xorm:"varchar(50) not null" json:"relation_kind"`
@ -86,6 +86,18 @@ func (TaskRelation) TableName() string {
type RelatedTaskMap map[RelationKind][]*Task
// Create creates a new task relation
// @Summary Creates a new relation between two tasks
// @Description Creates a new relation between two tasks. The user needs to have update rights on the base task and at least read rights on the other task. Both tasks do not need to be on the same list.
// @tags task
// @Accept json
// @Produce json
// @Security JWTKeyAuth
// @Param relation body models.TaskRelation true "The relation object"
// @Param taskID path int true "Task ID"
// @Success 200 {object} models.TaskRelation "The created task relation object."
// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid task relation object provided."
// @Failure 500 {object} models.Message "Internal error"
// @Router /tasks/{taskID}/relations [put]
func (rel *TaskRelation) Create(a web.Auth) error {
// Check if both tasks are the same
@ -139,6 +151,18 @@ func (rel *TaskRelation) Create(a web.Auth) error {
}
// Delete removes a task relation
// @Summary Remove a task relation
// @tags task
// @Accept json
// @Produce json
// @Security JWTKeyAuth
// @Param relation body models.TaskRelation true "The relation object"
// @Param taskID path int true "Task ID"
// @Success 200 {object} models.Message "The task relation was successfully deleted."
// @Failure 400 {object} code.vikunja.io/web.HTTPError "Invalid task relation object provided."
// @Failure 404 {object} code.vikunja.io/web.HTTPError "The task relation was not found."
// @Failure 500 {object} models.Message "Internal error"
// @Router /tasks/{taskID}/relations [delete]
func (rel *TaskRelation) Delete() error {
// Check if the relation exists
exists, err := x.

View File

@ -264,7 +264,7 @@ func registerAPIRoutes(a *echo.Group) {
},
}
a.PUT("/tasks/:task/relations", taskRelationHandler.CreateWeb)
a.DELETE("/tasks/:task/relations/:othertask", taskRelationHandler.DeleteWeb)
a.DELETE("/tasks/:task/relations", taskRelationHandler.DeleteWeb)
labelHandler := &handler.WebHandler{
EmptyStruct: func() handler.CObject {

View File

@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2019-09-20 19:04:01.162535903 +0200 CEST m=+0.097033344
// 2019-09-25 20:04:01.083178871 +0200 CEST m=+0.411169970
package swagger
@ -3204,6 +3204,134 @@ var doc = `{
}
}
},
"/tasks/{taskID}/relations": {
"put": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Creates a new relation between two tasks. The user needs to have update rights on the base task and at least read rights on the other task. Both tasks do not need to be on the same list.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"tasks"
],
"summary": "Creates a new relation between two tasks",
"parameters": [
{
"description": "The relation object",
"name": "relation",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/models.TaskRelation"
}
},
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The created task relation object.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.TaskRelation"
}
},
"400": {
"description": "Invalid task relation object provided.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io.web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
},
"delete": {
"security": [
{
"JWTKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"tasks"
],
"summary": "Remove a task relation",
"parameters": [
{
"description": "The relation object",
"name": "relation",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/models.TaskRelation"
}
},
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The task relation was successfully deleted.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
},
"400": {
"description": "Invalid task relation object provided.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io.web.HTTPError"
}
},
"404": {
"description": "The task relation was not found.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io.web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/tasks/{task}/labels": {
"get": {
"security": [
@ -4143,10 +4271,6 @@ var doc = `{
"description": "The list this task belongs to.",
"type": "integer"
},
"parentTaskID": {
"description": "If the task is a subtask, this is the id of its parent.",
"type": "integer"
},
"percentDone": {
"description": "Determines how far a task is left from being done",
"type": "number"
@ -4155,6 +4279,11 @@ var doc = `{
"description": "The task priority. Can be anything you want, it is possible to sort by this later.",
"type": "integer"
},
"related_tasks": {
"description": "All related tasks, grouped by their relation kind",
"type": "object",
"$ref": "#/definitions/models.RelatedTaskMap"
},
"reminderDates": {
"description": "An array of unix timestamps when the user wants to be reminded of the task.",
"type": "array",
@ -4170,13 +4299,6 @@ var doc = `{
"description": "When this task starts.",
"type": "integer"
},
"subtasks": {
"description": "An array of subtasks.",
"type": "array",
"items": {
"$ref": "#/definitions/models.Task"
}
},
"task_ids": {
"description": "A list of task ids to update",
"type": "array",
@ -4499,6 +4621,111 @@ var doc = `{
}
}
},
"models.RelatedTaskMap": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "object",
"properties": {
"assignees": {
"description": "An array of users who are assigned to this task",
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"created": {
"description": "A unix timestamp when this task was created. You cannot change this value.",
"type": "integer"
},
"createdBy": {
"description": "The user who initially created the task.",
"type": "object",
"$ref": "#/definitions/models.User"
},
"description": {
"description": "The task description.",
"type": "string"
},
"done": {
"description": "Whether a task is done or not.",
"type": "boolean"
},
"doneAt": {
"description": "The unix timestamp when a task was marked as done.",
"type": "integer"
},
"dueDate": {
"description": "A unix timestamp when the task is due.",
"type": "integer"
},
"endDate": {
"description": "When this task ends.",
"type": "integer"
},
"hexColor": {
"description": "The task color in hex",
"type": "string",
"maxLength": 6
},
"id": {
"description": "The unique, numeric id of this task.",
"type": "integer"
},
"labels": {
"description": "An array of labels which are associated with this task.",
"type": "array",
"items": {
"$ref": "#/definitions/models.Label"
}
},
"listID": {
"description": "The list this task belongs to.",
"type": "integer"
},
"percentDone": {
"description": "Determines how far a task is left from being done",
"type": "number"
},
"priority": {
"description": "The task priority. Can be anything you want, it is possible to sort by this later.",
"type": "integer"
},
"related_tasks": {
"description": "All related tasks, grouped by their relation kind",
"type": "object",
"$ref": "#/definitions/models.RelatedTaskMap"
},
"reminderDates": {
"description": "An array of unix timestamps when the user wants to be reminded of the task.",
"type": "array",
"items": {
"type": "integer"
}
},
"repeatAfter": {
"description": "An amount in seconds this task repeats itself. If this is set, when marking the task as done, it will mark itself as \"undone\" and then increase all remindes and the due date by its amount.",
"type": "integer"
},
"startDate": {
"description": "When this task starts.",
"type": "integer"
},
"text": {
"description": "The task text. This is what you'll see in the list.",
"type": "string",
"maxLength": 250,
"minLength": 3
},
"updated": {
"description": "A unix timestamp when this task was last updated. You cannot change this value.",
"type": "integer"
}
}
}
}
},
"models.Task": {
"type": "object",
"properties": {
@ -4558,10 +4785,6 @@ var doc = `{
"description": "The list this task belongs to.",
"type": "integer"
},
"parentTaskID": {
"description": "If the task is a subtask, this is the id of its parent.",
"type": "integer"
},
"percentDone": {
"description": "Determines how far a task is left from being done",
"type": "number"
@ -4570,6 +4793,11 @@ var doc = `{
"description": "The task priority. Can be anything you want, it is possible to sort by this later.",
"type": "integer"
},
"related_tasks": {
"description": "All related tasks, grouped by their relation kind",
"type": "object",
"$ref": "#/definitions/models.RelatedTaskMap"
},
"reminderDates": {
"description": "An array of unix timestamps when the user wants to be reminded of the task.",
"type": "array",
@ -4585,13 +4813,6 @@ var doc = `{
"description": "When this task starts.",
"type": "integer"
},
"subtasks": {
"description": "An array of subtasks.",
"type": "array",
"items": {
"$ref": "#/definitions/models.Task"
}
},
"text": {
"description": "The task text. This is what you'll see in the list.",
"type": "string",
@ -4615,6 +4836,32 @@ var doc = `{
}
}
},
"models.TaskRelation": {
"type": "object",
"properties": {
"created": {
"description": "A unix timestamp when this label was created. You cannot change this value.",
"type": "integer"
},
"created_by": {
"description": "The user who created this relation",
"type": "object",
"$ref": "#/definitions/models.User"
},
"other_task_id": {
"description": "The ID of the other task, the task which is being related.",
"type": "integer"
},
"relation_kind": {
"description": "The kind of the relation.",
"type": "string"
},
"task_id": {
"description": "The ID of the \"base\" task, the task which has a relation to another.",
"type": "integer"
}
}
},
"models.Team": {
"type": "object",
"properties": {

View File

@ -3191,6 +3191,134 @@
}
}
},
"/tasks/{taskID}/relations": {
"put": {
"security": [
{
"JWTKeyAuth": []
}
],
"description": "Creates a new relation between two tasks. The user needs to have update rights on the base task and at least read rights on the other task. Both tasks do not need to be on the same list.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"tasks"
],
"summary": "Creates a new relation between two tasks",
"parameters": [
{
"description": "The relation object",
"name": "relation",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/models.TaskRelation"
}
},
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The created task relation object.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.TaskRelation"
}
},
"400": {
"description": "Invalid task relation object provided.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io/web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
},
"delete": {
"security": [
{
"JWTKeyAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"tasks"
],
"summary": "Remove a task relation",
"parameters": [
{
"description": "The relation object",
"name": "relation",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/models.TaskRelation"
}
},
{
"type": "integer",
"description": "Task ID",
"name": "taskID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "The task relation was successfully deleted.",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
},
"400": {
"description": "Invalid task relation object provided.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io/web.HTTPError"
}
},
"404": {
"description": "The task relation was not found.",
"schema": {
"type": "object",
"$ref": "#/definitions/code.vikunja.io/web.HTTPError"
}
},
"500": {
"description": "Internal error",
"schema": {
"type": "object",
"$ref": "#/definitions/models.Message"
}
}
}
}
},
"/tasks/{task}/labels": {
"get": {
"security": [
@ -4129,10 +4257,6 @@
"description": "The list this task belongs to.",
"type": "integer"
},
"parentTaskID": {
"description": "If the task is a subtask, this is the id of its parent.",
"type": "integer"
},
"percentDone": {
"description": "Determines how far a task is left from being done",
"type": "number"
@ -4141,6 +4265,11 @@
"description": "The task priority. Can be anything you want, it is possible to sort by this later.",
"type": "integer"
},
"related_tasks": {
"description": "All related tasks, grouped by their relation kind",
"type": "object",
"$ref": "#/definitions/models.RelatedTaskMap"
},
"reminderDates": {
"description": "An array of unix timestamps when the user wants to be reminded of the task.",
"type": "array",
@ -4156,13 +4285,6 @@
"description": "When this task starts.",
"type": "integer"
},
"subtasks": {
"description": "An array of subtasks.",
"type": "array",
"items": {
"$ref": "#/definitions/models.Task"
}
},
"task_ids": {
"description": "A list of task ids to update",
"type": "array",
@ -4485,6 +4607,111 @@
}
}
},
"models.RelatedTaskMap": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "object",
"properties": {
"assignees": {
"description": "An array of users who are assigned to this task",
"type": "array",
"items": {
"$ref": "#/definitions/models.User"
}
},
"created": {
"description": "A unix timestamp when this task was created. You cannot change this value.",
"type": "integer"
},
"createdBy": {
"description": "The user who initially created the task.",
"type": "object",
"$ref": "#/definitions/models.User"
},
"description": {
"description": "The task description.",
"type": "string"
},
"done": {
"description": "Whether a task is done or not.",
"type": "boolean"
},
"doneAt": {
"description": "The unix timestamp when a task was marked as done.",
"type": "integer"
},
"dueDate": {
"description": "A unix timestamp when the task is due.",
"type": "integer"
},
"endDate": {
"description": "When this task ends.",
"type": "integer"
},
"hexColor": {
"description": "The task color in hex",
"type": "string",
"maxLength": 6
},
"id": {
"description": "The unique, numeric id of this task.",
"type": "integer"
},
"labels": {
"description": "An array of labels which are associated with this task.",
"type": "array",
"items": {
"$ref": "#/definitions/models.Label"
}
},
"listID": {
"description": "The list this task belongs to.",
"type": "integer"
},
"percentDone": {
"description": "Determines how far a task is left from being done",
"type": "number"
},
"priority": {
"description": "The task priority. Can be anything you want, it is possible to sort by this later.",
"type": "integer"
},
"related_tasks": {
"description": "All related tasks, grouped by their relation kind",
"type": "object",
"$ref": "#/definitions/models.RelatedTaskMap"
},
"reminderDates": {
"description": "An array of unix timestamps when the user wants to be reminded of the task.",
"type": "array",
"items": {
"type": "integer"
}
},
"repeatAfter": {
"description": "An amount in seconds this task repeats itself. If this is set, when marking the task as done, it will mark itself as \"undone\" and then increase all remindes and the due date by its amount.",
"type": "integer"
},
"startDate": {
"description": "When this task starts.",
"type": "integer"
},
"text": {
"description": "The task text. This is what you'll see in the list.",
"type": "string",
"maxLength": 250,
"minLength": 3
},
"updated": {
"description": "A unix timestamp when this task was last updated. You cannot change this value.",
"type": "integer"
}
}
}
}
},
"models.Task": {
"type": "object",
"properties": {
@ -4544,10 +4771,6 @@
"description": "The list this task belongs to.",
"type": "integer"
},
"parentTaskID": {
"description": "If the task is a subtask, this is the id of its parent.",
"type": "integer"
},
"percentDone": {
"description": "Determines how far a task is left from being done",
"type": "number"
@ -4556,6 +4779,11 @@
"description": "The task priority. Can be anything you want, it is possible to sort by this later.",
"type": "integer"
},
"related_tasks": {
"description": "All related tasks, grouped by their relation kind",
"type": "object",
"$ref": "#/definitions/models.RelatedTaskMap"
},
"reminderDates": {
"description": "An array of unix timestamps when the user wants to be reminded of the task.",
"type": "array",
@ -4571,13 +4799,6 @@
"description": "When this task starts.",
"type": "integer"
},
"subtasks": {
"description": "An array of subtasks.",
"type": "array",
"items": {
"$ref": "#/definitions/models.Task"
}
},
"text": {
"description": "The task text. This is what you'll see in the list.",
"type": "string",
@ -4601,6 +4822,32 @@
}
}
},
"models.TaskRelation": {
"type": "object",
"properties": {
"created": {
"description": "A unix timestamp when this label was created. You cannot change this value.",
"type": "integer"
},
"created_by": {
"description": "The user who created this relation",
"type": "object",
"$ref": "#/definitions/models.User"
},
"other_task_id": {
"description": "The ID of the other task, the task which is being related.",
"type": "integer"
},
"relation_kind": {
"description": "The kind of the relation.",
"type": "string"
},
"task_id": {
"description": "The ID of the \"base\" task, the task which has a relation to another.",
"type": "integer"
}
}
},
"models.Team": {
"type": "object",
"properties": {

View File

@ -74,9 +74,6 @@ definitions:
listID:
description: The list this task belongs to.
type: integer
parentTaskID:
description: If the task is a subtask, this is the id of its parent.
type: integer
percentDone:
description: Determines how far a task is left from being done
type: number
@ -84,6 +81,10 @@ definitions:
description: The task priority. Can be anything you want, it is possible to
sort by this later.
type: integer
related_tasks:
$ref: '#/definitions/models.RelatedTaskMap'
description: All related tasks, grouped by their relation kind
type: object
reminderDates:
description: An array of unix timestamps when the user wants to be reminded
of the task.
@ -98,11 +99,6 @@ definitions:
startDate:
description: When this task starts.
type: integer
subtasks:
description: An array of subtasks.
items:
$ref: '#/definitions/models.Task'
type: array
task_ids:
description: A list of task ids to update
items:
@ -360,6 +356,90 @@ definitions:
maxLength: 250
type: string
type: object
models.RelatedTaskMap:
additionalProperties:
items:
properties:
assignees:
description: An array of users who are assigned to this task
items:
$ref: '#/definitions/models.User'
type: array
created:
description: A unix timestamp when this task was created. You cannot change
this value.
type: integer
createdBy:
$ref: '#/definitions/models.User'
description: The user who initially created the task.
type: object
description:
description: The task description.
type: string
done:
description: Whether a task is done or not.
type: boolean
doneAt:
description: The unix timestamp when a task was marked as done.
type: integer
dueDate:
description: A unix timestamp when the task is due.
type: integer
endDate:
description: When this task ends.
type: integer
hexColor:
description: The task color in hex
maxLength: 6
type: string
id:
description: The unique, numeric id of this task.
type: integer
labels:
description: An array of labels which are associated with this task.
items:
$ref: '#/definitions/models.Label'
type: array
listID:
description: The list this task belongs to.
type: integer
percentDone:
description: Determines how far a task is left from being done
type: number
priority:
description: The task priority. Can be anything you want, it is possible
to sort by this later.
type: integer
related_tasks:
$ref: '#/definitions/models.RelatedTaskMap'
description: All related tasks, grouped by their relation kind
type: object
reminderDates:
description: An array of unix timestamps when the user wants to be reminded
of the task.
items:
type: integer
type: array
repeatAfter:
description: An amount in seconds this task repeats itself. If this is
set, when marking the task as done, it will mark itself as "undone"
and then increase all remindes and the due date by its amount.
type: integer
startDate:
description: When this task starts.
type: integer
text:
description: The task text. This is what you'll see in the list.
maxLength: 250
minLength: 3
type: string
updated:
description: A unix timestamp when this task was last updated. You cannot
change this value.
type: integer
type: object
type: array
type: object
models.Task:
properties:
assignees:
@ -405,9 +485,6 @@ definitions:
listID:
description: The list this task belongs to.
type: integer
parentTaskID:
description: If the task is a subtask, this is the id of its parent.
type: integer
percentDone:
description: Determines how far a task is left from being done
type: number
@ -415,6 +492,10 @@ definitions:
description: The task priority. Can be anything you want, it is possible to
sort by this later.
type: integer
related_tasks:
$ref: '#/definitions/models.RelatedTaskMap'
description: All related tasks, grouped by their relation kind
type: object
reminderDates:
description: An array of unix timestamps when the user wants to be reminded
of the task.
@ -429,11 +510,6 @@ definitions:
startDate:
description: When this task starts.
type: integer
subtasks:
description: An array of subtasks.
items:
$ref: '#/definitions/models.Task'
type: array
text:
description: The task text. This is what you'll see in the list.
maxLength: 250
@ -451,6 +527,26 @@ definitions:
user_id:
type: integer
type: object
models.TaskRelation:
properties:
created:
description: A unix timestamp when this label was created. You cannot change
this value.
type: integer
created_by:
$ref: '#/definitions/models.User'
description: The user who created this relation
type: object
other_task_id:
description: The ID of the other task, the task which is being related.
type: integer
relation_kind:
description: The kind of the relation.
type: string
task_id:
description: The ID of the "base" task, the task which has a relation to another.
type: integer
type: object
models.Team:
properties:
created:
@ -2911,6 +3007,93 @@ paths:
summary: Update all labels on a task.
tags:
- labels
/tasks/{taskID}/relations:
delete:
consumes:
- application/json
parameters:
- description: The relation object
in: body
name: relation
required: true
schema:
$ref: '#/definitions/models.TaskRelation'
type: object
- description: Task ID
in: path
name: taskID
required: true
type: integer
produces:
- application/json
responses:
"200":
description: The task relation was successfully deleted.
schema:
$ref: '#/definitions/models.Message'
type: object
"400":
description: Invalid task relation object provided.
schema:
$ref: '#/definitions/code.vikunja.io/web.HTTPError'
type: object
"404":
description: The task relation was not found.
schema:
$ref: '#/definitions/code.vikunja.io/web.HTTPError'
type: object
"500":
description: Internal error
schema:
$ref: '#/definitions/models.Message'
type: object
security:
- JWTKeyAuth: []
summary: Remove a task relation
tags:
- tasks
put:
consumes:
- application/json
description: Creates a new relation between two tasks. The user needs to have
update rights on the base task and at least read rights on the other task.
Both tasks do not need to be on the same list.
parameters:
- description: The relation object
in: body
name: relation
required: true
schema:
$ref: '#/definitions/models.TaskRelation'
type: object
- description: Task ID
in: path
name: taskID
required: true
type: integer
produces:
- application/json
responses:
"200":
description: The created task relation object.
schema:
$ref: '#/definitions/models.TaskRelation'
type: object
"400":
description: Invalid task relation object provided.
schema:
$ref: '#/definitions/code.vikunja.io/web.HTTPError'
type: object
"500":
description: Internal error
schema:
$ref: '#/definitions/models.Message'
type: object
security:
- JWTKeyAuth: []
summary: Creates a new relation between two tasks
tags:
- tasks
/tasks/all:
get:
consumes: