animi_okapi/lib.rs
1#![forbid(unsafe_code)]
2#![deny(clippy::all)]
3
4pub type Map<K, V> = schemars::Map<K, V>;
5pub type MapEntry<'a, K, V> = schemars::MapEntry<'a, K, V>;
6
7pub mod merge;
8pub mod openapi3;
9
10/// Re-export the current version of `Schemars` used by `Okapi`.
11pub use schemars;
12
13/// Macro to crate an `okapi::Map` with a number of key-value pairs in it.
14///
15/// # Examples
16///
17/// ```rust
18/// use animi_okapi::Map;
19/// use animi_okapi::map;
20///
21/// let my_map = map!{
22/// "user:read".to_owned() => "Ability to read user data".to_owned(),
23/// "user:write".to_owned() => "Ability to write user data".to_owned(),
24/// };
25///
26/// let mut control = Map::new();
27/// control.insert("user:read".to_owned(),"Ability to read user data".to_owned());
28/// control.insert("user:write".to_owned(),"Ability to write user data".to_owned());
29///
30/// assert_eq!(my_map, control);
31/// ```
32#[macro_export]
33macro_rules! map {
34 ($($key:expr => $val:expr),* $(,)*) => ({
35 #[allow(unused_mut)]
36 let mut map = animi_okapi::Map::new();
37 $( map.insert($key, $val); )*
38 map
39 });
40}