From bd5aeaf591f48cf95e745eb29322aaffefb5374a Mon Sep 17 00:00:00 2001 From: Antoine Gersant <antoine.gersant@lesforges.org> Date: Wed, 15 Jan 2025 20:01:52 -0800 Subject: [PATCH] API consistency improvements --- src/server/axum/api.rs | 16 ++++++++-------- src/server/test/protocol.rs | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/server/axum/api.rs b/src/server/axum/api.rs index 42939ef..420a702 100644 --- a/src/server/axum/api.rs +++ b/src/server/axum/api.rs @@ -633,7 +633,7 @@ async fn get_artists( #[utoipa::path( get, - path = "/artists/{artist}", + path = "/artist/{artist}", tag = "Collection", security( ("auth_token" = []), @@ -654,15 +654,15 @@ async fn get_artist( #[utoipa::path( get, - path = "/artists/{artists}/albums/{album}", + path = "/album/{album}/by/{artists}", tag = "Collection", security( ("auth_token" = []), ("auth_query_param" = []), ), params( - ("artists",), ("album",), + ("artists",), ), responses( (status = 200, body = dto::Album), @@ -671,7 +671,7 @@ async fn get_artist( async fn get_album( _auth: Auth, State(index_manager): State<index::Manager>, - Path((artists, name)): Path<(String, String)>, + Path((name, artists)): Path<(String, String)>, ) -> Result<Json<dto::Album>, APIError> { let artists = artists .split(API_ARRAY_SEPARATOR) @@ -832,7 +832,7 @@ async fn get_genres( #[utoipa::path( get, - path = "/genres/{genre}", + path = "/genre/{genre}", tag = "Collection", security( ("auth_token" = []), @@ -853,7 +853,7 @@ async fn get_genre( #[utoipa::path( get, - path = "/genres/{genre}/albums", + path = "/genre/{genre}/albums", tag = "Collection", security( ("auth_token" = []), @@ -881,7 +881,7 @@ async fn get_genre_albums( #[utoipa::path( get, - path = "/genres/{genre}/artists", + path = "/genre/{genre}/artists", tag = "Collection", security( ("auth_token" = []), @@ -909,7 +909,7 @@ async fn get_genre_artists( #[utoipa::path( get, - path = "/genres/{genre}/songs", + path = "/genre/{genre}/songs", tag = "Collection", security( ("auth_token" = []), diff --git a/src/server/test/protocol.rs b/src/server/test/protocol.rs index 2c615df..e895a1c 100644 --- a/src/server/test/protocol.rs +++ b/src/server/test/protocol.rs @@ -164,7 +164,7 @@ pub fn genres<VERSION: ProtocolVersion>() -> Request<()> { } pub fn genre<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { - let endpoint = format!("/api/genres/{}", url_encode(genre)); + let endpoint = format!("/api/genre/{}", url_encode(genre)); Request::builder() .header("Accept-Version", VERSION::header_value()) .method(Method::GET) @@ -174,7 +174,7 @@ pub fn genre<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { } pub fn genre_albums<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { - let endpoint = format!("/api/genres/{}/albums", url_encode(genre)); + let endpoint = format!("/api/genre/{}/albums", url_encode(genre)); Request::builder() .header("Accept-Version", VERSION::header_value()) .method(Method::GET) @@ -184,7 +184,7 @@ pub fn genre_albums<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { } pub fn genre_artists<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { - let endpoint = format!("/api/genres/{}/artists", url_encode(genre)); + let endpoint = format!("/api/genre/{}/artists", url_encode(genre)); Request::builder() .header("Accept-Version", VERSION::header_value()) .method(Method::GET) @@ -194,7 +194,7 @@ pub fn genre_artists<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { } pub fn genre_songs<VERSION: ProtocolVersion>(genre: &str) -> Request<()> { - let endpoint = format!("/api/genres/{}/songs", url_encode(genre)); + let endpoint = format!("/api/genre/{}/songs", url_encode(genre)); Request::builder() .header("Accept-Version", VERSION::header_value()) .method(Method::GET) @@ -207,7 +207,7 @@ pub fn random<VERSION: ProtocolVersion>() -> Request<()> { Request::builder() .header("Accept-Version", VERSION::header_value()) .method(Method::GET) - .uri("/api/random") + .uri("/api/albums/random") .body(()) .unwrap() } @@ -216,7 +216,7 @@ pub fn recent<VERSION: ProtocolVersion>() -> Request<()> { Request::builder() .header("Accept-Version", VERSION::header_value()) .method(Method::GET) - .uri("/api/recent") + .uri("/api/albums/recent") .body(()) .unwrap() }