Disallow body fields in GET endpoints

This commit is contained in:
Jonas Platte 2019-11-11 22:55:04 +01:00
parent c8f1342144
commit d6f1926832
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -52,11 +52,19 @@ pub struct Api {
impl From<RawApi> for Api {
fn from(raw_api: RawApi) -> Self {
Self {
let res = Self {
metadata: raw_api.metadata.into(),
request: raw_api.request.into(),
response: raw_api.response.into(),
}
};
assert!(
!(res.metadata.method == "GET"
&& (res.request.has_body_fields() || res.request.newtype_body_field().is_some())),
"GET endpoints can't have body fields"
);
res
}
}