vespera_macro 0.1.37

Procedural macros for Vespera - automatic route discovery and OpenAPI generation
Documentation

Vespera macro implementation crate.

This crate contains all the proc-macros for Vespera:

  • #[vespera::route(...)] - Mark a function as a route handler
  • #[derive(Schema)] - Register a type for OpenAPI schema generation
  • schema!(...) - Get OpenAPI schema at compile time
  • vespera!(...) - Generate Axum router with OpenAPI
  • export_app!(...) - Export router for merging

Architecture

┌─────────────────────────────────────────────────────────────────┐
│ Compile-time (vespera! macro)                                    │
├─────────────────────────────────────────────────────────────────┤
│ 1. Scan src/routes/ for .rs files              [collector]       │
│ 2. Parse #[route] attributes                   [args, route]     │
│ 3. Extract handler signatures                  [parser]          │
│ 4. Convert Rust types → JSON Schema            [parser/schema]   │
│ 5. Build OpenAPI document                      [openapi_gen]     │
│ 6. Write openapi.json to disk                  [vespera_impl]    │
│ 7. Generate Axum Router TokenStream            [router_codegen]  │
│ 8. Inject Swagger/ReDoc HTML routes           [router_codegen]  │
└─────────────────────────────────────────────────────────────────┘

# Module Organization

- `args` - Parse `#[route(...)]` attribute arguments
- `collector` - Filesystem scanning and route discovery
- `error` - Unified error handling
- `http` - HTTP method constants and validation
- `metadata` - Type definitions for collected metadata
- `method` - HTTP method token stream generation
- `openapi_generator` - OpenAPI spec assembly
- `parser` - Type extraction and schema generation
- `route` - Route information structures
- `route_impl` - Route attribute macro implementation
- `router_codegen` - Router and macro input parsing
- `schema_impl` - Schema derive macro implementation
- `schema_macro` - `schema_type!` macro implementation
- `vespera_impl` - Main macro orchestration