Skip to main content

axum_error_sets/
aide_impls.rs

1use super::*;
2
3macro_rules! impl_operation_output {
4    ($($error:ident),+ $(,)?) => {
5        impl<R, $($error),+> aide::OperationOutput for ErrorSet<R, ($($error,)+)>
6        where
7            R: AideResponseFor,
8            $($error: StatusWrapper),+
9        {
10            type Inner = R::Inner;
11
12            fn operation_response(
13                _ctx: &mut aide::generate::GenContext,
14                _operation: &mut aide::openapi::Operation,
15            ) -> Option<aide::openapi::Response> {
16                None
17            }
18
19            fn inferred_responses(
20                ctx: &mut aide::generate::GenContext,
21                operation: &mut aide::openapi::Operation,
22            ) -> Vec<(Option<u16>, aide::openapi::Response)> {
23                vec![
24                    $(
25                        (
26                            Some($error::STATUS_CODE.as_u16()),
27                            R::inferred_response_for(
28                                ctx,
29                                operation,
30                                $error::STATUS_CODE,
31                            ),
32                        ),
33                    )+
34                ]
35            }
36        }
37    };
38}
39
40impl_operation_output!(E1);
41impl_operation_output!(E1, E2);
42impl_operation_output!(E1, E2, E3);
43impl_operation_output!(E1, E2, E3, E4);
44impl_operation_output!(E1, E2, E3, E4, E5);
45impl_operation_output!(E1, E2, E3, E4, E5, E6);
46impl_operation_output!(E1, E2, E3, E4, E5, E6, E7);
47impl_operation_output!(E1, E2, E3, E4, E5, E6, E7, E8);
48impl_operation_output!(E1, E2, E3, E4, E5, E6, E7, E8, E9);
49impl_operation_output!(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10);
50impl_operation_output!(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11);
51impl_operation_output!(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12);
52
53impl<R> aide::OperationOutput for ErrorSet<R, ()>
54where
55    R: AideResponseFor,
56{
57    type Inner = R::Inner;
58
59    fn operation_response(
60        _ctx: &mut aide::generate::GenContext,
61        _operation: &mut aide::openapi::Operation,
62    ) -> Option<aide::openapi::Response> {
63        None
64    }
65
66    fn inferred_responses(
67        _ctx: &mut aide::generate::GenContext,
68        _operation: &mut aide::openapi::Operation,
69    ) -> Vec<(Option<u16>, aide::openapi::Response)> {
70        vec![]
71    }
72}