use axum::response::{Html, Json};
use serde_json::json;
// 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
pub async fn handle_openapi() -> Json {
let openapi_spec = json!({
"openapi": "3.0.0",
"info": {
"title": "Keep API",
"version": "1.0.0",
"description": "REST API for the Keep data storage system"
},
"servers": [
{
"url": "/",
"description": "Local server"
}
],
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer"
}
},
"schemas": {
"ItemInfo": {
"type": "object",
"properties": {
"id": {"type": "integer"},
"ts": {"type": "string", "format": "date-time"},
"size": {"type": "integer", "nullable": true},
"compression": {"type": "string"},
"tags": {"type": "array", "items": {"type": "string"}},
"metadata": {"type": "object"}
}
},
"StatusInfo": {
"type": "object",
"properties": {
"version": {"type": "string"},
"database_path": {"type": "string"},
"data_directory": {"type": "string"},
"compression_engines": {"type": "array", "items": {"type": "string"}},
"meta_plugins": {"type": "array", "items": {"type": "string"}}
}
}
}
},
"security": [{"bearerAuth": []}],
"paths": {}
});
Json(openapi_spec)
}
pub async fn handle_swagger_ui() -> Html<&'static str> {
let html = r#"
Keep API Documentation
"#;
Html(html)
}
pub fn add_routes(router: Router) -> Router {
router
// Documentation endpoints
.route("/openapi.json", get(docs::handle_openapi))
.route("/swagger/", get(docs::handle_swagger_ui))
}