paperclip_core/v3/models/
paths.rs

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
use super::v2;
use std::collections::BTreeMap;

impl From<v2::DefaultPathItemRaw> for openapiv3::PathItem {
    fn from(v2: v2::DefaultPathItemRaw) -> Self {
        let methods = v2
            .methods
            .iter()
            .map(|(k, v)| (*k, v.clone().into()))
            .collect::<BTreeMap<v2::HttpMethod, openapiv3::Operation>>();

        openapiv3::PathItem {
            get: methods.get(&v2::HttpMethod::Get).cloned(),
            put: methods.get(&v2::HttpMethod::Put).cloned(),
            post: methods.get(&v2::HttpMethod::Post).cloned(),
            delete: methods.get(&v2::HttpMethod::Delete).cloned(),
            options: methods.get(&v2::HttpMethod::Options).cloned(),
            head: methods.get(&v2::HttpMethod::Head).cloned(),
            patch: methods.get(&v2::HttpMethod::Patch).cloned(),
            trace: None,
            servers: vec![],
            parameters: {
                openapiv3::Operation::from(v2::DefaultOperationRaw {
                    parameters: v2.parameters,
                    ..Default::default()
                })
                .parameters
            },
            extensions: Default::default(),
            description: None,
            summary: None,
        }
    }
}