25 releases
| new 0.1.275 | Feb 2, 2026 |
|---|---|
| 0.1.265 | Feb 2, 2026 |
| 0.1.233 | Jan 30, 2026 |
| 0.1.2 | Dec 31, 2025 |
#1453 in Rust patterns
29 downloads per month
Used in 8 crates
(6 directly)
135KB
3K
SLoC
rustapi-openapi
Lens: "The Documentarian"
Philosophy: "Your API speaks for itself."
Automated API specifications and Swagger UI integration for RustAPI.
ℹ️ Note: This crate is used internally by
rustapi-rsto provide the.docs()method on the server builder.
How It Works
- Reflection: RustAPI macros collect metadata about your routes (path, method, input types, output types) at compile time
- Schema Gen: Uses
utoipato generate JSON Schemas for your Rust structs - Spec Build: At runtime, assembles the full OpenAPI 3.0 JSON specification
- UI Serve: Embeds the Swagger UI assets and serves them at your specified path
Route Metadata Macros
RustAPI provides attribute macros for enriching OpenAPI documentation:
#[rustapi_rs::get("/users/{id}")]
#[rustapi_rs::tag("Users")]
#[rustapi_rs::summary("Get user by ID")]
#[rustapi_rs::description("Returns a single user by their unique identifier.")]
async fn get_user(Path(id): Path<i64>) -> Json<User> { ... }
Customization
Inject custom security schemes or info into the spec via the RustApi builder:
RustApi::new()
.api_name("My Enterprise API")
.api_version("2.1.0")
.docs("/swagger-ui")
.run("0.0.0.0:3000")
.await
Dependencies
~3.5–4.5MB
~99K SLoC