tsk-170: Swagger openapi docs are now up
Well, at least one
This commit is contained in:
+15
-1
@@ -7,6 +7,19 @@ pub mod request {
|
|||||||
pub message: String,
|
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 {
|
pub mod update_status {
|
||||||
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
#[derive(Default, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
@@ -861,11 +874,12 @@ pub mod endpoint {
|
|||||||
|
|
||||||
use crate::callers::song::song_queue;
|
use crate::callers::song::song_queue;
|
||||||
|
|
||||||
|
|
||||||
#[utoipa::path(
|
#[utoipa::path(
|
||||||
post,
|
post,
|
||||||
path = "/song/queue",
|
path = "/song/queue",
|
||||||
request_body(
|
request_body(
|
||||||
content = Object,
|
content = super::request::song_queue::SongQueueRequest,
|
||||||
description = "Multipart form data for uploading song",
|
description = "Multipart form data for uploading song",
|
||||||
content_type = "multipart/form-data"
|
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]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@@ -57,6 +48,7 @@ async fn main() {
|
|||||||
pub mod init {
|
pub mod init {
|
||||||
use axum::routing::{delete, get, patch, post};
|
use axum::routing::{delete, get, patch, post};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use utoipa::OpenApi;
|
||||||
use tower_http::timeout::TimeoutLayer;
|
use tower_http::timeout::TimeoutLayer;
|
||||||
|
|
||||||
use axum::http::{
|
use axum::http::{
|
||||||
@@ -64,6 +56,16 @@ pub mod init {
|
|||||||
header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE},
|
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 {
|
pub async fn routes() -> axum::Router {
|
||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
.route(crate::ROOT, get(crate::root))
|
.route(crate::ROOT, get(crate::root))
|
||||||
@@ -221,6 +223,7 @@ pub mod init {
|
|||||||
|
|
||||||
routes()
|
routes()
|
||||||
.await
|
.await
|
||||||
|
.merge(utoipa_swagger_ui::SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
|
||||||
.layer(axum::Extension(pool))
|
.layer(axum::Extension(pool))
|
||||||
.layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024))
|
.layer(axum::extract::DefaultBodyLimit::max(1024 * 1024 * 1024))
|
||||||
.layer(TimeoutLayer::new(Duration::from_secs(300)))
|
.layer(TimeoutLayer::new(Duration::from_secs(300)))
|
||||||
|
|||||||
Reference in New Issue
Block a user