Generated: 2026-02-04 Branch: main
Vespera is a fully automated OpenAPI 3.1 engine for Axum - delivers FastAPI-like DX to Rust. Zero-config route discovery via compile-time macro scanning.
vespera/
├── crates/
│ ├── vespera/ # Public API - re-exports everything (+ chrono re-export)
│ ├── vespera_core/ # OpenAPI types, route/schema abstractions
│ └── vespera_macro/ # Proc-macros (main logic lives here)
└── examples/axum-example/ # Demo app with route patterns
| Task | Location | Notes |
|---|---|---|
| Add new macro feature | crates/vespera_macro/src/ |
Main macro in lib.rs |
| Modify OpenAPI output | crates/vespera_macro/src/openapi_generator.rs |
JSON generation |
| Add route parser feature | crates/vespera_macro/src/parser/ |
Type extraction logic |
| Change schema generation | crates/vespera_macro/src/parser/schema.rs |
Rust→JSON Schema |
| Modify route attribute | crates/vespera_macro/src/args.rs |
#[route] parsing |
| Modify schema_type! macro | crates/vespera_macro/src/schema_macro.rs |
Type derivation & SeaORM support |
| Add core types | crates/vespera_core/src/ |
OpenAPI spec types |
| Test new features | examples/axum-example/ |
Add route, run example |
| File | Lines | Role |
|---|---|---|
vespera_macro/src/lib.rs |
~1044 | vespera!, #[route], #[derive(Schema)] |
vespera_macro/src/schema_macro.rs |
~3000 | schema_type! macro, SeaORM relation handling |
vespera_macro/src/parser/schema.rs |
~1527 | Rust struct → JSON Schema conversion |
vespera_macro/src/parser/parameters.rs |
~845 | Extract path/query params from handlers |
vespera_macro/src/openapi_generator.rs |
~808 | OpenAPI doc assembly |
vespera_macro/src/collector.rs |
~707 | Filesystem route scanning |
Generate request/response types from existing structs with powerful transformations.
- Same-file Model reference:
schema_type!(Schema from Model, name = "UserSchema")- infers module path from file location - Cross-file reference:
schema_type!(Response from crate::models::user::Model, omit = ["password"]) - SeaORM integration: Automatic conversion of
HasOne,BelongsTo,HasManyrelations - Chrono conversion:
DateTimeWithTimeZone→vespera::chrono::DateTime<FixedOffset> - Circular reference handling: Automatic detection and inline field generation
| Parameter | Description |
|---|---|
pick |
Include only specified fields |
omit |
Exclude specified fields |
rename |
Rename fields: [("old", "new")] |
add |
Add new fields (disables auto From) |
clone |
Control Clone derive (default: true) |
partial |
Make fields optional for PATCH |
name |
Custom OpenAPI schema name |
rename_all |
Serde rename strategy |
ignore |
Skip Schema derive |
When using simple Model path (no crate:: prefix):
find_struct_from_path()callsfind_struct_by_name_in_all_files()- Uses
schema_namehint to disambiguate (e.g., "UserSchema" → prefersuser.rs) file_path_to_module_path()infers module path from file location- This enables
super::resolution in relation types
- Rust 2024 edition across all crates
- Workspace dependencies: Internal crates use
{ workspace = true } - Version sync: All crates at 0.1.19
- Test frameworks:
rstestfor unit tests,instafor snapshots - No
build.rs: All code gen via proc-macros at compile time
- NEVER add
build.rs- macro handles compile-time generation - NEVER manually register routes -
vespera!macro discovers them - NEVER write OpenAPI JSON by hand - generated from code
- Route functions MUST be
pub async fn
User writes: vespera!() macro at compile-time:
┌──────────────┐ ┌────────────────────────────────────────┐
│ src/routes/ │ ──── │ 1. Scan filesystem for .rs files │
│ users.rs │ │ 2. Parse #[route] attributes │
│ posts.rs │ │ 3. Extract handler signatures │
└──────────────┘ │ 4. Generate Axum Router code │
│ 5. Build OpenAPI spec │
│ 6. Write openapi.json (optional) │
│ 7. Inject Swagger/ReDoc routes │
└────────────────────────────────────────┘
# Development
cargo build # Build all crates
cargo test --workspace # Run all tests
cargo test -p vespera_macro # Test macros only
# Run example
cd examples/axum-example
cargo run # Starts server on :3000
# Visit http://localhost:3000/docs for Swagger UI
# Check generated OpenAPI
cat examples/axum-example/openapi.json- Macro performs filesystem I/O at compile time - may affect IDE performance
- OpenAPI files are regenerated on every build when
openapi = "..."specified CARGO_MANIFEST_DIRenv var used to locatesrc/routes/folder- Generic types in schemas require
#[derive(Schema)]on all type params