fix: remove redundant OpenAPI endpoint and fix Swagger UI path reference
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -1,41 +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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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>
|
||||||
@@ -49,7 +11,7 @@ pub async fn handle_swagger_ui() -> Html<&'static str> {
|
|||||||
<script src="https://unpkg.com/swagger-ui-dist@3.52.5/swagger-ui-bundle.js"></script>
|
<script src="https://unpkg.com/swagger-ui-dist@3.52.5/swagger-ui-bundle.js"></script>
|
||||||
<script>
|
<script>
|
||||||
SwaggerUIBundle({
|
SwaggerUIBundle({
|
||||||
url: '/openapi.json',
|
url: '/api-docs/openapi.json',
|
||||||
dom_id: '#swagger-ui',
|
dom_id: '#swagger-ui',
|
||||||
presets: [
|
presets: [
|
||||||
SwaggerUIBundle.presets.apis,
|
SwaggerUIBundle.presets.apis,
|
||||||
@@ -66,6 +28,5 @@ pub async fn handle_swagger_ui() -> Html<&'static str> {
|
|||||||
pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
|
pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
|
||||||
router
|
router
|
||||||
// Documentation endpoints
|
// Documentation endpoints
|
||||||
.route("/openapi.json", get(handle_openapi))
|
|
||||||
.route("/swagger", get(handle_swagger_ui))
|
.route("/swagger", get(handle_swagger_ui))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user