Disallow multiple ruma_api(body) attributes in one request / response

This commit is contained in:
Jonas Platte 2019-11-11 22:32:10 +01:00
parent 47267cc2ba
commit c8f1342144
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 9 additions and 0 deletions

View File

@ -144,6 +144,11 @@ impl From<Vec<Field>> for Request {
Meta::Word(ident) => {
match &ident.to_string()[..] {
"body" => {
assert!(
!has_newtype_body,
"ruma_api! body attribute can only be used once per request definition"
);
has_newtype_body = true;
field_kind = RequestFieldKind::NewtypeBody;
}

View File

@ -116,6 +116,10 @@ impl From<Vec<Field>> for Response {
ident == "body",
"ruma_api! single-word attribute on responses must be: body"
);
assert!(
!has_newtype_body,
"ruma_api! body attribute can only be used once per response definition"
);
has_newtype_body = true;
field_kind = ResponseFieldKind::NewtypeBody;