api: Make metadata path field optional
This commit is contained in:
parent
4ccf79cb67
commit
457726017b
@ -47,7 +47,6 @@ impl Api {
|
|||||||
let description = &metadata.description;
|
let description = &metadata.description;
|
||||||
let method = &metadata.method;
|
let method = &metadata.method;
|
||||||
let name = &metadata.name;
|
let name = &metadata.name;
|
||||||
let path = &metadata.path;
|
|
||||||
let unstable_path = util::map_option_literal(&metadata.unstable_path);
|
let unstable_path = util::map_option_literal(&metadata.unstable_path);
|
||||||
let r0_path = util::map_option_literal(&metadata.r0_path);
|
let r0_path = util::map_option_literal(&metadata.r0_path);
|
||||||
let stable_path = util::map_option_literal(&metadata.stable_path);
|
let stable_path = util::map_option_literal(&metadata.stable_path);
|
||||||
@ -75,6 +74,7 @@ impl Api {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
let path = util::map_option_literal(&metadata.path);
|
||||||
let added = util::map_option_literal(&metadata.added);
|
let added = util::map_option_literal(&metadata.added);
|
||||||
let deprecated = util::map_option_literal(&metadata.deprecated);
|
let deprecated = util::map_option_literal(&metadata.deprecated);
|
||||||
let removed = util::map_option_literal(&metadata.removed);
|
let removed = util::map_option_literal(&metadata.removed);
|
||||||
|
@ -46,7 +46,7 @@ pub struct Metadata {
|
|||||||
pub name: LitStr,
|
pub name: LitStr,
|
||||||
|
|
||||||
/// The path field. (deprecated)
|
/// The path field. (deprecated)
|
||||||
pub path: EndpointPath,
|
pub path: Option<EndpointPath>,
|
||||||
|
|
||||||
/// The unstable path field.
|
/// The unstable path field.
|
||||||
pub unstable_path: Option<EndpointPath>,
|
pub unstable_path: Option<EndpointPath>,
|
||||||
@ -179,7 +179,7 @@ impl Parse for Metadata {
|
|||||||
description: description.ok_or_else(|| missing_field("description"))?,
|
description: description.ok_or_else(|| missing_field("description"))?,
|
||||||
method: method.ok_or_else(|| missing_field("method"))?,
|
method: method.ok_or_else(|| missing_field("method"))?,
|
||||||
name: name.ok_or_else(|| missing_field("name"))?,
|
name: name.ok_or_else(|| missing_field("name"))?,
|
||||||
path: path.ok_or_else(|| missing_field("path"))?,
|
path,
|
||||||
unstable_path,
|
unstable_path,
|
||||||
r0_path,
|
r0_path,
|
||||||
stable_path,
|
stable_path,
|
||||||
|
@ -22,7 +22,7 @@ pub struct Metadata {
|
|||||||
pub name: &'static str,
|
pub name: &'static str,
|
||||||
|
|
||||||
/// (DEPRECATED)
|
/// (DEPRECATED)
|
||||||
pub path: &'static str,
|
pub path: Option<&'static str>,
|
||||||
|
|
||||||
/// The unstable path of this endpoint's URL, often `None`, used for developmental
|
/// The unstable path of this endpoint's URL, often `None`, used for developmental
|
||||||
/// purposes.
|
/// purposes.
|
||||||
|
@ -28,7 +28,7 @@ const METADATA: Metadata = Metadata {
|
|||||||
description: "Add an alias to a room.",
|
description: "Add an alias to a room.",
|
||||||
method: Method::PUT,
|
method: Method::PUT,
|
||||||
name: "create_alias",
|
name: "create_alias",
|
||||||
path: "/_matrix/client/r0/directory/room/:room_alias",
|
path: Some("/_matrix/client/r0/directory/room/:room_alias"),
|
||||||
unstable_path: None,
|
unstable_path: None,
|
||||||
r0_path: None,
|
r0_path: None,
|
||||||
stable_path: None,
|
stable_path: None,
|
||||||
@ -52,7 +52,7 @@ impl OutgoingRequest for Request {
|
|||||||
// FIXME: properly integrate
|
// FIXME: properly integrate
|
||||||
_considering_versions: &'_ [MatrixVersion],
|
_considering_versions: &'_ [MatrixVersion],
|
||||||
) -> Result<http::Request<T>, IntoHttpError> {
|
) -> Result<http::Request<T>, IntoHttpError> {
|
||||||
let url = (base_url.to_owned() + METADATA.path)
|
let url = (base_url.to_owned() + METADATA.path.unwrap())
|
||||||
.replace(":room_alias", &self.room_alias.to_string());
|
.replace(":room_alias", &self.room_alias.to_string());
|
||||||
|
|
||||||
let request_body = RequestBody { room_id: self.room_id };
|
let request_body = RequestBody { room_id: self.room_id };
|
||||||
|
@ -11,7 +11,7 @@ const BASE: Metadata = Metadata {
|
|||||||
description: "",
|
description: "",
|
||||||
method: Method::GET,
|
method: Method::GET,
|
||||||
name: "test_endpoint",
|
name: "test_endpoint",
|
||||||
path: "/depr/path",
|
path: Some("/depr/path"),
|
||||||
unstable_path: Some("/unstable/path"),
|
unstable_path: Some("/unstable/path"),
|
||||||
r0_path: Some("/r0/path"),
|
r0_path: Some("/r0/path"),
|
||||||
stable_path: Some("/stable/path"),
|
stable_path: Some("/stable/path"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user