You can control which files or modules the macro scans using the paths argument. The paths argument accepts a comma-separated string of file or directory paths.
Import from src folder (Default)
If you omit the paths argument, the macro automatically scans the src folder.
Import from a specific module or directory
Specify a directory to scan all methods and structs within it:
#[utoipauto(paths = "./src/rest")]
Import from specific files
Provide a comma-separated list of specific .rs files:
#[utoipauto(paths = "./src/rest/test_controller.rs,./src/rest/test2_controller.rs ")]
Usage in Workspaces
When working in a workspace, you must include the crate name in the path. To specify that paths belong to another crate, use the from keyword:
- Standard workspace path:
#[utoipauto(paths = "./utoipauto/src")] - Cross-crate path:
#[utoipauto(paths = "./utoipauto/src from utoipauto")] - Sub-folder with crate mapping:
#[utoipauto(paths = "(./src/lib/rest from crate::rest)")]
#[utoipauto(paths = "./src/rest/test_controller.rs,./src/rest/test2_controller.rs ")]
#[derive(OpenApi)]
#[openapi(
paths(
crate::rest::other_controller::get_users,
),
components(
schemas(TestDTO)
),
tags(
(name = "todo", description = "Todo management endpoints.")
),
modifiers(&SecurityAddon)
)]
pub struct ApiDoc;