oasgen_core/
operation.rs

1use openapiv3::{Operation, Parameter, RefOr, Schema};
2
3pub struct OperationRegister {
4    pub name: &'static str,
5    pub constructor: &'static (dyn Sync + Send + Fn() -> Operation),
6}
7
8pub trait OaParameter {
9    fn body_schema() -> Option<RefOr<Schema>> {
10        None
11    }
12    fn parameter_schemas() -> Vec<RefOr<Schema>> {
13        Vec::new()
14    }
15    fn parameters() -> Vec<RefOr<Parameter>> {
16        Vec::new()
17    }
18}
19
20impl<T, E> OaParameter for Result<T, E>
21where
22    T: OaParameter,
23{
24    fn body_schema() -> Option<RefOr<Schema>> {
25        T::body_schema()
26    }
27}
28
29inventory::collect!(OperationRegister);