Files
2026-03-14 20:00:36 +01:00

287 lines
8.9 KiB
JSON

{
"swagger": "2.0",
"info": {
"description": "API for managing users and artists in Music Index.",
"title": "Music Index API",
"contact": {},
"version": "1.0"
},
"basePath": "/api/v1/",
"paths": {
"/artists": {
"get": {
"produces": [
"application/json"
],
"tags": [
"artist"
],
"summary": "List all artists",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/artists/:id": {
"get": {
"produces": [
"application/json"
],
"tags": [
"artist"
],
"summary": "List artist by ID",
"parameters": [
{
"type": "string",
"description": "Artist ID (UUID)",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/users/create": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Create a user",
"parameters": [
{
"description": "User payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.CreateUserRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/handlers.CreateUserResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/users/login": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Log in with email and password",
"parameters": [
{
"description": "Login payload",
"name": "payload",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handlers.LoginRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.LoginResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
},
"/users/{id}": {
"get": {
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "Get username by user ID",
"parameters": [
{
"type": "string",
"description": "User ID (UUID)",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/handlers.UsernameResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handlers.ErrorResponse"
}
}
}
}
}
},
"definitions": {
"handlers.CreateUserRequest": {
"type": "object",
"required": [
"password",
"user_mail",
"user_name"
],
"properties": {
"password": {
"type": "string",
"minLength": 12
},
"user_mail": {
"type": "string"
},
"user_name": {
"type": "string"
}
}
},
"handlers.CreateUserResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"handlers.ErrorResponse": {
"type": "object",
"properties": {
"error": {
"type": "string"
}
}
},
"handlers.LoginRequest": {
"type": "object",
"required": [
"password",
"user_mail"
],
"properties": {
"password": {
"type": "string"
},
"user_mail": {
"type": "string"
}
}
},
"handlers.LoginResponse": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"handlers.UsernameResponse": {
"type": "object",
"properties": {
"user_name": {
"type": "string"
}
}
}
}
}