pub mod some_endpoint {
use ruma_api::ruma_api;
use ruma_events::{collections::all, tag::TagEvent, EventJson};
ruma_api! {
metadata {
description: "Does something.",
method: POST, name: "some_endpoint",
path: "/_matrix/some/endpoint/:baz",
rate_limited: false,
requires_authentication: false,
}
request {
pub foo: String,
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
#[ruma_api(query)]
pub bar: String,
#[ruma_api(path)]
pub baz: String,
}
response {
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
pub value: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub optional_flag: Option<bool>,
pub event: EventJson<TagEvent>,
pub list_of_events: Vec<EventJson<all::RoomEvent>>,
}
}
}
pub mod newtype_body_endpoint {
use ruma_api::ruma_api;
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct MyCustomType {
pub foo: String,
}
ruma_api! {
metadata {
description: "Does something.",
method: PUT,
name: "newtype_body_endpoint",
path: "/_matrix/some/newtype/body/endpoint",
rate_limited: false,
requires_authentication: false,
}
request {
#[ruma_api(body)]
pub list_of_custom_things: Vec<MyCustomType>,
}
response {
#[ruma_api(body)]
pub my_custom_thing: MyCustomType,
}
}
}
pub mod newtype_raw_body_endpoint {
use ruma_api::ruma_api;
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct MyCustomType {
pub foo: String,
}
ruma_api! {
metadata {
description: "Does something.",
method: PUT,
name: "newtype_body_endpoint",
path: "/_matrix/some/newtype/body/endpoint",
rate_limited: false,
requires_authentication: false,
}
request {
#[ruma_api(raw_body)]
pub file: Vec<u8>,
}
response {
#[ruma_api(raw_body)]
pub file: Vec<u8>,
}
}
}
pub mod query_map_endpoint {
use ruma_api::ruma_api;
ruma_api! {
metadata {
description: "Does something.",
method: GET,
name: "newtype_body_endpoint",
path: "/_matrix/some/query/map/endpoint",
rate_limited: false,
requires_authentication: false,
}
request {
#[ruma_api(query_map)]
pub fields: Vec<(String, String)>,
}
response {
}
}
}