Crate rovo

Crate rovo 

Source
Expand description

§Rovo

A lightweight macro-based framework for generating OpenAPI documentation from doc comments in Axum handlers.

Rovo provides a declarative way to document your API endpoints using special annotations in doc comments, automatically generating OpenAPI specifications without manual schema definitions.

§Quick Start

use rovo::{Router, rovo, routing::get, schemars::JsonSchema, aide::axum::IntoApiResponse};
use rovo::aide::openapi::OpenApi;
use rovo::{extract::Path, response::Json};
use serde::Serialize;

#[derive(Serialize, JsonSchema)]
struct User { id: u32, name: String }

/// Get user by ID
///
/// # Responses
///
/// 200: Json<User> - User found successfully
/// 404: () - User not found
///
/// # Metadata
///
/// @tag users
#[rovo]
async fn get_user(Path(id): Path<u32>) -> impl IntoApiResponse {
    Json(User { id, name: "Alice".to_string() })
}

let mut api = OpenApi::default();
api.info.title = "My API".to_string();

let app = Router::new()
    .route("/users/{id}", get(get_user))
    .with_oas(api);

§Documentation Format

Rovo uses Rust-style markdown sections in doc comments:

§Responses Section

Document HTTP response codes and their types:

/// # Responses
///
/// 200: Json<User> - User found successfully
/// 404: () - User not found

§Examples Section

Provide response examples with valid Rust expressions:

/// # Examples
///
/// 200: User { id: 1, name: "Alice".into() }
/// 404: ()

§Metadata Section

Add API metadata with annotations:

/// # Metadata
///
/// @tag users
/// @security bearer_auth
/// @id getUserById
/// @hidden

Available metadata annotations:

  • @tag <name> - Group endpoints by tags
  • @security <scheme> - Specify security requirements
  • @id <operation_id> - Set custom operation ID
  • @hidden - Hide endpoint from documentation

Special directives:

  • @rovo-ignore - Stop processing annotations after this point

Re-exports§

pub use aide;
pub use schemars;
pub use ::axum::http;

Modules§

axum
Re-exports from aide’s axum integration for convenience.
extract
Re-export of axum’s extract module for request data extraction.
response
Re-export of axum’s response module for building HTTP responses.
routing
Drop-in replacement routing functions that work with #[rovo] decorated handlers.

Structs§

ApiMethodRouter
Wrapper around ApiMethodRouter that provides method chaining for documented handlers.
Router
A drop-in replacement for axum::Router that adds OpenAPI documentation support.

Traits§

IntoApiMethodRouter
Trait for handlers that carry their own documentation.

Attribute Macros§

rovo
Macro that generates OpenAPI documentation from doc comments.