1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::collections::BTreeMap;
use crate::{FromRef, RefPath, MediaType, Spec};
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Default)]
pub struct RequestBody {
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
pub content: BTreeMap<String, MediaType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub required: Option<bool>,
}
impl FromRef for RequestBody {
fn from_ref(
spec: &Spec,
path: &str,
) -> Option<Self>
where
Self: Sized,
{
let path = RefPath::from_str(path);
match path.kind.as_ref() {
"requestBodies" => spec
.components
.as_ref()
.and_then(|cs| cs.request_bodies.get(&path.name))
.and_then(|oor| oor.resolve(&spec)),
_ => None,
}
}
}