oasgen_core/
operation.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
use openapiv3::{Operation, Parameter, RefOr, Schema};

pub struct OperationRegister {
    pub name: &'static str,
    pub constructor: &'static (dyn Sync + Send + Fn() -> Operation),
}

pub trait OaParameter {
    fn body_schema() -> Option<RefOr<Schema>> {
        None
    }
    fn parameter_schemas() -> Vec<RefOr<Schema>> {
        Vec::new()
    }
    fn parameters() -> Vec<RefOr<Parameter>> {
        Vec::new()
    }
}

impl<T, E> OaParameter for Result<T, E>
where
    T: OaParameter,
{
    fn body_schema() -> Option<RefOr<Schema>> {
        T::body_schema()
    }
}

inventory::collect!(OperationRegister);