openzeppelin_relayer/api/routes/docs/
plugin_docs.rs

1use crate::{
2    models::{ApiResponse, PluginCallRequest, PluginModel},
3    repositories::PaginatedResult,
4    services::plugins::PluginCallResponse,
5};
6
7/// Calls a plugin method.
8#[utoipa::path(
9    post,
10    path = "/api/v1/plugins/{plugin_id}/call",
11    tag = "Plugins",
12    operation_id = "callPlugin",
13    security(
14        ("bearer_auth" = [])
15    ),
16    params(
17        ("plugin_id" = String, Path, description = "The unique identifier of the plugin")
18    ),
19    request_body = PluginCallRequest,
20    responses(
21        (
22            status = 200,
23            description = "Plugin call successful",
24            body = ApiResponse<PluginCallResponse>
25        ),
26        (
27            status = 400,
28            description = "BadRequest",
29            body = ApiResponse<String>,
30            example = json!({
31                "success": false,
32                "message": "Bad Request",
33                "data": null
34            })
35        ),
36        (
37            status = 401,
38            description = "Unauthorized",
39            body = ApiResponse<String>,
40            example = json!({
41                "success": false,
42                "message": "Unauthorized",
43                "data": null
44            })
45        ),
46        (
47            status = 404,
48            description = "Not Found",
49            body = ApiResponse<String>,
50            example = json!({
51                "success": false,
52                "message": "Plugin with ID plugin_id not found",
53                "data": null
54            })
55        ),
56        (
57            status = 429,
58            description = "Too Many Requests",
59            body = ApiResponse<String>,
60            example = json!({
61                "success": false,
62                "message": "Too Many Requests",
63                "data": null
64            })
65        ),
66        (
67            status = 500,
68            description = "Internal server error",
69            body = ApiResponse<String>,
70            example = json!({
71                "success": false,
72                "message": "Internal Server Error",
73                "data": null
74            })
75        ),
76    )
77)]
78#[allow(dead_code)]
79fn doc_call_plugin() {}
80
81/// List plugins.
82#[utoipa::path(
83    get,
84    path = "/api/v1/plugins",
85    tag = "Plugins",
86    operation_id = "listPlugins",
87    security(
88        ("bearer_auth" = [])
89    ),
90    params(
91        ("page" = Option<usize>, Query, description = "Page number for pagination (starts at 1)"),
92        ("per_page" = Option<usize>, Query, description = "Number of items per page (default: 10)")
93    ),
94    responses(
95        (
96            status = 200,
97            description = "Plugins listed successfully",
98            body = ApiResponse<PaginatedResult<PluginModel>>
99        ),
100        (
101            status = 400,
102            description = "BadRequest",
103            body = ApiResponse<String>,
104            example = json!({
105                "success": false,
106                "message": "Bad Request",
107                "data": null
108            })
109        ),
110        (
111            status = 401,
112            description = "Unauthorized",
113            body = ApiResponse<String>,
114            example = json!({
115                "success": false,
116                "message": "Unauthorized",
117                "data": null
118            })
119        ),
120        (
121            status = 404,
122            description = "Not Found",
123            body = ApiResponse<String>,
124            example = json!({
125                "success": false,
126                "message": "Plugin with ID plugin_id not found",
127                "data": null
128            })
129        ),
130        (
131            status = 429,
132            description = "Too Many Requests",
133            body = ApiResponse<String>,
134            example = json!({
135                "success": false,
136                "message": "Too Many Requests",
137                "data": null
138            })
139        ),
140        (
141            status = 500,
142            description = "Internal server error",
143            body = ApiResponse<String>,
144            example = json!({
145                "success": false,
146                "message": "Internal Server Error",
147                "data": null
148            })
149        ),
150    )
151)]
152#[allow(dead_code)]
153fn doc_list_plugins() {}