#[errors]Expand description
Error responses macro for OpenAPI documentation
Declares possible error responses for a handler endpoint. These are automatically added to the OpenAPI specification.
§Syntax
ⓘ
#[rustapi::errors(404 = "User not found", 403 = "Access denied", 409 = "Email already exists")]§Example
ⓘ
#[rustapi::get("/users/{id}")]
#[rustapi::errors(404 = "User not found", 403 = "Forbidden")]
async fn get_user(Path(id): Path<Uuid>) -> Result<Json<User>> {
// ...
}This generates OpenAPI responses for 404 and 403 status codes, each referencing the standard ErrorSchema component.