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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#[macro_use]
extern crate quote;
#[macro_use]
extern crate syn;
extern crate proc_macro;
mod openapi_attr;
mod routes_with_openapi;
use proc_macro::TokenStream;
use syn::Ident;
#[proc_macro_attribute]
pub fn openapi(args: TokenStream, mut input: TokenStream) -> TokenStream {
input.extend(openapi_attr::parse(args, input.clone()));
input
}
#[proc_macro]
pub fn routes_and_spec_with_openapi(input: TokenStream) -> TokenStream {
routes_with_openapi::parse_spec_and_routes(input)
}
#[proc_macro]
pub fn routes_with_openapi(input: TokenStream) -> TokenStream {
routes_with_openapi::parse(input)
}
fn get_add_operation_fn_name(route_fn_name: &Ident) -> Ident {
Ident::new(
&format!("okapi_add_operation_for_{}_", route_fn_name),
route_fn_name.span(),
)
}