Detect header attributes as name/value pairs.
This commit is contained in:
parent
a035c233be
commit
f0f4f9bd17
@ -92,25 +92,26 @@ impl From<Vec<Field>> for Request {
|
|||||||
match meta_item {
|
match meta_item {
|
||||||
Meta::Word(ident) => {
|
Meta::Word(ident) => {
|
||||||
match ident.as_ref() {
|
match ident.as_ref() {
|
||||||
"body" => {
|
"body" => {
|
||||||
has_newtype_body = true;
|
has_newtype_body = true;
|
||||||
field_kind = RequestFieldKind::NewtypeBody;
|
field_kind = RequestFieldKind::NewtypeBody;
|
||||||
}
|
}
|
||||||
"header" => field_kind = RequestFieldKind::Header,
|
"path" => field_kind = RequestFieldKind::Path,
|
||||||
"path" => field_kind = RequestFieldKind::Path,
|
"query" => field_kind = RequestFieldKind::Query,
|
||||||
"query" => field_kind = RequestFieldKind::Query,
|
_ => panic!("ruma_api! single-word attribute on requests must be: body, path, or query"),
|
||||||
_ => panic!(
|
|
||||||
"ruma_api! attribute meta item on requests must be: body, header, path, or query"
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => panic!(
|
Meta::NameValue(name_value) => {
|
||||||
"ruma_api! attribute meta item on requests cannot be a list or name/value pair"
|
match name_value.ident.as_ref() {
|
||||||
),
|
"header" => field_kind = RequestFieldKind::Header,
|
||||||
|
_ => panic!("ruma_api! name/value pair attribute on requests must be: header"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => panic!("ruma_api! attributes on requests must be a single word or a name/value pair"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NestedMeta::Literal(_) => panic!(
|
NestedMeta::Literal(_) => panic!(
|
||||||
"ruma_api! attribute meta item on requests must be: body, header, path, or query"
|
"ruma_api! attributes on requests must be: body, header, path, or query"
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,18 +101,19 @@ impl From<Vec<Field>> for Response {
|
|||||||
Meta::Word(ident) => {
|
Meta::Word(ident) => {
|
||||||
match ident.as_ref() {
|
match ident.as_ref() {
|
||||||
"body" => {
|
"body" => {
|
||||||
has_newtype_body = true;
|
has_newtype_body = true;
|
||||||
field_kind = ResponseFieldKind::NewtypeBody;
|
field_kind = ResponseFieldKind::NewtypeBody;
|
||||||
}
|
}
|
||||||
"header" => field_kind = ResponseFieldKind::Header,
|
_ => panic!("ruma_api! single-word attribute on responses must be: body"),
|
||||||
_ => panic!(
|
|
||||||
"ruma_api! attribute meta item on responses must be: header"
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => panic!(
|
Meta::NameValue(name_value) => {
|
||||||
"ruma_api! attribute meta item on responses cannot be a list or name/value pair"
|
match name_value.ident.as_ref() {
|
||||||
),
|
"header" => field_kind = ResponseFieldKind::Header,
|
||||||
|
_ => panic!("ruma_api! name/value pair attribute on requests must be: header"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => panic!("ruma_api! attributes on responses must be a single word or a name/value pair"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NestedMeta::Literal(_) => panic!(
|
NestedMeta::Literal(_) => panic!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user