Trading card city builder game?

refactor docs

eldridge.cam 0b4c75c3 bf4d3c5e

verified
+28 -29
+18 -29
packages/cartography/src/app.rs
··· 2 2 use crate::bus::Bus; 3 3 use axum::Router; 4 4 use kameo::actor::Spawn as _; 5 - use utoipa::OpenApi as _; 6 5 7 6 #[derive(utoipa::OpenApi)] 8 7 #[openapi( 9 - paths( 10 - operations::get_banner, 11 - operations::list_banners, 12 - operations::pull_banner, 8 + paths( 9 + operations::get_banner, 10 + operations::list_banners, 11 + operations::pull_banner, 13 12 14 - operations::list_card_types, 13 + operations::list_card_types, 15 14 16 - operations::list_fields, 17 - ), 18 - components( 19 - schemas( 20 - crate::dto::AccountIdOrMe 21 - ) 22 - ), 23 - tags( 24 - (name = "Global", description = "Publicly available global data about the Cartography game."), 25 - (name = "Player", description = "Player specific data; typically requires authorization."), 26 - (name = "Game", description = "Actions with effects on gameplay."), 27 - ), 28 - )] 15 + operations::list_fields, 16 + ), 17 + components( 18 + schemas( 19 + crate::dto::AccountIdOrMe 20 + ) 21 + ), 22 + tags( 23 + (name = "Global", description = "Publicly available global data about the Cartography game."), 24 + (name = "Player", description = "Player specific data; typically requires authorization."), 25 + (name = "Game", description = "Actions with effects on gameplay."), 26 + ), 27 + )] 29 28 pub struct ApiDoc; 30 29 31 30 pub struct Config { ··· 51 50 52 51 pub fn into_router(self) -> Router { 53 52 let bus = Bus::spawn(()); 54 - 55 - // let scalar_config = serde_json::json!({ 56 - // "url": "/api/openapi.json", 57 - // "agent": scalar_api_reference::config::AgentOptions::disabled() 58 - // }); 59 53 60 54 axum::Router::new() 61 55 .route( ··· 79 73 axum::routing::get(operations::list_fields), 80 74 ) 81 75 .route("/play/ws", axum::routing::any(ws::v1)) 82 - .route( 83 - "/api/openapi.json", 84 - axum::routing::get(axum::response::Json(ApiDoc::openapi())), 85 - ) 86 - // .merge(scalar_api_reference::axum::router("/docs", &scalar_config)) // TODO: waiting on scalar_api_reference to re-publish 87 76 .layer(axum::middleware::from_fn(middleware::authorization::trust)) 88 77 .layer(axum::Extension(bus)) 89 78 .layer(axum::Extension(self.pool))
+10
packages/cartography/src/main.rs
··· 43 43 .parse() 44 44 .expect("PORT must be a valid u16"); 45 45 46 + // let scalar_config = serde_json::json!({ 47 + // "url": "/api/openapi.json", 48 + // "agent": scalar_api_reference::config::AgentOptions::disabled() 49 + // }); 50 + 46 51 let app = app::new() 47 52 .await? 53 + // .merge(scalar_api_reference::axum::router("/docs", &scalar_config)) // TODO: waiting on scalar_api_reference to re-publish 54 + .route( 55 + "/api/openapi.json", 56 + axum::routing::get(axum::response::Json(app::ApiDoc::openapi())), 57 + ) 48 58 .layer(tower_http::trace::TraceLayer::new_for_http()); 49 59 50 60 let listener = tokio::net::TcpListener::bind((host, port)).await?;