auth-api/docs/docs.go

726 lines
26 KiB
Go
Raw Normal View History

2023-05-08 15:29:19 +02:00
// Code generated by swaggo/swag. DO NOT EDIT.
2021-06-22 22:52:48 +02:00
package docs
2022-02-18 19:38:35 +01:00
import "github.com/swaggo/swag"
2021-06-22 22:52:48 +02:00
2023-05-08 15:29:19 +02:00
const docTemplate = `{
2021-06-22 22:52:48 +02:00
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
2022-02-18 19:38:35 +01:00
"description": "{{escape .Description}}",
2021-06-22 22:52:48 +02:00
"title": "{{.Title}}",
"contact": {
"name": "Power Plan",
2021-06-22 23:49:11 +02:00
"url": "https://pwrpln.com/",
2021-06-22 22:52:48 +02:00
"email": "lilleman@larvit.se"
},
"license": {
"name": "MIT"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
2023-05-08 15:29:19 +02:00
"/accounts": {
"get": {
"description": "Requires Authorization-header with role \"admin\".\nExample: Authorization: bearer xxx\nWhere \"xxx\" is a valid JWT token",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Get accounts",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/db.Account"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"415": {
"description": "Unsupported Media Type",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
}
}
},
2021-06-22 22:52:48 +02:00
"post": {
2021-06-22 23:49:11 +02:00
"description": "Requires Authorization-header with role \"admin\".\nExample: Authorization: bearer xxx\nWhere \"xxx\" is a valid JWT token",
2021-06-22 22:52:48 +02:00
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Create an account",
"operationId": "account-create",
2021-06-22 23:49:11 +02:00
"parameters": [
{
"description": "Account object to be written to database",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.AccountInput"
}
}
],
2021-06-22 22:52:48 +02:00
"responses": {
2021-06-24 00:42:54 +02:00
"201": {
"description": "Created",
2021-06-22 22:52:48 +02:00
"schema": {
"$ref": "#/definitions/db.CreatedAccount"
}
},
2021-06-24 00:42:54 +02:00
"400": {
"description": "Bad Request",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"409": {
"description": "Conflict",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"415": {
"description": "Unsupported Media Type",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
}
}
}
},
2023-05-08 15:29:19 +02:00
"/accounts/:id": {
2021-06-24 00:42:54 +02:00
"delete": {
2021-06-24 01:55:47 +02:00
"description": "Requires Authorization-header with role \"admin\" or a matching account id\nExample: Authorization: bearer xxx\nWhere \"xxx\" is a valid JWT token",
2021-06-24 00:42:54 +02:00
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Delete an account",
"operationId": "account-del",
"parameters": [
{
"type": "string",
"description": "Account ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "No Content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
2021-06-22 22:52:48 +02:00
"401": {
"description": "Unauthorized",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"403": {
"description": "Forbidden",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
2021-06-24 01:55:47 +02:00
"404": {
"description": "Not Found",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
2021-06-22 22:52:48 +02:00
"415": {
"description": "Unsupported Media Type",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"500": {
"description": "Internal Server Error",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
}
}
}
},
2023-05-08 15:29:19 +02:00
"/accounts/{id}": {
2021-06-22 22:52:48 +02:00
"get": {
2021-06-22 23:49:11 +02:00
"description": "Requires Authorization-header with either role \"admin\" or with a matching account id.\nExample: Authorization: bearer xxx\nWhere \"xxx\" is a valid JWT token",
2021-06-22 22:52:48 +02:00
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
2021-06-22 23:49:11 +02:00
"summary": "Get account by id",
2021-06-22 22:52:48 +02:00
"operationId": "get-account-by-id",
"parameters": [
{
"type": "string",
"description": "Account ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/db.Account"
}
},
"401": {
"description": "Unauthorized",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"403": {
"description": "Forbidden",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"415": {
"description": "Unsupported Media Type",
2021-06-24 01:55:47 +02:00
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
}
}
}
},
2023-05-08 15:29:19 +02:00
"/accounts/{id}/fields": {
2021-06-24 01:55:47 +02:00
"put": {
"description": "Requires Authorization-header with role \"admin\".\nExample: Authorization: bearer xxx\nWhere \"xxx\" is a valid JWT token",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Update account fields",
"operationId": "account-update-fields",
"parameters": [
{
"description": "Fields array with objects to be written to database",
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/db.AccountCreateInputFields"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/db.Account"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"401": {
"description": "Unauthorized",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"403": {
"description": "Forbidden",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
}
},
"415": {
"description": "Unsupported Media Type",
2021-06-22 22:52:48 +02:00
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"500": {
"description": "Internal Server Error",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
}
}
}
},
"/auth/api-key": {
"post": {
"description": "Authenticate account by API Key",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Authenticate account by API Key",
"operationId": "auth-account-by-api-key",
2021-06-22 23:49:11 +02:00
"parameters": [
{
"description": "API Key as a string in JSON format (just encapsulate the string with \\",
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "string"
}
}
],
2021-06-22 22:52:48 +02:00
"responses": {
"200": {
"description": "OK",
"schema": {
2021-06-22 23:49:11 +02:00
"$ref": "#/definitions/handlers.ResToken"
2021-06-22 22:52:48 +02:00
}
},
"401": {
"description": "Unauthorized",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"403": {
"description": "Forbidden",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"415": {
"description": "Unsupported Media Type",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"500": {
"description": "Internal Server Error",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
}
}
}
},
"/auth/password": {
"post": {
"description": "Authenticate account by Password",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Authenticate account by Password",
"operationId": "auth-account-by-password",
2021-06-22 23:49:11 +02:00
"parameters": [
{
"description": "Name and password to auth by",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.AuthInput"
}
}
],
2021-06-22 22:52:48 +02:00
"responses": {
"200": {
"description": "OK",
"schema": {
2021-06-22 23:49:11 +02:00
"$ref": "#/definitions/handlers.ResToken"
2021-06-22 22:52:48 +02:00
}
},
"401": {
"description": "Unauthorized",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"403": {
"description": "Forbidden",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"415": {
"description": "Unsupported Media Type",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"500": {
"description": "Internal Server Error",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
}
}
}
},
"/renew-token": {
"post": {
"description": "Renew token",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Renew token",
"operationId": "renew-token",
2021-06-22 23:49:11 +02:00
"parameters": [
{
"description": "Renewal token as a string in JSON format (just encapsulate the string with \\",
"name": "body",
"in": "body",
"required": true,
"schema": {
"type": "string"
}
}
],
2021-06-22 22:52:48 +02:00
"responses": {
"200": {
"description": "OK",
"schema": {
2021-06-22 23:49:11 +02:00
"$ref": "#/definitions/handlers.ResToken"
2021-06-22 22:52:48 +02:00
}
},
"401": {
"description": "Unauthorized",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"403": {
"description": "Forbidden",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"415": {
"description": "Unsupported Media Type",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
},
"500": {
"description": "Internal Server Error",
"schema": {
2021-06-22 23:49:11 +02:00
"type": "array",
"items": {
"$ref": "#/definitions/handlers.ResJSONError"
}
2021-06-22 22:52:48 +02:00
}
}
}
}
}
},
"definitions": {
"db.Account": {
"type": "object",
"properties": {
"created": {
"type": "string"
},
"fields": {
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"type": "string"
}
}
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
2021-06-22 23:49:11 +02:00
"db.AccountCreateInputFields": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
2021-06-22 22:52:48 +02:00
"db.CreatedAccount": {
"type": "object",
"properties": {
"apiKey": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
2021-06-22 23:49:11 +02:00
"handlers.AccountInput": {
"type": "object",
"properties": {
"fields": {
"type": "array",
"items": {
"$ref": "#/definitions/db.AccountCreateInputFields"
}
},
"name": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"handlers.AuthInput": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
2021-06-22 22:52:48 +02:00
"handlers.ResJSONError": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"field": {
"type": "string"
}
}
2021-06-22 23:49:11 +02:00
},
"handlers.ResToken": {
"type": "object",
"properties": {
"jwt": {
"type": "string"
},
"renewalToken": {
"type": "string"
}
}
2021-06-22 22:52:48 +02:00
}
}
}`
2023-05-08 15:29:19 +02:00
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
2022-02-18 19:38:35 +01:00
Version: "0.1",
Host: "",
BasePath: "/",
Schemes: []string{},
Title: "JWT Auth API",
Description: "This is a tiny http API for auth. Register accounts, auth with api-key or name/password, renew JWT tokens...",
InfoInstanceName: "swagger",
2023-05-08 15:29:19 +02:00
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
2021-06-22 22:52:48 +02:00
}
func init() {
2023-05-08 15:29:19 +02:00
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
2021-06-22 22:52:48 +02:00
}