tsk-170: API documentation #178
+15
-1
@@ -7,6 +7,19 @@ pub mod request {
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
pub mod song_queue {
|
||||
#[derive(utoipa::ToSchema)]
|
||||
pub struct SongQueueRequest {
|
||||
/// Filename
|
||||
pub file: String,
|
||||
#[schema(rename = "type")]
|
||||
/// File type. Should be a file and not a value
|
||||
pub file_type: String,
|
||||
/// Raw data of the flac file
|
||||
pub value: Vec<u8>,
|
||||
}
|
||||
}
|
||||
|
||||
pub mod update_status {
|
||||
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Request {
|
||||
@@ -861,11 +874,12 @@ pub mod endpoint {
|
||||
|
||||
use crate::callers::song::song_queue;
|
||||
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/song/queue",
|
||||
request_body(
|
||||
content = Object,
|
||||
content = super::request::song_queue::SongQueueRequest,
|
||||
description = "Multipart form data for uploading song",
|
||||
content_type = "multipart/form-data"
|
||||
),
|
||||
|
||||
+12
-9
@@ -29,15 +29,6 @@ pub mod db {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(utoipa::OpenApi)]
|
||||
#[openapi(
|
||||
paths(crate::callers::song::endpoint::queue_song),
|
||||
components(schemas(crate::callers::song::response::Response)),
|
||||
tags(
|
||||
(name = "queue song", description = "Start process to upload song by queueing the song")
|
||||
)
|
||||
)]
|
||||
struct ApiDoc;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
@@ -57,6 +48,7 @@ async fn main() {
|
||||
pub mod init {
|
||||
use axum::routing::{delete, get, patch, post};
|
||||
use std::time::Duration;
|
||||
use utoipa::OpenApi;
|
||||
use tower_http::timeout::TimeoutLayer;
|
||||
|
||||
use axum::http::{
|
||||
@@ -64,6 +56,16 @@ pub mod init {
|
||||
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE},
|
||||
};
|
||||
|
||||
#[derive(utoipa::OpenApi)]
|
||||
#[openapi(
|
||||
paths(crate::callers::song::endpoint::queue_song),
|
||||
components(schemas(crate::callers::song::response::Response)),
|
||||
tags(
|
||||
(name = "queue song", description = "Start process to upload song by queueing the song")
|
||||
)
|
||||
)]
|
||||
struct ApiDoc;
|
||||
|
||||
pub async fn routes() -> axum::Router {
|
||||
axum::Router::new()
|
||||
.route(crate::ROOT, get(crate::root))
|
||||
@@ -221,6 +223,7 @@ pub mod init {
|
||||
|
||||
routes()
|
||||
.await
|
||||
.merge(utoipa_swagger_ui::SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
|
||||
.layer(axum::Extension(pool))
|
||||
.layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024))
|
||||
.layer(TimeoutLayer::new(Duration::from_secs(300)))
|
||||
|
||||
Reference in New Issue
Block a user