Vision: FastAPI-inspired REST framework for Rust with automatic OpenAPI, validation, and DI.
- Type-Driven Development - Types define validation, serialization, and documentation
- Minimal Boilerplate - Macros handle repetitive code
- Developer Experience First - Great errors, automatic docs, easy testing
- Rust-Idiomatic - Embrace Rust patterns, don't fight them
- Performance - Built on tokio/axum for production-grade speed
┌─────────────────────────────────────┐
│ User Application Code │
│ (Routes, Services, Models) │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ RustAPI Macros │
│ #[get], #[post], #[injectable] │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ RustAPI Core │
│ - DI Container │
│ - Validation Engine │
│ - OpenAPI Generator │
│ - Testing Utilities │
└─────────────────────────────────────┘
↓
┌─────────────────────────────────────┐
│ Axum + Tokio │
│ (HTTP Server Foundation) │
└─────────────────────────────────────┘
Procedural macros for route definitions:
#[get("/users/{id}")]
async fn get_user(
path: Path<String>,
db: Inject<Database>,
) -> Result<Json<User>> {
// Implementation
}Generates:
- Axum handler registration
- OpenAPI schema for this route
- Parameter validation
- Dependency injection setup
Simple, type-safe DI container:
#[injectable]
pub struct UserService {
db: Inject<Database>,
}
impl UserService {
pub async fn get_user(&self, id: &str) -> Result<User> {
// Implementation
}
}Features:
- Constructor injection
- Singleton and scoped lifetimes
- Trait-based services for testing
- Automatic Arc wrapping
Derive-based validation with great errors:
#[derive(Deserialize, Validate)]
struct CreateUser {
#[validate(email)]
email: String,
#[validate(length(min = 8, max = 50))]
password: String,
#[validate(range(min = 18, max = 120))]
age: u8,
}Returns:
- Structured validation errors
- HTTP 422 with field-level errors
- Automatic OpenAPI validation schema
Automatic OpenAPI 3.0 spec generation:
let app = App::new()
.register(get_user)
.register(create_user)
.openapi("/docs") // Swagger UI at /docs
.build();Generates:
- Complete OpenAPI 3.0 JSON/YAML
- Swagger UI integration
- ReDoc support
- Type-safe schemas from Rust types
Ergonomic app construction:
#[tokio::main]
async fn main() {
App::new()
.service::<Database>()
.service::<UserService>()
.route(get_user)
.route(create_user)
.middleware(cors())
.openapi("/docs")
.serve("0.0.0.0:3000")
.await
.unwrap();
}rust-api/
├── crates/
│ ├── rust-api/ # Main crate (DI, app, server, router, error)
│ └── rust-api-macros/ # Proc macros (#[get], #[post], etc.)
├── examples/
│ ├── hello_world.rs # Minimal example
│ ├── with_macros.rs # Full-featured example
│ └── basic-api/ # Complete app with DI
└── Cargo.toml # Workspace configuration
rust-apii/
├── crates/
│ ├── rust-api/ # Main facade crate
│ ├── rust-api-core/ # Core runtime (DI, app builder)
│ ├── rust-api-macros/ # Proc macros
│ ├── rust-api-validate/ # Validation system (planned)
│ └── rust-api-openapi/ # OpenAPI generation (planned)
├── examples/
│ ├── hello-world/
│ ├── todo-app/
│ └── microservices/
└── tests/
└── integration/
- Basic controller-service pattern
- Define macro API surface
- Build DI container
- Create app builder
- Route macros (#[get], #[post], etc.)
- Integration with axum
- Injectable macro (future)
- Validation derive macro (future)
- Validation engine
- Error handling & formatting
- HTTP error responses
- Testing utilities
- Schema generation from types
- Route documentation
- Swagger UI integration
- Export to JSON/YAML
- Comprehensive examples
- Documentation site
- Performance benchmarks
- Community feedback
-
Developer Experience
- Lines of code: 50% less than plain axum
- Time to first endpoint: < 5 minutes
- Learning curve: Familiar to FastAPI/NestJS devs
-
Performance
- Overhead: < 5% vs raw axum
- Compile time: Reasonable (< 30s for medium project)
- Runtime: Production-ready
-
Adoption
- Clear value proposition vs existing frameworks
- Good documentation
- Active examples and community
| Feature | rust-api | axum | actix-web | poem | rocket |
|---|---|---|---|---|---|
| Route Macros | ✅ | ❌ | ❌ | ❌ | ✅ |
| Built-in DI | ✅ | ❌ | ✅ | ❌ | ❌ |
| Auto OpenAPI | Planned | ❌ | ❌ | ✅ | ❌ |
| Validation | Planned | Manual | Manual | ✅ | ✅ |
| FastAPI-like DX | ✅ | ❌ | ❌ | ~ | ~ |
| Maturity | 🚧 | ✅ | ✅ | ~ | ✅ |
- ✅
Prototype DI container - ✅
Design macro syntax - ✅
Build minimal working example - ✅
Validate architecture with real use case - Improve route registration ergonomics (Inject extractor)
- Add validation system (rust-api-validate crate)
- Implement OpenAPI generation (rust-api-openapi crate)
- Iterate based on community feedback