Skip to main content

handler_docs

Macro handler_docs 

Source
macro_rules! handler_docs {
    ($($doc:expr),* $(,)?) => { ... };
}
Expand description

Collect handler doc constants into a slice for [Server::with_openapi_docs].

Pass the SCREAMING_SNAKE_CASE_DOC constants generated by #[documented_handler].

§Example

use typeway_macros::documented_handler;
use typeway_server::handler_docs;

/// List users.
#[documented_handler(tags = "users")]
async fn list_users() -> Json<Vec<User>> { /* ... */ }

/// Get one user.
#[documented_handler(tags = "users")]
async fn get_user(id: Path<u32>) -> Json<User> { /* ... */ }

Server::<API>::new(handlers)
    .with_openapi_docs("My API", "1.0", &handler_docs![
        LIST_USERS_DOC,
        GET_USER_DOC,
    ])
    .serve(addr)
    .await?;