summaryrefslogtreecommitdiff
path: root/src/api/artist.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/artist.rs')
-rw-r--r--src/api/artist.rs53
1 files changed, 51 insertions, 2 deletions
diff --git a/src/api/artist.rs b/src/api/artist.rs
index d36ccf4..1fdae37 100644
--- a/src/api/artist.rs
+++ b/src/api/artist.rs
@@ -5,14 +5,24 @@ use crate::extractors::auth_token::AuthenticationToken;
use crate::AppState;
use actix_web::{delete, get, post, put, web, HttpResponse};
use serde::Deserialize;
+use utoipa::IntoParams;
/* Possible arguments ( /artist?arg=value ) */
-#[derive(Deserialize)]
-struct ArtistQueryOptions {
+#[derive(Deserialize, IntoParams)]
+pub struct ArtistQueryOptions {
id: Option<String>,
name: Option<String>,
}
+#[utoipa::path(
+ params(ArtistQueryOptions),
+ context_path = "/api",
+ description = "Gets a list of the current artists and applies filters based on the url parameters recieved. It only accepts one parameter at a time.",
+ responses(
+ (status = 200, description = "Return a list of artists", body = Vec<Artist>),
+ (status = 400, description = "Errors found, unfulfilled request"),
+ ),
+)]
#[get("/artist")]
pub async fn get_artist(
app_state: web::Data<AppState>,
@@ -48,6 +58,19 @@ pub async fn get_artist(
}
}
+#[utoipa::path(
+ request_body = ArtistPost,
+ context_path = "/api",
+ description = "Creates a new artist with the specified name.",
+ responses(
+ (status = 200, description = "Create new artist", body = Response),
+ (status = 400, description = "Errors found, unfulfilled request"),
+ (status = 401, description = "Authentication failed"),
+ ),
+ security(
+ {"bearer_auth" = []}
+ ),
+)]
#[post("/artist")]
pub async fn post_artist(
app_state: web::Data<AppState>,
@@ -63,6 +86,19 @@ pub async fn post_artist(
)
}
+#[utoipa::path(
+ request_body = ArtistPut,
+ context_path = "/api",
+ description = "Edits the name of the specified artist.",
+ responses(
+ (status = 200, description = "Edit artist name", body = Response),
+ (status = 400, description = "Errors found or artist not found"),
+ (status = 401, description = "Authentication failed"),
+ ),
+ security(
+ {"bearer_auth" = []}
+ ),
+)]
#[put("/artist")]
pub async fn put_artist(
app_state: web::Data<AppState>,
@@ -78,6 +114,19 @@ pub async fn put_artist(
)
}
+#[utoipa::path(
+ request_body = Delete,
+ context_path = "/api",
+ description = "Deletes the specified artist.",
+ responses(
+ (status = 200, description = "Delete existing artist", body = Response),
+ (status = 400, description = "Errors found or artist not found"),
+ (status = 401, description = "Authentication failed"),
+ ),
+ security(
+ {"bearer_auth" = []}
+ ),
+)]
#[delete("/artist")]
pub async fn delete_artist(
app_state: web::Data<AppState>,