OpenAPI documentation for Axum using doc comments and macros.
Built on aide, Rovo provides a declarative approach to API documentation through special annotations in doc comments.
Features
- Drop-in replacement for
axum::Router - Doc-comment driven documentation
- Compile-time validation of annotations
- Method chaining support (
.post(),.patch(),.delete()) - Built-in Swagger/Redoc/Scalar UI integration
- Type-safe response definitions
- Minimal runtime overhead
- Editor Integration:
- VSCode - See VSCODE.md for Visual Studio Code extension with auto-installation, completions, and syntax highlighting
- Neovim LSP - See NEOVIM.md for editor support with completions, hover docs, and more
- JetBrains IDEs - See JETBRAINS.md for RustRover, IntelliJ IDEA, and CLion support
Quick Start
use ;
use ;
use ;
use Serialize;
/// Get user information.
///
/// Returns the current user's profile information.
///
/// @tag users
/// @response 200 Json<User> User profile retrieved successfully.
async
async
Installation
[]
= { = "0.1.8", = ["swagger"] }
= "0.8"
= { = "1.0", = ["derive"] }
= { = "1", = ["full"] }
Note: Rovo re-exports
aideandschemars, so you don't need to add them as separate dependencies. Access them viarovo::aideandrovo::schemars.
For detailed API documentation, see docs.rs/rovo.
Feature Flags
Choose one or more documentation UIs (none enabled by default):
swagger- Swagger UIredoc- Redoc UIscalar- Scalar UI
Annotations
@response <code> <type> <description>
Document response status codes:
/// @response 200 Json<User> User found successfully
/// @response 404 () User not found
/// @response 500 Json<ErrorResponse> Internal server error
@example <code> <expression>
Provide example responses:
/// @response 200 Json<User> User information
/// @example 200 User { id: 1, name: "Alice".into(), email: "alice@example.com".into() }
@tag <tag_name>
Group operations by tags (can be used multiple times):
/// @tag users
/// @tag authentication
@security <scheme_name>
Specify security requirements (can be used multiple times):
/// @security bearer_auth
Security schemes must be defined in your OpenAPI spec. See Tips for details.
@id <operation_id>
Set custom operation ID (defaults to function name):
/// @id getUserById
@hidden
Hide an operation from documentation:
/// @hidden
#[deprecated]
Mark endpoints as deprecated using Rust's built-in attribute:
async
@rovo-ignore
Stop processing annotations after this point:
/// Get user information.
///
/// @tag users
/// @response 200 Json<User> User found successfully
/// @rovo-ignore
/// Additional documentation here won't be processed.
/// You can write @anything without causing errors.
async
Router API
Basic Usage
use Router;
let app = new
.route
.with_state;
Method Chaining
use ;
new
.route
.route
Nesting Routes
new
.nest
Documentation UIs
new
.route
.with_oas
.with_swagger
.with_redoc
.with_scalar
.with_state
Use custom OAS route:
new
.route
.with_oas_route
.with_swagger
.with_state
OpenAPI Formats
Rovo automatically serves your OpenAPI specification in multiple formats:
- JSON -
/api.json(default) - YAML -
/api.yamlor/api.yml
All formats are automatically available when you use .with_oas() or .with_oas_route().
Examples
See examples/todo_api.rs for a complete CRUD API.
Run with:
Migration from Axum
Replace imports and add documentation:
// Before
use ;
async
// After
use ;
use IntoApiResponse;
/// Handler description
///
/// @tag category
/// @response 200 Json<Data> Success
async
Add OpenAPI setup in main():
use OpenApi;
let mut api = default;
api.info.title = "My API".to_string;
let app = new
.route
.with_oas
.with_swagger
.with_state;
Tips
Path Parameters
Use structs with JsonSchema:
use JsonSchema;
use Deserialize;
use Uuid;
async
Security Schemes
Define in OpenAPI object:
use ;
api.components.get_or_insert_default
.security_schemes
.insert;
Reference in handlers:
/// @security bearer_auth
async
Troubleshooting
Handler doesn't implement required traits
Add the #[rovo] macro:
async
Type mismatch with .with_state()
Add explicit type annotation:
let router: = new
.route
.with_state;
Comparison with aide
| Feature | aide | rovo |
|---|---|---|
| Documentation | Separate _docs function |
Doc comments |
| Routing | api_route() |
Native axum syntax |
| Method chaining | Custom | Standard axum |
| Lines per endpoint | ~15-20 | ~5-10 |
Development
This project uses just for common development tasks.
Quick Start
# List all available commands
# Run all checks (format, clippy, tests)
# Fix formatting and clippy issues
# Run tests
# Check for outdated dependencies
# Check for unused dependencies
# Check for security vulnerabilities
Pre-commit Hooks
Uses prek for git hooks:
Available Commands
just test- Run all testsjust lint- Run clippy lintsjust fmt- Format codejust check- Run all checks (fmt, clippy, test)just fix- Run all checks and fixesjust build- Build the projectjust example- Run the todo_api examplejust outdated- Check for outdated dependenciesjust unused-deps- Check for unused dependenciesjust audit- Check for security vulnerabilitiesjust docs- Build and open documentationjust pre-release- Run all pre-release checks
See just --list for all available commands.
Contributing
Contributions are welcome. Please submit a Pull Request.
License
MIT