fix: restore openapi.json endpoint and update swagger UI path reference
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
use crate::compression_engine;
|
use crate::compression_engine;
|
||||||
use crate::compression_engine::COMPRESSION_PROGRAMS;
|
use crate::compression_engine::COMPRESSION_PROGRAMS;
|
||||||
@@ -8,20 +9,20 @@ use crate::compression_engine::program::CompressionEngineProgram;
|
|||||||
use crate::meta_plugin::MetaPluginType;
|
use crate::meta_plugin::MetaPluginType;
|
||||||
use crate::meta_plugin;
|
use crate::meta_plugin;
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
pub struct StatusInfo {
|
pub struct StatusInfo {
|
||||||
pub paths: PathInfo,
|
pub paths: PathInfo,
|
||||||
pub compression: Vec<CompressionInfo>,
|
pub compression: Vec<CompressionInfo>,
|
||||||
pub meta_plugins: Vec<MetaPluginInfo>,
|
pub meta_plugins: Vec<MetaPluginInfo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
pub struct PathInfo {
|
pub struct PathInfo {
|
||||||
pub data: String,
|
pub data: String,
|
||||||
pub database: String,
|
pub database: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
pub struct CompressionInfo {
|
pub struct CompressionInfo {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub compression_type: String,
|
pub compression_type: String,
|
||||||
@@ -32,7 +33,7 @@ pub struct CompressionInfo {
|
|||||||
pub decompress: String,
|
pub decompress: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize, ToSchema)]
|
||||||
pub struct MetaPluginInfo {
|
pub struct MetaPluginInfo {
|
||||||
pub meta_name: String,
|
pub meta_name: String,
|
||||||
pub found: bool,
|
pub found: bool,
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ use utoipa_swagger_ui::SwaggerUi;
|
|||||||
components(
|
components(
|
||||||
schemas(
|
schemas(
|
||||||
crate::modes::server::common::ApiResponse<crate::modes::server::api::status::StatusInfo>,
|
crate::modes::server::common::ApiResponse<crate::modes::server::api::status::StatusInfo>,
|
||||||
crate::modes::server::common::ApiResponse<Vec<crate::modes::server::api::item::ItemInfo>>,
|
crate::modes::server::common::ApiResponse<Vec<crate::modes::server::common::ItemInfo>>,
|
||||||
crate::modes::server::common::ApiResponse<crate::modes::server::api::item::ItemInfo>,
|
crate::modes::server::common::ApiResponse<crate::modes::server::common::ItemInfo>,
|
||||||
crate::modes::server::common::ApiResponse<HashMap<String, String>>,
|
crate::modes::server::common::ApiResponse<std::collections::HashMap<std::string::String>>,
|
||||||
crate::modes::server::common::ApiResponse<()>,
|
crate::modes::server::common::ApiResponse<()>,
|
||||||
crate::modes::server::api::status::StatusInfo,
|
crate::modes::server::api::status::StatusInfo,
|
||||||
crate::modes::server::api::item::ItemInfo,
|
crate::modes::server::common::ItemInfo,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
tags(
|
tags(
|
||||||
|
|||||||
@@ -1,64 +1,3 @@
|
|||||||
use axum::response::{Html, Json};
|
|
||||||
use serde_json::json;
|
|
||||||
use serde_json::Value;
|
|
||||||
|
|
||||||
use crate::modes::server::common::AppState;
|
|
||||||
use axum::{
|
|
||||||
routing::get,
|
|
||||||
Router,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub async fn handle_openapi() -> Json<Value> {
|
|
||||||
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> {
|
pub async fn handle_swagger_ui() -> Html<&'static str> {
|
||||||
let html = r#"<!DOCTYPE html>
|
let html = r#"<!DOCTYPE html>
|
||||||
|
|||||||
Reference in New Issue
Block a user