Add try_build test testing new type body fields are declared last

This commit is contained in:
Devin Ragotzy 2020-07-28 17:10:54 -04:00
parent b68b63ab8d
commit f00bad3895
2 changed files with 38 additions and 0 deletions

View File

@ -3,4 +3,5 @@ fn ui() {
let t = trybuild::TestCases::new(); let t = trybuild::TestCases::new();
t.pass("tests/ui/01-api-sanity-check.rs"); t.pass("tests/ui/01-api-sanity-check.rs");
t.compile_fail("tests/ui/02-invalid-path.rs"); t.compile_fail("tests/ui/02-invalid-path.rs");
t.pass("tests/ui/03-move-value.rs");
} }

View File

@ -0,0 +1,37 @@
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
ruma_api! {
metadata: {
description: "Does something.",
method: POST,
name: "my_endpoint",
path: "/_matrix/foo/:bar/",
rate_limited: false,
requires_authentication: false,
}
request: {
#[ruma_api(body)]
pub q2: Vec<u8>,
#[ruma_api(path)]
pub bar: String,
#[ruma_api(query)]
pub baz: UserId,
#[ruma_api(header = CONTENT_TYPE)]
pub world: String,
}
response: {
#[ruma_api(body)]
pub q2: Vec<u8>,
#[ruma_api(header = CONTENT_TYPE)]
pub world: String,
}
}
fn main() {}