#[param]Expand description
Path parameter schema macro for OpenAPI documentation
Use this to specify the OpenAPI schema type for a path parameter when
the auto-inferred type is incorrect. This is particularly useful for
UUID parameters that might be named id.
§Supported schema types
"uuid"- String with UUID format"integer"or"int"- Integer with int64 format"string"- Plain string"boolean"or"bool"- Boolean"number"- Number (float)
§Example
ⓘ
use uuid::Uuid;
#[rustapi::get("/users/{id}")]
#[rustapi::param(id, schema = "uuid")]
async fn get_user(Path(id): Path<Uuid>) -> Json<User> {
// ...
}
// Alternative syntax:
#[rustapi::get("/posts/{post_id}")]
#[rustapi::param(post_id = "uuid")]
async fn get_post(Path(post_id): Path<Uuid>) -> Json<Post> {
// ...
}