From cbed412945aaa4ecb26c3ebbbc40639473f2316d Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Fri, 17 Oct 2025 12:16:39 +0200 Subject: [PATCH] ajoute une vue dans l'application web sur l'openAPI --- Cargo.lock | 1 + PMOMusic/Cargo.toml | 1 + PMOMusic/src/main.rs | 9 +- pmoapp/webapp/src/App.vue | 3 +- pmoapp/webapp/src/components/APIExplorer.vue | 802 +++++++++++++++++++ pmoapp/webapp/src/router/index.ts | 2 + 6 files changed, 813 insertions(+), 5 deletions(-) create mode 100644 pmoapp/webapp/src/components/APIExplorer.vue diff --git a/Cargo.lock b/Cargo.lock index 867c2113..d84e44cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,7 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", + "utoipa", ] [[package]] diff --git a/PMOMusic/Cargo.toml b/PMOMusic/Cargo.toml index 52f44081..41ce7dae 100644 --- a/PMOMusic/Cargo.toml +++ b/PMOMusic/Cargo.toml @@ -18,3 +18,4 @@ tracing = "0.1.41" tracing-subscriber = "0.3.20" axum = "0.8.4" serde_json = "1.0.145" +utoipa = "5.4" diff --git a/PMOMusic/src/main.rs b/PMOMusic/src/main.rs index a149ed5c..cb70e794 100644 --- a/PMOMusic/src/main.rs +++ b/PMOMusic/src/main.rs @@ -1,10 +1,11 @@ use pmoapp::{WebAppExt, Webapp}; use pmocovers::CoverCacheExt; use pmomediarenderer::MEDIA_RENDERER; -use pmomediaserver::{MEDIA_SERVER, sources::SourcesExt, MediaServerExt, sources_api_router}; +use pmomediaserver::{MEDIA_SERVER, sources::SourcesExt, MediaServerExt, sources_api_router, sources_api::SourcesApiDoc}; use pmoserver::ServerBuilder; use pmoupnp::{UpnpServer, ssdp::SsdpServer, upnp_api::UpnpApiExt}; use tracing::info; +use utoipa::OpenApi; #[tokio::main] async fn main() { @@ -36,9 +37,9 @@ async fn main() { // Enregistrer l'API d'introspection UPnP server.register_upnp_api().await; - // Enregistrer l'API de gestion des sources musicales - info!("📡 Registering Sources API..."); - server.add_router("/api", sources_api_router()).await; + // Enregistrer l'API de gestion des sources musicales avec OpenAPI + info!("📡 Registering Sources API with OpenAPI documentation..."); + server.add_openapi(sources_api_router(), SourcesApiDoc::openapi(), "sources").await; info!("📡 Registering MediaRenderer..."); let renderer_instance = server diff --git a/pmoapp/webapp/src/App.vue b/pmoapp/webapp/src/App.vue index aa2cd002..11d1fb8d 100644 --- a/pmoapp/webapp/src/App.vue +++ b/pmoapp/webapp/src/App.vue @@ -13,6 +13,7 @@ 📋 Logs 🎵 UPnP Explorer 🎨 Cover Cache + 🌐 API Explorer @@ -30,7 +31,7 @@ const showDebugMenu = ref(false) const route = useRoute() const isDebugRoute = computed(() => { - return ['/logs', '/upnp', '/covers-cache'].includes(route.path) + return ['/logs', '/upnp', '/covers-cache', '/api-explorer'].includes(route.path) }) diff --git a/pmoapp/webapp/src/components/APIExplorer.vue b/pmoapp/webapp/src/components/APIExplorer.vue new file mode 100644 index 00000000..dc48973b --- /dev/null +++ b/pmoapp/webapp/src/components/APIExplorer.vue @@ -0,0 +1,802 @@ + + + + + diff --git a/pmoapp/webapp/src/router/index.ts b/pmoapp/webapp/src/router/index.ts index 44965899..2e6c3793 100644 --- a/pmoapp/webapp/src/router/index.ts +++ b/pmoapp/webapp/src/router/index.ts @@ -3,12 +3,14 @@ import HelloWorld from "../components/HelloWorld.vue"; import LogView from "../components/LogView.vue"; import CoverCacheManager from "../components/CoverCacheManager.vue"; import UpnpExplorer from "../components/UpnpExplorer.vue"; +import APIExplorer from "../components/APIExplorer.vue"; const routes = [ { path: "/", name: "home", component: HelloWorld }, { path: "/logs", name: "logs", component: LogView }, { path: "/covers-cache", name: "covers-cache", component: CoverCacheManager }, { path: "/upnp", name: "upnp", component: UpnpExplorer }, + { path: "/api-explorer", name: "api-explorer", component: APIExplorer }, ]; const router = createRouter({