2024-03-08 10:17:27 +01:00
|
|
|
// Package docs Code generated by swaggo/swag. DO NOT EDIT
|
|
|
|
package docs
|
|
|
|
|
|
|
|
import "github.com/swaggo/swag"
|
|
|
|
|
|
|
|
const docTemplate = `{
|
|
|
|
"schemes": {{ marshal .Schemes }},
|
|
|
|
"swagger": "2.0",
|
|
|
|
"info": {
|
|
|
|
"description": "{{escape .Description}}",
|
|
|
|
"title": "{{.Title}}",
|
|
|
|
"contact": {},
|
|
|
|
"license": {
|
|
|
|
"name": "AGPL",
|
|
|
|
"url": "https://www.gnu.org/licenses/agpl-3.0.html"
|
|
|
|
},
|
|
|
|
"version": "{{.Version}}"
|
|
|
|
},
|
|
|
|
"host": "{{.Host}}",
|
|
|
|
"basePath": "{{.BasePath}}",
|
|
|
|
"paths": {
|
2024-03-18 22:40:51 +01:00
|
|
|
"/login": {
|
2024-03-08 10:17:27 +01:00
|
|
|
"post": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"description": "Logs in a user and returns a JWT token",
|
2024-03-08 10:17:27 +01:00
|
|
|
"consumes": [
|
|
|
|
"application/json"
|
|
|
|
],
|
|
|
|
"produces": [
|
2024-03-29 18:43:26 +01:00
|
|
|
"application/json"
|
2024-03-18 22:40:51 +01:00
|
|
|
],
|
|
|
|
"tags": [
|
2024-03-29 18:43:26 +01:00
|
|
|
"Auth"
|
2024-03-18 22:40:51 +01:00
|
|
|
],
|
2024-03-29 18:43:26 +01:00
|
|
|
"summary": "Login",
|
2024-03-18 22:40:51 +01:00
|
|
|
"parameters": [
|
|
|
|
{
|
2024-03-29 18:43:26 +01:00
|
|
|
"description": "User credentials",
|
|
|
|
"name": "body",
|
2024-03-18 22:40:51 +01:00
|
|
|
"in": "body",
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"$ref": "#/definitions/types.NewUser"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"responses": {
|
|
|
|
"200": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"description": "JWT token",
|
2024-03-18 22:40:51 +01:00
|
|
|
"schema": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"$ref": "#/definitions/types.Token"
|
2024-03-18 22:40:51 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"400": {
|
|
|
|
"description": "Bad request",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"401": {
|
|
|
|
"description": "Unauthorized",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-03-29 18:43:26 +01:00
|
|
|
"/loginrenew": {
|
2024-03-18 22:40:51 +01:00
|
|
|
"post": {
|
2024-03-19 00:27:31 +01:00
|
|
|
"security": [
|
|
|
|
{
|
2024-03-29 18:43:26 +01:00
|
|
|
"JWT": []
|
2024-03-19 00:27:31 +01:00
|
|
|
}
|
|
|
|
],
|
2024-03-29 18:43:26 +01:00
|
|
|
"description": "Renews the users token.",
|
2024-03-18 22:40:51 +01:00
|
|
|
"produces": [
|
2024-03-29 18:43:26 +01:00
|
|
|
"application/json"
|
2024-03-18 22:40:51 +01:00
|
|
|
],
|
|
|
|
"tags": [
|
2024-03-29 18:43:26 +01:00
|
|
|
"Auth"
|
2024-03-18 22:40:51 +01:00
|
|
|
],
|
2024-03-19 00:27:31 +01:00
|
|
|
"summary": "LoginRenews",
|
2024-03-18 22:40:51 +01:00
|
|
|
"responses": {
|
|
|
|
"200": {
|
|
|
|
"description": "Successfully signed token for user",
|
|
|
|
"schema": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"$ref": "#/definitions/types.Token"
|
2024-03-18 22:40:51 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"401": {
|
|
|
|
"description": "Unauthorized",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-04-03 17:48:02 +02:00
|
|
|
"/promote/{projectName}": {
|
|
|
|
"put": {
|
|
|
|
"security": [
|
|
|
|
{
|
|
|
|
"JWT": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": "Promote a user to project manager",
|
|
|
|
"consumes": [
|
|
|
|
"text/plain"
|
|
|
|
],
|
|
|
|
"produces": [
|
|
|
|
"text/plain"
|
|
|
|
],
|
|
|
|
"tags": [
|
|
|
|
"Auth"
|
|
|
|
],
|
|
|
|
"summary": "Promote to project manager",
|
|
|
|
"parameters": [
|
|
|
|
{
|
|
|
|
"type": "string",
|
|
|
|
"description": "Project name",
|
|
|
|
"name": "projectName",
|
|
|
|
"in": "path",
|
|
|
|
"required": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "string",
|
|
|
|
"description": "User name",
|
|
|
|
"name": "userName",
|
|
|
|
"in": "query",
|
|
|
|
"required": true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"responses": {
|
|
|
|
"403": {
|
|
|
|
"description": "Forbidden",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-03-18 23:21:49 +01:00
|
|
|
"/promoteToAdmin": {
|
|
|
|
"post": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"security": [
|
|
|
|
{
|
|
|
|
"JWT": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"description": "Promote chosen user to site admin",
|
2024-03-18 23:21:49 +01:00
|
|
|
"consumes": [
|
|
|
|
"application/json"
|
|
|
|
],
|
|
|
|
"produces": [
|
|
|
|
"text/plain"
|
|
|
|
],
|
|
|
|
"tags": [
|
|
|
|
"User"
|
|
|
|
],
|
2024-03-19 00:27:31 +01:00
|
|
|
"summary": "PromoteToAdmin",
|
2024-03-18 23:21:49 +01:00
|
|
|
"parameters": [
|
|
|
|
{
|
|
|
|
"description": "user info",
|
|
|
|
"name": "NewUser",
|
|
|
|
"in": "body",
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"$ref": "#/definitions/types.NewUser"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"responses": {
|
|
|
|
"200": {
|
2024-03-29 15:59:36 +01:00
|
|
|
"description": "Successfully promoted user",
|
2024-03-18 23:21:49 +01:00
|
|
|
"schema": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"$ref": "#/definitions/types.Token"
|
2024-03-18 23:21:49 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"400": {
|
2024-03-29 15:59:36 +01:00
|
|
|
"description": "Bad request",
|
2024-03-18 23:21:49 +01:00
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"401": {
|
|
|
|
"description": "Unauthorized",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-03-18 22:40:51 +01:00
|
|
|
"/register": {
|
|
|
|
"post": {
|
|
|
|
"description": "Register a new user",
|
|
|
|
"consumes": [
|
|
|
|
"application/json"
|
|
|
|
],
|
|
|
|
"produces": [
|
|
|
|
"text/plain"
|
|
|
|
],
|
2024-03-08 10:17:27 +01:00
|
|
|
"tags": [
|
2024-03-29 18:43:26 +01:00
|
|
|
"Auth"
|
2024-03-08 10:17:27 +01:00
|
|
|
],
|
2024-03-19 00:27:31 +01:00
|
|
|
"summary": "Register",
|
2024-03-18 19:59:14 +01:00
|
|
|
"parameters": [
|
|
|
|
{
|
|
|
|
"description": "User to register",
|
2024-03-18 22:40:51 +01:00
|
|
|
"name": "NewUser",
|
2024-03-18 19:59:14 +01:00
|
|
|
"in": "body",
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"$ref": "#/definitions/types.NewUser"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2024-03-08 10:17:27 +01:00
|
|
|
"responses": {
|
|
|
|
"200": {
|
|
|
|
"description": "User added",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"400": {
|
|
|
|
"description": "Bad request",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
2024-03-18 22:40:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"/userdelete/{username}": {
|
|
|
|
"delete": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"security": [
|
|
|
|
{
|
|
|
|
"JWT": []
|
|
|
|
}
|
|
|
|
],
|
2024-03-18 22:40:51 +01:00
|
|
|
"description": "UserDelete deletes a user from the database",
|
|
|
|
"consumes": [
|
|
|
|
"application/json"
|
|
|
|
],
|
|
|
|
"produces": [
|
|
|
|
"text/plain"
|
|
|
|
],
|
|
|
|
"tags": [
|
|
|
|
"User"
|
|
|
|
],
|
2024-03-19 00:27:31 +01:00
|
|
|
"summary": "UserDelete",
|
2024-03-18 22:40:51 +01:00
|
|
|
"responses": {
|
|
|
|
"200": {
|
|
|
|
"description": "User deleted",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"401": {
|
|
|
|
"description": "Unauthorized",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"403": {
|
|
|
|
"description": "You can only delete yourself",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
2024-03-18 23:21:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"/users/all": {
|
|
|
|
"get": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"security": [
|
|
|
|
{
|
|
|
|
"JWT": []
|
|
|
|
}
|
2024-03-18 23:21:49 +01:00
|
|
|
],
|
2024-03-29 18:43:26 +01:00
|
|
|
"description": "lists all users",
|
2024-03-18 23:21:49 +01:00
|
|
|
"produces": [
|
2024-03-29 18:43:26 +01:00
|
|
|
"application/json"
|
2024-03-18 23:21:49 +01:00
|
|
|
],
|
|
|
|
"tags": [
|
|
|
|
"User"
|
|
|
|
],
|
2024-03-19 00:27:31 +01:00
|
|
|
"summary": "ListsAllUsers",
|
2024-03-18 23:21:49 +01:00
|
|
|
"responses": {
|
|
|
|
"200": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"description": "Successfully returned all users",
|
2024-03-18 23:21:49 +01:00
|
|
|
"schema": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"type": "array",
|
|
|
|
"items": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
2024-03-18 23:21:49 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"401": {
|
|
|
|
"description": "Unauthorized",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"500": {
|
|
|
|
"description": "Internal server error",
|
|
|
|
"schema": {
|
|
|
|
"type": "string"
|
|
|
|
}
|
2024-03-08 10:17:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-03-18 19:59:14 +01:00
|
|
|
"definitions": {
|
|
|
|
"types.NewUser": {
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"password": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"type": "string",
|
|
|
|
"example": "password123"
|
2024-03-18 19:59:14 +01:00
|
|
|
},
|
|
|
|
"username": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"type": "string",
|
|
|
|
"example": "username123"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"types.Token": {
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"token": {
|
2024-03-18 19:59:14 +01:00
|
|
|
"type": "string"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-03-19 00:27:31 +01:00
|
|
|
"securityDefinitions": {
|
2024-03-29 18:43:26 +01:00
|
|
|
"JWT": {
|
|
|
|
"description": "Use the JWT token provided by the login endpoint to authenticate requests. **Prefix the token with \"Bearer \".**",
|
2024-03-19 00:27:31 +01:00
|
|
|
"type": "apiKey",
|
|
|
|
"name": "Authorization",
|
|
|
|
"in": "header"
|
|
|
|
}
|
|
|
|
},
|
2024-03-08 10:17:27 +01:00
|
|
|
"externalDocs": {
|
|
|
|
"description": "OpenAPI",
|
|
|
|
"url": "https://swagger.io/resources/open-api/"
|
|
|
|
}
|
|
|
|
}`
|
|
|
|
|
|
|
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
|
|
|
var SwaggerInfo = &swag.Spec{
|
|
|
|
Version: "0.0.1",
|
|
|
|
Host: "localhost:8080",
|
|
|
|
BasePath: "/api",
|
|
|
|
Schemes: []string{},
|
|
|
|
Title: "TTime API",
|
|
|
|
Description: "This is the API for TTime, a time tracking application.",
|
|
|
|
InfoInstanceName: "swagger",
|
|
|
|
SwaggerTemplate: docTemplate,
|
|
|
|
LeftDelim: "{{",
|
|
|
|
RightDelim: "}}",
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
|
|
|
|
}
|