-
-
Notifications
You must be signed in to change notification settings - Fork 2
chore(quick-wins): reduce dependency surface and align native OpenAPI… #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,7 +4,7 @@ use std::collections::HashMap; | |||||||||||||||||
| use std::future::Future; | ||||||||||||||||||
| use std::pin::Pin; | ||||||||||||||||||
| use std::sync::{Arc, RwLock}; | ||||||||||||||||||
| use std::time::{Duration, Instant}; | ||||||||||||||||||
| use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; | ||||||||||||||||||
|
|
||||||||||||||||||
| /// Configuration for the Status Page | ||||||||||||||||||
| #[derive(Clone, Debug)] | ||||||||||||||||||
|
|
@@ -97,8 +97,7 @@ impl StatusMonitor { | |||||||||||||||||
| } | ||||||||||||||||||
| entry.total_latency_ms += duration.as_millis(); | ||||||||||||||||||
|
|
||||||||||||||||||
| let now = chrono::Utc::now().to_rfc3339(); | ||||||||||||||||||
| entry.last_access = Some(now); | ||||||||||||||||||
| entry.last_access = Some(format_unix_timestamp()); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| pub fn get_uptime(&self) -> Duration { | ||||||||||||||||||
|
|
@@ -274,3 +273,10 @@ fn format_duration(d: Duration) -> String { | |||||||||||||||||
| format!("{}m {}s", minutes, secs) | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| fn format_unix_timestamp() -> String { | ||||||||||||||||||
| let now = SystemTime::now() | ||||||||||||||||||
| .duration_since(UNIX_EPOCH) | ||||||||||||||||||
| .unwrap_or_else(|_| Duration::from_secs(0)); | ||||||||||||||||||
| format!("unix:{}", now.as_secs()) | ||||||||||||||||||
|
Comment on lines
+278
to
+281
|
||||||||||||||||||
| let now = SystemTime::now() | |
| .duration_since(UNIX_EPOCH) | |
| .unwrap_or_else(|_| Duration::from_secs(0)); | |
| format!("unix:{}", now.as_secs()) | |
| match SystemTime::now().duration_since(UNIX_EPOCH) { | |
| Ok(duration) => format!("unix:{}", duration.as_secs()), | |
| Err(_) => "-".to_string(), | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,7 +10,7 @@ Automated API specifications and Swagger UI integration for RustAPI. | |||||
| ## How It Works | ||||||
|
|
||||||
| 1. **Reflection**: RustAPI macros collect metadata about your routes (path, method, input types, output types) at compile time | ||||||
| 2. **Schema Gen**: Uses `utoipa` to generate JSON Schemas for your Rust structs | ||||||
| 2. **Schema Gen**: Uses RustAPI's native schema engine to generate OpenAPI-compatible JSON Schemas | ||||||
| 3. **Spec Build**: At runtime, assembles the full OpenAPI 3.0 JSON specification | ||||||
|
||||||
| 3. **Spec Build**: At runtime, assembles the full OpenAPI 3.0 JSON specification | |
| 3. **Spec Build**: At runtime, assembles the full OpenAPI 3.1 JSON specification |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -145,7 +145,7 @@ RustApi::auto().run("0.0.0.0:8080").await | |||||
| **Automatic OpenAPI/Swagger generation.** | ||||||
|
|
||||||
| Features: | ||||||
| - Wraps `utoipa` internally (not exposed) | ||||||
| - Native OpenAPI model and schema registry (no external OpenAPI generator dependency) | ||||||
| - Auto-generates OpenAPI 3.0 spec | ||||||
|
||||||
| - Auto-generates OpenAPI 3.0 spec | |
| - Auto-generates OpenAPI 3.1 spec (3.0 available as legacy) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,10 +1,10 @@ | ||||||
| # Native OpenAPI Design for RustAPI | ||||||
|
|
||||||
| ## Overview | ||||||
| RustAPI is moving to a native OpenAPI 3.1 generator to reduce external dependencies (specifically `utoipa`) and ensure deterministic, high-quality spec generation. This document outlines the architecture for the "Native OpenAPI" implementation. | ||||||
| RustAPI uses a native OpenAPI 3.1 generator to reduce external dependencies and ensure deterministic, high-quality spec generation. This document outlines the architecture for the "Native OpenAPI" implementation. | ||||||
|
|
||||||
| ## Goals | ||||||
| - **Zero Heavy Dependencies**: Remove `utoipa`. Use only `serde` + `serde_json` + standard library. | ||||||
| - **Zero Heavy Dependencies**: Use only `serde` + `serde_json` + standard library. | ||||||
|
||||||
| - **Zero Heavy Dependencies**: Use only `serde` + `serde_json` + standard library. | |
| - **No Heavy OpenAPI Dependencies**: No external OpenAPI/schema generators or large meta-frameworks; the core schema engine and OpenAPI model types rely primarily on `serde` + `serde_json` + standard library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last_accessis now set to aunix:<secs>string, which makes the "Last Access" column much less human-readable than the previous RFC3339 timestamp. Consider keeping a readable format (e.g., ISO-8601) or changing the UI to show a relative age ("5s ago") while still avoiding thechronodependency.