openzeppelin_relayer/api/routes/docs/
signer_docs.rs

1use crate::models::{ApiResponse, SignerCreateRequest, SignerResponse, SignerUpdateRequest};
2
3/// Signer routes implementation
4///
5/// Note: OpenAPI documentation for these endpoints can be found in the `openapi.rs` file
6///
7/// Lists all signers with pagination support.
8#[utoipa::path(
9  get,
10  path = "/api/v1/signers",
11  tag = "Signers",
12  operation_id = "listSigners",
13  security(
14      ("bearer_auth" = [])
15  ),
16  params(
17      ("page" = Option<usize>, Query, description = "Page number for pagination (starts at 1)"),
18      ("per_page" = Option<usize>, Query, description = "Number of items per page (default: 10)")
19  ),
20  responses(
21      (
22          status = 200,
23          description = "Signer list retrieved successfully",
24          body = ApiResponse<Vec<SignerResponse>>
25      ),
26      (
27          status = 400,
28          description = "Bad Request",
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 = 500,
48          description = "Internal Server Error",
49          body = ApiResponse<String>,
50          example = json!({
51              "success": false,
52              "message": "Internal Server Error",
53              "data": null
54          })
55      )
56  )
57)]
58#[allow(dead_code)]
59fn doc_list_signers() {}
60
61/// Retrieves details of a specific signer by ID.
62#[utoipa::path(
63  get,
64  path = "/api/v1/signers/{signer_id}",
65  tag = "Signers",
66  operation_id = "getSigner",
67  security(
68      ("bearer_auth" = [])
69  ),
70  params(
71      ("signer_id" = String, Path, description = "Signer ID")
72  ),
73  responses(
74      (
75          status = 200,
76          description = "Signer retrieved successfully",
77          body = ApiResponse<SignerResponse>
78      ),
79      (
80          status = 400,
81          description = "Bad Request",
82          body = ApiResponse<String>,
83          example = json!({
84              "success": false,
85              "message": "Bad Request",
86              "data": null
87          })
88      ),
89      (
90          status = 401,
91          description = "Unauthorized",
92          body = ApiResponse<String>,
93          example = json!({
94              "success": false,
95              "message": "Unauthorized",
96              "data": null
97          })
98      ),
99      (
100          status = 404,
101          description = "Signer not found",
102          body = ApiResponse<String>,
103          example = json!({
104              "success": false,
105              "message": "Signer not found",
106              "data": null
107          })
108      ),
109      (
110          status = 500,
111          description = "Internal Server Error",
112          body = ApiResponse<String>,
113          example = json!({
114              "success": false,
115              "message": "Internal Server Error",
116              "data": null
117          })
118      )
119  )
120)]
121#[allow(dead_code)]
122fn doc_get_signer() {}
123
124/// Creates a new signer.
125#[utoipa::path(
126  post,
127  path = "/api/v1/signers",
128  tag = "Signers",
129  operation_id = "createSigner",
130  security(
131      ("bearer_auth" = [])
132  ),
133  request_body = SignerCreateRequest,
134  responses(
135      (
136          status = 201,
137          description = "Signer created successfully",
138          body = ApiResponse<SignerResponse>
139      ),
140      (
141          status = 400,
142          description = "Bad Request",
143          body = ApiResponse<String>,
144          example = json!({
145              "success": false,
146              "message": "Bad Request",
147              "data": null
148          })
149      ),
150      (
151          status = 401,
152          description = "Unauthorized",
153          body = ApiResponse<String>,
154          example = json!({
155              "success": false,
156              "message": "Unauthorized",
157              "data": null
158          })
159      ),
160      (
161          status = 409,
162          description = "Signer with this ID already exists",
163          body = ApiResponse<String>,
164          example = json!({
165              "success": false,
166              "message": "Signer with this ID already exists",
167              "data": null
168          })
169      ),
170      (
171          status = 500,
172          description = "Internal Server Error",
173          body = ApiResponse<String>,
174          example = json!({
175              "success": false,
176              "message": "Internal Server Error",
177              "data": null
178          })
179      )
180  )
181)]
182#[allow(dead_code)]
183fn doc_create_signer() {}
184
185/// Updates an existing signer.
186#[utoipa::path(
187  patch,
188  path = "/api/v1/signers/{signer_id}",
189  tag = "Signers",
190  operation_id = "updateSigner",
191  security(
192      ("bearer_auth" = [])
193  ),
194  params(
195      ("signer_id" = String, Path, description = "Signer ID")
196  ),
197  request_body = SignerUpdateRequest,
198  responses(
199      (
200          status = 200,
201          description = "Signer updated successfully",
202          body = ApiResponse<SignerResponse>
203      ),
204      (
205          status = 400,
206          description = "Bad Request",
207          body = ApiResponse<String>,
208          example = json!({
209              "success": false,
210              "message": "Bad Request",
211              "data": null
212          })
213      ),
214      (
215          status = 401,
216          description = "Unauthorized",
217          body = ApiResponse<String>,
218          example = json!({
219              "success": false,
220              "message": "Unauthorized",
221              "data": null
222          })
223      ),
224      (
225          status = 404,
226          description = "Signer not found",
227          body = ApiResponse<String>,
228          example = json!({
229              "success": false,
230              "message": "Signer not found",
231              "data": null
232          })
233      ),
234      (
235          status = 500,
236          description = "Internal Server Error",
237          body = ApiResponse<String>,
238          example = json!({
239              "success": false,
240              "message": "Internal Server Error",
241              "data": null
242          })
243      )
244  )
245)]
246#[allow(dead_code)]
247fn doc_update_signer() {}
248
249/// Deletes a signer by ID.
250#[utoipa::path(
251  delete,
252  path = "/api/v1/signers/{signer_id}",
253  tag = "Signers",
254  operation_id = "deleteSigner",
255  security(
256      ("bearer_auth" = [])
257  ),
258  params(
259      ("signer_id" = String, Path, description = "Signer ID")
260  ),
261  responses(
262      (
263          status = 200,
264          description = "Signer deleted successfully",
265          body = ApiResponse<String>,
266          example = json!({
267              "success": true,
268              "message": "Signer deleted successfully",
269              "data": "Signer deleted successfully"
270          })
271      ),
272      (
273          status = 400,
274          description = "Bad Request",
275          body = ApiResponse<String>,
276          example = json!({
277              "success": false,
278              "message": "Bad Request",
279              "data": null
280          })
281      ),
282      (
283          status = 401,
284          description = "Unauthorized",
285          body = ApiResponse<String>,
286          example = json!({
287              "success": false,
288              "message": "Unauthorized",
289              "data": null
290          })
291      ),
292      (
293          status = 404,
294          description = "Signer not found",
295          body = ApiResponse<String>,
296          example = json!({
297              "success": false,
298                "message": "Signer not found",
299              "data": null
300          })
301      ),
302      (
303          status = 500,
304          description = "Internal Server Error",
305          body = ApiResponse<String>,
306          example = json!({
307              "success": false,
308              "message": "Internal Server Error",
309              "data": null
310          })
311      )
312  )
313)]
314#[allow(dead_code)]
315fn doc_delete_signer() {}