Fix: Finished Backend

This commit is contained in:
Aron Malcher 2024-02-26 21:46:33 +01:00
parent 6b388729d9
commit ffaf8d989e
Signed by: aronmal
GPG key ID: 816B7707426FC612
30 changed files with 1478 additions and 873 deletions

View file

@ -10,19 +10,22 @@
"version": "0.0.0"
},
"paths": {
"/api/boot/config": {
"/api/boot": {
"get": {
"tags": ["Guild configs"],
"summary": "Find a guild's config by ID",
"description": "Returns a single guild's config.",
"operationId": "getGuildsFromBoot",
"tags": ["Bot bootup"],
"summary": "Retrieve all guild's configs",
"description": "Returns all guild's configs.",
"operationId": "getGuildsForBoot",
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/bootConfig"
"type": "array",
"items": {
"$ref": "#/components/schemas/guildConfig"
}
}
}
}
@ -30,20 +33,23 @@
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
}
},
"/api/{guildId}/config": {
"get": {
"tags": ["Guild configs"],
"tags": ["Guild config"],
"summary": "Find a guild's config by ID",
"description": "Returns a single guild's config.",
"operationId": "getGuildById",
@ -73,18 +79,21 @@
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
},
"delete": {
"tags": ["Guild configs"],
"tags": ["Guild config"],
"summary": "Deletes a guild's config by ID",
"description": "Delete a guild's config when the bot is removed from the guild.",
"operationId": "deleteGuildById",
@ -107,13 +116,16 @@
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
}
@ -153,19 +165,22 @@
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
},
"put": {
"tags": ["Time planning messages"],
"summary": "Put message IDs for tp_messages of guild by ID",
"summary": "Put new message IDs for tp_messages of guild by ID",
"description": "Returns tp_messages for a guild",
"operationId": "putTp_messagesOfGuildById",
"parameters": [
@ -180,30 +195,37 @@
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tp_messages"
}
"requestBody": {
"description": "Put new message IDs for tp_messages in channel",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tp_messages"
}
}
},
"required": true
},
"responses": {
"204": {
"description": "Time planning not enabled for this guild"
"description": "successful operation"
},
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Time planning not enabled for this guild"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
}
@ -232,9 +254,20 @@
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/tp_messages"
"type": "object",
"required": ["matches", "timezone"],
"properties": {
"matches": {
"type": "array",
"items": {
"$ref": "#/components/schemas/match"
}
},
"timezone": {
"type": "string",
"format": "text",
"example": "Europe/Berlin"
}
}
}
}
@ -246,21 +279,22 @@
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
}
},
"/api/{guildId}/matches/{channelId}": {
},
"post": {
"tags": ["Matches"],
"summary": "Save a new created match in channel of guild by IDs",
"summary": "Save a new created match of guild by ID",
"description": "Returns tp_messages for a guild",
"operationId": "postMatchOfGuildById",
"parameters": [
@ -273,108 +307,48 @@
"type": "string",
"format": "varchar(20)"
}
},
{
"name": "channelId",
"in": "path",
"description": "ID of match's channel to set",
"required": true,
"schema": {
"type": "string",
"format": "varchar(20)"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tp_messages"
"requestBody": {
"description": "Save a new created match in channel",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["match", "timezone"],
"properties": {
"match": {
"$ref": "#/components/schemas/match"
},
"timezone": {
"type": "string",
"format": "text",
"example": "Europe/Berlin",
"description": "Has to match guild tz"
}
}
}
}
},
"required": true
},
"responses": {
"204": {
"description": "Time planning not enabled for this guild"
"description": "successful operation"
},
"400": {
"description": "Invalid ID supplied"
},
"401": {
"description": "Unauthorized"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
}
]
}
},
"/api/{guildId}/matches/{channelId}/{matchMessageId}": {
"put": {
"tags": ["Matches"],
"summary": "Set state for match of guild by IDs",
"description": "Returns tp_messages for a guild",
"operationId": "putMatchOfGuildById",
"parameters": [
{
"name": "guildId",
"in": "path",
"description": "ID of guild's tp_messages to return",
"required": true,
"schema": {
"type": "string",
"format": "varchar(20)"
}
},
{
"name": "channelId",
"in": "path",
"description": "ID of match's channel to set",
"required": true,
"schema": {
"type": "string",
"format": "varchar(20)"
}
},
{
"name": "matchMessageId",
"in": "path",
"description": "ID of match's message Id to set",
"required": true,
"schema": {
"type": "string",
"format": "varchar(20)"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tp_messages"
}
}
}
},
"204": {
"description": "Time planning not enabled for this guild"
},
"400": {
"description": "Invalid ID supplied"
},
"404": {
"description": "Guild not found"
}
},
"security": [
{
"bot_token": []
"basicAuth": []
}
]
}
@ -382,21 +356,11 @@
},
"components": {
"schemas": {
"bootConfig": {
"type": "object",
"properties": {
"guilds": {
"type": "array",
"items": {
"$ref": "#/components/schemas/guildConfig"
}
}
}
},
"guildConfig": {
"type": "object",
"required": ["guildId", "timezone", "features", "matches", "checksum"],
"properties": {
"guildID": {
"guildId": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789"
@ -408,14 +372,27 @@
},
"features": {
"type": "object",
"required": ["timePlanning"],
"properties": {
"time_planning": {
"timePlanning": {
"type": "object",
"required": [
"enabled",
"channelId",
"targetMinute",
"targetHour",
"targetDay",
"roles"
],
"properties": {
"channelID": {
"enabled": {
"type": "boolean"
},
"channelId": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789"
"example": "1234567890123456789",
"nullable": true
},
"targetMinute": {
"type": "number",
@ -431,6 +408,11 @@
},
"roles": {
"type": "object",
"required": [
"enabled",
"isAvailableRoleId",
"wantsToBeNotifieRoledId"
],
"properties": {
"enabled": {
"type": "boolean"
@ -458,13 +440,25 @@
"items": {
"$ref": "#/components/schemas/match"
}
},
"checksum": {
"type": "string"
}
}
},
"match": {
"type": "object",
"required": [
"channelId",
"matchType",
"createrId",
"roleId",
"opponentName",
"messageId",
"utc_ts"
],
"properties": {
"channelID": {
"channelId": {
"type": "string",
"format": "varcharq(20)",
"example": "1234567890123456789"
@ -489,54 +483,81 @@
"format": "varchar(100)",
"example": "?"
},
"messsageId": {
"messageId": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789"
},
"utc_ts": {
"type": "string",
"example": "1706180188"
"example": "2020-01-01T00:00:00Z"
}
}
},
"tp_messages": {
"type": "object",
"required": ["channelId", "messageIds"],
"properties": {
"guildId": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789"
},
"channelId": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789"
},
"messageIds": {
"type": "array",
"items": {
"type": "string",
"format": "varchar(20)"
},
"example": [
"1234567890123456789",
"1234567890123456789",
"1234567890123456789",
"1234567890123456789",
"1234567890123456789",
"1234567890123456789",
"1234567890123456789"
]
"type": "object",
"required": ["0", "1", "2", "3", "4", "5", "6"],
"properties": {
"0": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
},
"1": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
},
"2": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
},
"3": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
},
"4": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
},
"5": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
},
"6": {
"type": "string",
"format": "varchar(20)",
"example": "1234567890123456789",
"nullable": true
}
}
}
}
}
},
"securitySchemes": {
"bot_token": {
"basicAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT"
"scheme": "basic"
}
}
}