34 lines
922 B
Rust
34 lines
922 B
Rust
|
|
pub async fn handle_swagger_ui() -> Html<&'static str> {
|
|
let html = r#"<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Keep API Documentation</title>
|
|
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3.52.5/swagger-ui.css" />
|
|
</head>
|
|
<body>
|
|
<div id="swagger-ui"></div>
|
|
<script src="https://unpkg.com/swagger-ui-dist@3.52.5/swagger-ui-bundle.js"></script>
|
|
<script>
|
|
SwaggerUIBundle({
|
|
url: '/openapi.json',
|
|
dom_id: '#swagger-ui',
|
|
presets: [
|
|
SwaggerUIBundle.presets.apis,
|
|
SwaggerUIBundle.presets.standalone
|
|
]
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>"#;
|
|
|
|
Html(html)
|
|
}
|
|
|
|
pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
|
|
router
|
|
// Documentation endpoints
|
|
.route("/openapi.json", get(handle_openapi))
|
|
.route("/swagger", get(handle_swagger_ui))
|
|
}
|