From bd072d8fb95de0aea546124f488d01f747113e09 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Tue, 14 Nov 2023 13:10:41 -0800 Subject: [PATCH] feat(ui): always display chat api endpoints in swagger doc (#784) --- crates/tabby/src/serve.rs | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/crates/tabby/src/serve.rs b/crates/tabby/src/serve.rs index 361714bada2b..32effb09e984 100644 --- a/crates/tabby/src/serve.rs +++ b/crates/tabby/src/serve.rs @@ -102,12 +102,9 @@ pub async fn main(config: &Config, args: &ServeArgs) { info!("Starting server, this might takes a few minutes..."); - let mut doc = ApiDoc::openapi(); - doc.override_doc(args); - let app = Router::new() .merge(api_router(args, config).await) - .merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", doc)); + .merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi())); let app = attach_webserver(app).await; @@ -217,21 +214,3 @@ fn start_heartbeat(args: &ServeArgs) { } }); } - -trait OpenApiOverride { - fn override_doc(&mut self, args: &ServeArgs); -} - -impl OpenApiOverride for utoipa::openapi::OpenApi { - fn override_doc(&mut self, args: &ServeArgs) { - if args.chat_model.is_none() { - self.paths.paths.remove("/v1beta/chat/completions"); - - if let Some(components) = self.components.as_mut() { - components.schemas.remove("ChatCompletionRequest"); - components.schemas.remove("ChatCompletionChunk"); - components.schemas.remove("Message"); - } - } - } -}