swagger_utils/definitions/
mod.rs

1use common::Attribute;
2use std::collections::HashMap;
3
4pub type Definitions = HashMap<String, Attribute>;
5
6#[cfg(test)]
7mod tests {
8    extern crate yaml_rust;
9    use common::Type;
10    use definitions::Definitions;
11    use std::collections::HashMap;
12    use std::fs::File;
13    use std::path::PathBuf;
14
15    #[test]
16    fn load_test_yaml() {
17        let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
18        path.push("src/definitions/test.yaml");
19        let file = File::open(path.to_str().unwrap()).unwrap();
20        let root: HashMap<String, Definitions> = serde_yaml::from_reader(&file).unwrap();
21        let definitions = root.get("definitions").unwrap();
22        let category = definitions.get("Category").unwrap();
23        assert_eq!(category.type_.unwrap(), Type::Object);
24        let pet = definitions.get("Pet").unwrap();
25        let pet_properties = pet.properties.as_ref();
26        let photo_urls = pet_properties.unwrap().get("photoUrls").unwrap();
27        assert_eq!(photo_urls.type_.unwrap(), Type::Array);
28    }
29}