From aed09886946f8817a478981cae1b6b8b5d4e7b7d Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Sun, 13 Feb 2022 11:30:58 +0100 Subject: [PATCH] api: Remove support for path metadata field --- crates/ruma-api-macros/src/api.rs | 2 - crates/ruma-api-macros/src/api/metadata.rs | 70 ++++++++++++++----- crates/ruma-api-macros/src/version.rs | 4 +- crates/ruma-api/src/lib.rs | 6 +- crates/ruma-api/src/metadata.rs | 3 - crates/ruma-api/tests/conversions.rs | 12 ++-- crates/ruma-api/tests/header_override.rs | 4 +- crates/ruma-api/tests/manual_endpoint_impl.rs | 29 +++++--- crates/ruma-api/tests/no_fields.rs | 8 +-- crates/ruma-api/tests/optional_headers.rs | 2 +- crates/ruma-api/tests/path_arg_ordering.rs | 2 +- crates/ruma-api/tests/ruma_api_lifetime.rs | 10 +-- crates/ruma-api/tests/ruma_api_macros.rs | 8 +-- crates/ruma-api/tests/select_path.rs | 1 - .../ruma-api/tests/ui/01-api-sanity-check.rs | 1 - crates/ruma-api/tests/ui/02-invalid-path.rs | 4 +- .../ruma-api/tests/ui/02-invalid-path.stderr | 12 ++-- crates/ruma-api/tests/ui/03-move-value.rs | 6 +- crates/ruma-api/tests/ui/04-attributes.rs | 2 +- crates/ruma-api/tests/ui/05-request-only.rs | 3 +- crates/ruma-api/tests/ui/06-response-only.rs | 2 +- .../tests/ui/07-error-type-attribute.rs | 2 +- .../tests/ui/08-deprecated-without-added.rs | 2 +- .../tests/ui/09-removed-without-deprecated.rs | 2 +- 24 files changed, 116 insertions(+), 81 deletions(-) diff --git a/crates/ruma-api-macros/src/api.rs b/crates/ruma-api-macros/src/api.rs index a10829e1..29b60cc6 100644 --- a/crates/ruma-api-macros/src/api.rs +++ b/crates/ruma-api-macros/src/api.rs @@ -74,7 +74,6 @@ impl Api { } }) .collect(); - let path = util::map_option_literal(&metadata.path); let added = util::map_option_literal(&metadata.added); let deprecated = util::map_option_literal(&metadata.deprecated); let removed = util::map_option_literal(&metadata.removed); @@ -94,7 +93,6 @@ impl Api { description: #description, method: #http::Method::#method, name: #name, - path: #path, unstable_path: #unstable_path, r0_path: #r0_path, stable_path: #stable_path, diff --git a/crates/ruma-api-macros/src/api/metadata.rs b/crates/ruma-api-macros/src/api/metadata.rs index 92579430..0fc90dd6 100644 --- a/crates/ruma-api-macros/src/api/metadata.rs +++ b/crates/ruma-api-macros/src/api/metadata.rs @@ -14,7 +14,6 @@ mod kw { syn::custom_keyword!(description); syn::custom_keyword!(method); syn::custom_keyword!(name); - syn::custom_keyword!(path); syn::custom_keyword!(unstable_path); syn::custom_keyword!(r0_path); syn::custom_keyword!(stable_path); @@ -45,9 +44,6 @@ pub struct Metadata { /// The name field. pub name: LitStr, - /// The path field. (deprecated) - pub path: Option, - /// The unstable path field. pub unstable_path: Option, @@ -101,7 +97,6 @@ impl Parse for Metadata { let mut description = None; let mut method = None; let mut name = None; - let mut path = None; let mut unstable_path = None; let mut r0_path = None; let mut stable_path = None; @@ -116,7 +111,6 @@ impl Parse for Metadata { FieldValue::Description(d) => set_field(&mut description, d)?, FieldValue::Method(m) => set_field(&mut method, m)?, FieldValue::Name(n) => set_field(&mut name, n)?, - FieldValue::Path(p) => set_field(&mut path, p)?, FieldValue::UnstablePath(p) => set_field(&mut unstable_path, p)?, FieldValue::R0Path(p) => set_field(&mut r0_path, p)?, FieldValue::StablePath(p) => set_field(&mut stable_path, p)?, @@ -135,6 +129,17 @@ impl Parse for Metadata { let missing_field = |name| syn::Error::new_spanned(metadata_kw, format!("missing field `{}`", name)); + let stable_or_r0 = stable_path.as_ref().or(r0_path.as_ref()); + + if let Some(path) = stable_or_r0 { + if added.is_none() { + return Err(syn::Error::new_spanned( + path, + "stable path was defined, while `added` version was not defined", + )); + } + } + if let Some(deprecated) = &deprecated { if added.is_none() { return Err(syn::Error::new_spanned( @@ -160,26 +165,53 @@ impl Parse for Metadata { } if let Some(added) = &added { - if stable_path.is_none() { + if stable_or_r0.is_none() { return Err(syn::Error::new_spanned( added, - "added version is defined, but no stable path exists", + "added version is defined, but no stable or r0 path exists", + )); + } + } + + if let Some(r0) = &r0_path { + let added = added.as_ref().expect("we error if r0 or stable is defined without added"); + + if added.major.get() == 1 && added.minor > 0 { + return Err(syn::Error::new_spanned( + r0, + "r0 defined while added version is newer than v1.0", + )); + } + + if stable_path.is_none() { + return Err(syn::Error::new_spanned(r0, "r0 defined without stable path")); + } + + if !r0.value().contains("/r0/") { + return Err(syn::Error::new_spanned(r0, "r0 endpoint does not contain /r0/")); + } + } + + if let Some(stable) = &stable_path { + if stable.value().contains("/r0/") { + return Err(syn::Error::new_spanned( + stable, + "stable endpoint contains /r0/ (did you make a copy-paste error?)", )); } } if unstable_path.is_none() && r0_path.is_none() && stable_path.is_none() { - // TODO replace with error - // return Err(syn::Error::new_spanned(metadata_kw, "no path is defined")); - r0_path = path.clone(); - unstable_path = path.clone(); + return Err(syn::Error::new_spanned( + metadata_kw, + "need to define one of [r0_path, stable_path, unstable_path]", + )); } Ok(Self { description: description.ok_or_else(|| missing_field("description"))?, method: method.ok_or_else(|| missing_field("method"))?, name: name.ok_or_else(|| missing_field("name"))?, - path, unstable_path, r0_path, stable_path, @@ -204,7 +236,6 @@ enum Field { Description, Method, Name, - Path, UnstablePath, R0Path, StablePath, @@ -228,9 +259,6 @@ impl Parse for Field { } else if lookahead.peek(kw::name) { let _: kw::name = input.parse()?; Ok(Self::Name) - } else if lookahead.peek(kw::path) { - let _: kw::path = input.parse()?; - Ok(Self::Path) } else if lookahead.peek(kw::unstable_path) { let _: kw::unstable_path = input.parse()?; Ok(Self::UnstablePath) @@ -265,7 +293,6 @@ enum FieldValue { Description(LitStr), Method(Ident), Name(LitStr), - Path(EndpointPath), UnstablePath(EndpointPath), R0Path(EndpointPath), StablePath(EndpointPath), @@ -294,7 +321,6 @@ impl Parse for FieldValue { Field::Description => Self::Description(input.parse()?), Field::Method => Self::Method(input.parse()?), Field::Name => Self::Name(input.parse()?), - Field::Path => Self::Path(input.parse()?), Field::UnstablePath => Self::UnstablePath(input.parse()?), Field::R0Path => Self::R0Path(input.parse()?), Field::StablePath => Self::StablePath(input.parse()?), @@ -310,6 +336,12 @@ impl Parse for FieldValue { #[derive(Clone)] pub struct EndpointPath(LitStr); +impl EndpointPath { + pub fn value(&self) -> String { + self.0.value() + } +} + impl Parse for EndpointPath { fn parse(input: ParseStream<'_>) -> syn::Result { let path: LitStr = input.parse()?; diff --git a/crates/ruma-api-macros/src/version.rs b/crates/ruma-api-macros/src/version.rs index dafc90ed..e72e6cc7 100644 --- a/crates/ruma-api-macros/src/version.rs +++ b/crates/ruma-api-macros/src/version.rs @@ -6,8 +6,8 @@ use syn::{parse::Parse, Error, LitFloat}; #[derive(Clone)] pub struct MatrixVersionLiteral { - major: NonZeroU8, - minor: u8, + pub(crate) major: NonZeroU8, + pub(crate) minor: u8, } impl Parse for MatrixVersionLiteral { diff --git a/crates/ruma-api/src/lib.rs b/crates/ruma-api/src/lib.rs index 8396f5ba..58695433 100644 --- a/crates/ruma-api/src/lib.rs +++ b/crates/ruma-api/src/lib.rs @@ -135,9 +135,10 @@ use ruma_identifiers::UserId; /// description: "Does something.", /// method: POST, /// name: "some_endpoint", -/// path: "/_matrix/some/endpoint/:baz", +/// stable_path: "/_matrix/some/endpoint/:baz", /// rate_limited: false, /// authentication: None, +/// added: 1.1, /// } /// /// request: { @@ -176,9 +177,10 @@ use ruma_identifiers::UserId; /// description: "Does something.", /// method: PUT, /// name: "newtype_body_endpoint", -/// path: "/_matrix/some/newtype/body/endpoint", +/// stable_path: "/_matrix/some/newtype/body/endpoint", /// rate_limited: false, /// authentication: None, +/// added: 1.1, /// } /// /// request: { diff --git a/crates/ruma-api/src/metadata.rs b/crates/ruma-api/src/metadata.rs index fc34980d..0b621626 100644 --- a/crates/ruma-api/src/metadata.rs +++ b/crates/ruma-api/src/metadata.rs @@ -21,9 +21,6 @@ pub struct Metadata { /// A unique identifier for this endpoint. pub name: &'static str, - /// (DEPRECATED) - pub path: Option<&'static str>, - /// The unstable path of this endpoint's URL, often `None`, used for developmental /// purposes. pub unstable_path: Option<&'static str>, diff --git a/crates/ruma-api/tests/conversions.rs b/crates/ruma-api/tests/conversions.rs index fde06630..1505b71b 100644 --- a/crates/ruma-api/tests/conversions.rs +++ b/crates/ruma-api/tests/conversions.rs @@ -11,7 +11,7 @@ ruma_api! { description: "Does something.", method: POST, name: "my_endpoint", - path: "/_matrix/foo/:bar/:user", + unstable_path: "/_matrix/foo/:bar/:user", rate_limited: false, authentication: None, } @@ -55,7 +55,7 @@ fn request_serde() { .try_into_http_request::>( "https://homeserver.tld", SendAccessToken::None, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ) .unwrap(); let req2 = Request::try_from_http_request(http_req, &["barVal", "@bazme:ruma.io"]).unwrap(); @@ -82,7 +82,7 @@ fn invalid_uri_should_not_panic() { let result = req.try_into_http_request::>( "invalid uri", SendAccessToken::None, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ); assert!(result.is_err()); } @@ -104,7 +104,7 @@ fn request_with_user_id_serde() { "https://homeserver.tld", SendAccessToken::None, user_id, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ) .unwrap(); @@ -126,7 +126,7 @@ mod without_query { description: "Does something without query.", method: POST, name: "my_endpoint", - path: "/_matrix/foo/:bar/:user", + unstable_path: "/_matrix/foo/:bar/:user", rate_limited: false, authentication: None, } @@ -165,7 +165,7 @@ mod without_query { "https://homeserver.tld", SendAccessToken::None, user_id, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ) .unwrap(); diff --git a/crates/ruma-api/tests/header_override.rs b/crates/ruma-api/tests/header_override.rs index b089b5b4..fb83070a 100644 --- a/crates/ruma-api/tests/header_override.rs +++ b/crates/ruma-api/tests/header_override.rs @@ -10,7 +10,7 @@ ruma_api! { description: "Does something.", method: GET, name: "no_fields", - path: "/_matrix/my/endpoint", + unstable_path: "/_matrix/my/endpoint", rate_limited: false, authentication: None, } @@ -53,7 +53,7 @@ fn request_content_type_override() { .try_into_http_request::>( "https://homeserver.tld", SendAccessToken::None, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ) .unwrap(); diff --git a/crates/ruma-api/tests/manual_endpoint_impl.rs b/crates/ruma-api/tests/manual_endpoint_impl.rs index 490b6007..753adf25 100644 --- a/crates/ruma-api/tests/manual_endpoint_impl.rs +++ b/crates/ruma-api/tests/manual_endpoint_impl.rs @@ -28,15 +28,14 @@ const METADATA: Metadata = Metadata { description: "Add an alias to a room.", method: Method::PUT, name: "create_alias", - path: Some("/_matrix/client/r0/directory/room/:room_alias"), - unstable_path: None, - r0_path: None, - stable_path: None, + unstable_path: Some("/_matrix/client/unstable/directory/room/:room_alias"), + r0_path: Some("/_matrix/client/r0/directory/room/:room_alias"), + stable_path: Some("/_matrix/client/v3/directory/room/:room_alias"), rate_limited: false, authentication: AuthScheme::None, - added: None, - deprecated: None, - removed: None, + added: Some(MatrixVersion::V1_0), + deprecated: Some(MatrixVersion::V1_1), + removed: Some(MatrixVersion::V1_2), }; impl OutgoingRequest for Request { @@ -49,11 +48,19 @@ impl OutgoingRequest for Request { self, base_url: &str, _access_token: SendAccessToken<'_>, - // FIXME: properly integrate - _considering_versions: &'_ [MatrixVersion], + considering_versions: &'_ [MatrixVersion], ) -> Result, IntoHttpError> { - let url = (base_url.to_owned() + METADATA.path.unwrap()) - .replace(":room_alias", &self.room_alias.to_string()); + let url = format!( + "{}{}", + base_url, + ruma_api::select_path( + considering_versions, + &METADATA, + Some(format_args!("/_matrix/client/unstable/directory/room/{}", self.room_alias)), + Some(format_args!("/_matrix/client/r0/directory/room/{}", self.room_alias)), + Some(format_args!("/_matrix/client/v3/directory/room/{}", self.room_alias)), + )? + ); let request_body = RequestBody { room_id: self.room_id }; diff --git a/crates/ruma-api/tests/no_fields.rs b/crates/ruma-api/tests/no_fields.rs index ba931724..b49db326 100644 --- a/crates/ruma-api/tests/no_fields.rs +++ b/crates/ruma-api/tests/no_fields.rs @@ -6,7 +6,7 @@ mod get { description: "Does something.", method: GET, name: "no_fields", - path: "/_matrix/my/endpoint", + unstable_path: "/_matrix/my/endpoint", rate_limited: false, authentication: None, } @@ -22,7 +22,7 @@ mod post { description: "Does something.", method: POST, name: "no_fields", - path: "/_matrix/my/endpoint", + unstable_path: "/_matrix/my/endpoint", rate_limited: false, authentication: None, } @@ -39,7 +39,7 @@ fn empty_post_request_http_repr() { .try_into_http_request::>( "https://homeserver.tld", SendAccessToken::None, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ) .unwrap(); @@ -53,7 +53,7 @@ fn empty_get_request_http_repr() { .try_into_http_request::>( "https://homeserver.tld", SendAccessToken::None, - &[MatrixVersion::V1_0], + &[MatrixVersion::V1_1], ) .unwrap(); diff --git a/crates/ruma-api/tests/optional_headers.rs b/crates/ruma-api/tests/optional_headers.rs index 84ca68d1..8301fcf3 100644 --- a/crates/ruma-api/tests/optional_headers.rs +++ b/crates/ruma-api/tests/optional_headers.rs @@ -5,7 +5,7 @@ ruma_api! { description: "Does something.", method: GET, name: "no_fields", - path: "/_matrix/my/endpoint", + unstable_path: "/_matrix/my/endpoint", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/path_arg_ordering.rs b/crates/ruma-api/tests/path_arg_ordering.rs index dc6c817b..4bb433b4 100644 --- a/crates/ruma-api/tests/path_arg_ordering.rs +++ b/crates/ruma-api/tests/path_arg_ordering.rs @@ -5,7 +5,7 @@ ruma_api! { description: "Does something.", method: GET, name: "some_path_args", - path: "/_matrix/:one/a/:two/b/:three/c", + unstable_path: "/_matrix/:one/a/:two/b/:three/c", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ruma_api_lifetime.rs b/crates/ruma-api/tests/ruma_api_lifetime.rs index 38790607..1b483f93 100644 --- a/crates/ruma-api/tests/ruma_api_lifetime.rs +++ b/crates/ruma-api/tests/ruma_api_lifetime.rs @@ -15,7 +15,7 @@ mod empty_response { description: "Add an alias to a room.", method: PUT, name: "create_alias", - path: "/_matrix/client/r0/directory/room/:room_alias", + unstable_path: "/_matrix/client/r0/directory/room/:room_alias", rate_limited: false, authentication: AccessToken, } @@ -42,7 +42,7 @@ mod nested_types { description: "Add an alias to a room.", method: PUT, name: "create_alias", - path: "/_matrix/client/r0/directory/room", + unstable_path: "/_matrix/client/r0/directory/room", rate_limited: false, authentication: AccessToken, } @@ -69,7 +69,7 @@ mod full_request_response { description: "Does something.", method: POST, name: "no_fields", - path: "/_matrix/my/endpoint/:thing", + unstable_path: "/_matrix/my/endpoint/:thing", rate_limited: false, authentication: None, } @@ -101,7 +101,7 @@ mod full_request_response_with_query_map { description: "Does something.", method: GET, name: "no_fields", - path: "/_matrix/my/endpoint/:thing", + unstable_path: "/_matrix/my/endpoint/:thing", rate_limited: false, authentication: None, } @@ -133,7 +133,7 @@ mod query_fields { description: "Get the list of rooms in this homeserver's public directory.", method: GET, name: "get_public_rooms", - path: "/_matrix/client/r0/publicRooms", + unstable_path: "/_matrix/client/r0/publicRooms", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ruma_api_macros.rs b/crates/ruma-api/tests/ruma_api_macros.rs index 7139ae5b..c7558d65 100644 --- a/crates/ruma-api/tests/ruma_api_macros.rs +++ b/crates/ruma-api/tests/ruma_api_macros.rs @@ -11,7 +11,7 @@ pub mod some_endpoint { description: "Does something.", method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", - path: "/_matrix/some/endpoint/:user", + unstable_path: "/_matrix/some/endpoint/:user", #[cfg(all())] rate_limited: true, @@ -76,7 +76,7 @@ pub mod newtype_body_endpoint { description: "Does something.", method: PUT, name: "newtype_body_endpoint", - path: "/_matrix/some/newtype/body/endpoint", + unstable_path: "/_matrix/some/newtype/body/endpoint", rate_limited: false, authentication: None, } @@ -106,7 +106,7 @@ pub mod raw_body_endpoint { description: "Does something.", method: PUT, name: "newtype_body_endpoint", - path: "/_matrix/some/newtype/body/endpoint", + unstable_path: "/_matrix/some/newtype/body/endpoint", rate_limited: false, authentication: None, } @@ -131,7 +131,7 @@ pub mod query_map_endpoint { description: "Does something.", method: GET, name: "newtype_body_endpoint", - path: "/_matrix/some/query/map/endpoint", + unstable_path: "/_matrix/some/query/map/endpoint", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/select_path.rs b/crates/ruma-api/tests/select_path.rs index 4b55ebe9..55b77c99 100644 --- a/crates/ruma-api/tests/select_path.rs +++ b/crates/ruma-api/tests/select_path.rs @@ -11,7 +11,6 @@ const BASE: Metadata = Metadata { description: "", method: Method::GET, name: "test_endpoint", - path: Some("/depr/path"), unstable_path: Some("/unstable/path"), r0_path: Some("/r0/path"), stable_path: Some("/stable/path"), diff --git a/crates/ruma-api/tests/ui/01-api-sanity-check.rs b/crates/ruma-api/tests/ui/01-api-sanity-check.rs index 625949bb..3ad0940d 100644 --- a/crates/ruma-api/tests/ui/01-api-sanity-check.rs +++ b/crates/ruma-api/tests/ui/01-api-sanity-check.rs @@ -7,7 +7,6 @@ ruma_api! { description: "Does something.", method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", - path: "/_matrix/some/endpoint/:baz", unstable_path: "/_matrix/some/msc1234/endpoint/:baz", r0_path: "/_matrix/some/r0/endpoint/:baz", stable_path: "/_matrix/some/v1/endpoint/:baz", diff --git a/crates/ruma-api/tests/ui/02-invalid-path.rs b/crates/ruma-api/tests/ui/02-invalid-path.rs index 2cde887b..2ef34817 100644 --- a/crates/ruma-api/tests/ui/02-invalid-path.rs +++ b/crates/ruma-api/tests/ui/02-invalid-path.rs @@ -5,7 +5,7 @@ ruma_api! { description: "This will fail.", method: GET, name: "invalid_path", - path: "µ/°/§/€", + unstable_path: "µ/°/§/€", rate_limited: false, authentication: None, } @@ -23,7 +23,7 @@ ruma_api! { description: "This will fail.", method: GET, name: "invalid_path", - path: "path/to/invalid space/endpoint", + unstable_path: "path/to/invalid space/endpoint", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ui/02-invalid-path.stderr b/crates/ruma-api/tests/ui/02-invalid-path.stderr index 44f623a3..9f76c9a8 100644 --- a/crates/ruma-api/tests/ui/02-invalid-path.stderr +++ b/crates/ruma-api/tests/ui/02-invalid-path.stderr @@ -1,11 +1,11 @@ error: path may only contain printable ASCII characters with no spaces - --> $DIR/02-invalid-path.rs:8:15 + --> tests/ui/02-invalid-path.rs:8:24 | -8 | path: "µ/°/§/€", - | ^^^^^^^^^ +8 | unstable_path: "µ/°/§/€", + | ^^^^^^^^^ error: path may only contain printable ASCII characters with no spaces - --> $DIR/02-invalid-path.rs:26:15 + --> tests/ui/02-invalid-path.rs:26:24 | -26 | path: "path/to/invalid space/endpoint", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +26 | unstable_path: "path/to/invalid space/endpoint", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/crates/ruma-api/tests/ui/03-move-value.rs b/crates/ruma-api/tests/ui/03-move-value.rs index da6a790e..ef747468 100644 --- a/crates/ruma-api/tests/ui/03-move-value.rs +++ b/crates/ruma-api/tests/ui/03-move-value.rs @@ -13,7 +13,7 @@ mod newtype_body { description: "Does something.", method: POST, name: "my_endpoint", - path: "/_matrix/foo/:bar/", + unstable_path: "/_matrix/foo/:bar/", rate_limited: false, authentication: None, } @@ -51,7 +51,7 @@ mod raw_body { description: "Does something.", method: POST, name: "my_endpoint", - path: "/_matrix/foo/:bar/", + unstable_path: "/_matrix/foo/:bar/", rate_limited: false, authentication: None, } @@ -92,7 +92,7 @@ mod plain { description: "Does something.", method: POST, name: "my_endpoint", - path: "/_matrix/foo/:bar/", + unstable_path: "/_matrix/foo/:bar/", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ui/04-attributes.rs b/crates/ruma-api/tests/ui/04-attributes.rs index 967f718e..136b04fb 100644 --- a/crates/ruma-api/tests/ui/04-attributes.rs +++ b/crates/ruma-api/tests/ui/04-attributes.rs @@ -5,7 +5,7 @@ ruma_api! { description: "Does something.", method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", - path: "/_matrix/some/endpoint/:baz", + unstable_path: "/_matrix/some/endpoint/:baz", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ui/05-request-only.rs b/crates/ruma-api/tests/ui/05-request-only.rs index 5263e9c8..f00cd42b 100644 --- a/crates/ruma-api/tests/ui/05-request-only.rs +++ b/crates/ruma-api/tests/ui/05-request-only.rs @@ -10,7 +10,7 @@ ruma_api! { description: "Does something.", method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", - path: "/_matrix/some/endpoint", + unstable_path: "/_matrix/some/endpoint/:foo", rate_limited: false, authentication: None, } @@ -18,6 +18,7 @@ ruma_api! { #[derive(PartialEq)] // Make sure attributes work request: { // With no attribute on the field, it will be put into the body of the request. + #[ruma_api(path)] pub foo: String, } } diff --git a/crates/ruma-api/tests/ui/06-response-only.rs b/crates/ruma-api/tests/ui/06-response-only.rs index 9745dac5..b9c69452 100644 --- a/crates/ruma-api/tests/ui/06-response-only.rs +++ b/crates/ruma-api/tests/ui/06-response-only.rs @@ -5,7 +5,7 @@ ruma_api! { description: "Does something.", method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", - path: "/_matrix/some/endpoint/:baz", + unstable_path: "/_matrix/some/endpoint/:baz", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ui/07-error-type-attribute.rs b/crates/ruma-api/tests/ui/07-error-type-attribute.rs index f14f7fc3..7159fad5 100644 --- a/crates/ruma-api/tests/ui/07-error-type-attribute.rs +++ b/crates/ruma-api/tests/ui/07-error-type-attribute.rs @@ -5,7 +5,7 @@ ruma_api! { description: "Does something.", method: POST, // An `http::Method` constant. No imports required. name: "some_endpoint", - path: "/_matrix/some/endpoint/:baz", + unstable_path: "/_matrix/some/endpoint/:baz", rate_limited: false, authentication: None, } diff --git a/crates/ruma-api/tests/ui/08-deprecated-without-added.rs b/crates/ruma-api/tests/ui/08-deprecated-without-added.rs index 502f96e9..510427ae 100644 --- a/crates/ruma-api/tests/ui/08-deprecated-without-added.rs +++ b/crates/ruma-api/tests/ui/08-deprecated-without-added.rs @@ -5,7 +5,7 @@ ruma_api! { description: "This will fail.", method: GET, name: "invalid_versions", - path: "/a/path", + unstable_path: "/a/path", rate_limited: false, authentication: None, diff --git a/crates/ruma-api/tests/ui/09-removed-without-deprecated.rs b/crates/ruma-api/tests/ui/09-removed-without-deprecated.rs index 4702abe9..7bb3861c 100644 --- a/crates/ruma-api/tests/ui/09-removed-without-deprecated.rs +++ b/crates/ruma-api/tests/ui/09-removed-without-deprecated.rs @@ -5,7 +5,7 @@ ruma_api! { description: "This will fail.", method: GET, name: "invalid_versions", - path: "/a/path", + unstable_path: "/a/path", rate_limited: false, authentication: None,