From 68c5514a443692666550aa3f3f7745500cf8b7f6 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 12 Aug 2025 15:01:40 -0300 Subject: [PATCH] refactor: use api::add_routes() and docs::add_routes() to register server routes Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/modes/server.rs | 5 ++++- src/modes/server/docs.rs | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/modes/server.rs b/src/modes/server.rs index aaa9a4a..44266d5 100644 --- a/src/modes/server.rs +++ b/src/modes/server.rs @@ -1,6 +1,5 @@ use anyhow::Result; use axum::{ - routing::get, Router, }; use clap::Command; @@ -68,6 +67,10 @@ async fn run_server( ) .with_state(state); + // Add API and documentation routes + let app = api::add_routes(app); + let app = docs::add_routes(app); + let addr: SocketAddr = if config.address.starts_with('/') || config.address.starts_with("./") { // Unix socket - not supported by axum directly, fall back to TCP warn!("Unix sockets not yet implemented, falling back to TCP on 127.0.0.1:8080"); diff --git a/src/modes/server/docs.rs b/src/modes/server/docs.rs index cdc04e9..21abc85 100644 --- a/src/modes/server/docs.rs +++ b/src/modes/server/docs.rs @@ -1,10 +1,14 @@ use axum::response::{Html, Json}; use serde_json::json; +use serde_json::Value; -// Remove the invalid imports - we'll access the OpenAPI specs differently -// For now, we'll create a simplified version that doesn't depend on those functions +use crate::modes::server::common::AppState; +use axum::{ + routing::get, + Router, +}; -pub async fn handle_openapi() -> Json { +pub async fn handle_openapi() -> Json { let openapi_spec = json!({ "openapi": "3.0.0", "info": { @@ -85,6 +89,6 @@ pub async fn handle_swagger_ui() -> Html<&'static str> { pub fn add_routes(router: Router) -> Router { router // Documentation endpoints - .route("/openapi.json", get(docs::handle_openapi)) - .route("/swagger/", get(docs::handle_swagger_ui)) + .route("/openapi.json", get(handle_openapi)) + .route("/swagger/", get(handle_swagger_ui)) }