-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
/
lib.mustache
111 lines (101 loc) · 3.09 KB
/
lib.mustache
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#![allow(
missing_docs,
trivial_casts,
unused_variables,
unused_mut,
unused_extern_crates,
non_camel_case_types,
unused_imports,
unused_attributes,
)]
#![allow(
clippy::derive_partial_eq_without_eq,
clippy::disallowed_names,
clippy::too_many_arguments
)]
use async_trait::async_trait;
use axum::extract::*;
use axum_extra::extract::{CookieJar, Multipart};
use bytes::Bytes;
use http::Method;
use serde::{Deserialize, Serialize};
use types::*;
pub const BASE_PATH: &str = "{{{basePathWithoutHost}}}";
{{#appVersion}}
pub const API_VERSION: &str = "{{{.}}}";
{{/appVersion}}
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{>response}}
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
/// API
#[async_trait]
#[allow(clippy::ptr_arg)]
pub trait Api {
{{#apiInfo}}
{{#apis}}
{{#operations}}
{{#operation}}
{{#summary}}
/// {{{.}}}.
///
{{/summary}}
{{#vendorExtensions}}
/// {{{operationId}}} - {{{httpMethod}}} {{{basePathWithoutHost}}}{{{path}}}
async fn {{{x-operation-id}}}(
&self,
method: Method,
host: Host,
cookies: CookieJar,
{{#headerParams.size}}
header_params: models::{{{operationIdCamelCase}}}HeaderParams,
{{/headerParams.size}}
{{#pathParams.size}}
path_params: models::{{{operationIdCamelCase}}}PathParams,
{{/pathParams.size}}
{{#queryParams.size}}
query_params: models::{{{operationIdCamelCase}}}QueryParams,
{{/queryParams.size}}
{{^x-consumes-multipart-related}}
{{^x-consumes-multipart}}
{{#bodyParam}}
{{#vendorExtensions}}
{{^x-consumes-plain-text}}
body: {{^required}}Option<{{/required}}{{{dataType}}}{{^required}}>{{/required}},
{{/x-consumes-plain-text}}
{{#x-consumes-plain-text}}
{{#isString}}
body: String,
{{/isString}}
{{^isString}}
body: Bytes,
{{/isString}}
{{/x-consumes-plain-text}}
{{/vendorExtensions}}
{{/bodyParam}}
{{/x-consumes-multipart}}
{{/x-consumes-multipart-related}}
{{#x-consumes-multipart}}
body: Multipart,
{{/x-consumes-multipart}}
{{#x-consumes-multipart-related}}
body: axum::body::Body,
{{/x-consumes-multipart-related}}
) -> Result<{{{operationId}}}Response, String>;
{{/vendorExtensions}}
{{/operation}}
{{/operations}}
{{/apis}}
{{/apiInfo}}
}
#[cfg(feature = "server")]
pub mod server;
pub mod models;
pub mod types;
#[cfg(feature = "server")]
pub(crate) mod header;