diff options
Diffstat (limited to 'src/routers')
| -rw-r--r-- | src/routers/account.rs | 22 | ||||
| -rw-r--r-- | src/routers/queue.rs | 24 |
2 files changed, 25 insertions, 21 deletions
diff --git a/src/routers/account.rs b/src/routers/account.rs index 71ba496..1ae8c22 100644 --- a/src/routers/account.rs +++ b/src/routers/account.rs | |||
| @@ -34,7 +34,7 @@ struct Token { | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | #[derive(Deserialize, ToSchema)] | 36 | #[derive(Deserialize, ToSchema)] |
| 37 | #[schema(description = "Account register data")] | 37 | #[schema(description = "Body of the account registration request")] |
| 38 | struct RegisterRequest { | 38 | struct RegisterRequest { |
| 39 | #[schema(examples("john_doe", "ivanov_ivan"))] | 39 | #[schema(examples("john_doe", "ivanov_ivan"))] |
| 40 | username: String, | 40 | username: String, |
| @@ -57,7 +57,7 @@ enum TokenLifetime { | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | #[derive(Deserialize, ToSchema)] | 59 | #[derive(Deserialize, ToSchema)] |
| 60 | #[schema(description = "Account login data")] | 60 | #[schema(description = "Body of the login request")] |
| 61 | struct LoginRequest { | 61 | struct LoginRequest { |
| 62 | #[schema(examples("john_doe", "ivanov_ivan"))] | 62 | #[schema(examples("john_doe", "ivanov_ivan"))] |
| 63 | username: String, | 63 | username: String, |
| @@ -69,7 +69,7 @@ struct LoginRequest { | |||
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | #[derive(Deserialize, ToSchema)] | 71 | #[derive(Deserialize, ToSchema)] |
| 72 | #[schema(description = "Change account password data")] | 72 | #[schema(description = "Body of the change account password request")] |
| 73 | struct ChangePasswordRequest { | 73 | struct ChangePasswordRequest { |
| 74 | #[schema(examples("secret-password"))] | 74 | #[schema(examples("secret-password"))] |
| 75 | old_password: String, | 75 | old_password: String, |
| @@ -78,14 +78,14 @@ struct ChangePasswordRequest { | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | #[derive(Deserialize, ToSchema)] | 80 | #[derive(Deserialize, ToSchema)] |
| 81 | #[schema(description = "Change account password data")] | 81 | #[schema(description = "Body of the change account username request")] |
| 82 | struct ChangeUsernameRequest { | 82 | struct ChangeUsernameRequest { |
| 83 | #[schema(examples("ivanov_ivan", "john_doe"))] | 83 | #[schema(examples("ivanov_ivan", "john_doe"))] |
| 84 | new_username: String, | 84 | new_username: String, |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | #[derive(Deserialize, ToSchema)] | 87 | #[derive(Deserialize, ToSchema)] |
| 88 | #[schema(description = "Change account name data")] | 88 | #[schema(description = "Body of the change account name request")] |
| 89 | struct ChangeNameRequest { | 89 | struct ChangeNameRequest { |
| 90 | #[schema(examples("John", "Иван"))] | 90 | #[schema(examples("John", "Иван"))] |
| 91 | first_name: Option<String>, | 91 | first_name: Option<String>, |
| @@ -94,7 +94,7 @@ struct ChangeNameRequest { | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | #[derive(Deserialize, ToSchema)] | 96 | #[derive(Deserialize, ToSchema)] |
| 97 | #[schema(description = "Account delete data")] | 97 | #[schema(description = "Body of the delete account request")] |
| 98 | struct DeleteUserRequest { | 98 | struct DeleteUserRequest { |
| 99 | #[schema(examples("secret-password"))] | 99 | #[schema(examples("secret-password"))] |
| 100 | password: String, | 100 | password: String, |
| @@ -129,7 +129,7 @@ async fn me(Auth(user): Auth) -> ApiResult<Account> { | |||
| 129 | responses( | 129 | responses( |
| 130 | ( | 130 | ( |
| 131 | status = 200, body = SuccessResponse<Account>, | 131 | status = 200, body = SuccessResponse<Account>, |
| 132 | description = "Success response with created account data" | 132 | description = "Success response with your account data" |
| 133 | ), | 133 | ), |
| 134 | GlobalResponses | 134 | GlobalResponses |
| 135 | ), | 135 | ), |
| @@ -213,7 +213,7 @@ async fn login( | |||
| 213 | responses( | 213 | responses( |
| 214 | ( | 214 | ( |
| 215 | status = 200, body = SuccessResponse<Account>, | 215 | status = 200, body = SuccessResponse<Account>, |
| 216 | description = "Success response with changed account data" | 216 | description = "Success response with the updated account data" |
| 217 | ), | 217 | ), |
| 218 | GlobalResponses | 218 | GlobalResponses |
| 219 | ), | 219 | ), |
| @@ -246,7 +246,7 @@ async fn change_password( | |||
| 246 | responses( | 246 | responses( |
| 247 | ( | 247 | ( |
| 248 | status = 200, body = SuccessResponse<Account>, | 248 | status = 200, body = SuccessResponse<Account>, |
| 249 | description = "Success response with changed account data" | 249 | description = "Success response with the updated account data" |
| 250 | ), | 250 | ), |
| 251 | GlobalResponses | 251 | GlobalResponses |
| 252 | ), | 252 | ), |
| @@ -281,7 +281,7 @@ async fn change_username( | |||
| 281 | responses( | 281 | responses( |
| 282 | ( | 282 | ( |
| 283 | status = 200, body = SuccessResponse<Account>, | 283 | status = 200, body = SuccessResponse<Account>, |
| 284 | description = "Success response with changed account data" | 284 | description = "Success response with the updated account data" |
| 285 | ), | 285 | ), |
| 286 | GlobalResponses | 286 | GlobalResponses |
| 287 | ), | 287 | ), |
| @@ -315,7 +315,7 @@ async fn change_name( | |||
| 315 | responses( | 315 | responses( |
| 316 | ( | 316 | ( |
| 317 | status = 200, body = SuccessResponse<Account>, | 317 | status = 200, body = SuccessResponse<Account>, |
| 318 | description = "Success response with deleted account data" | 318 | description = "Success response with the deleted account data" |
| 319 | ), | 319 | ), |
| 320 | GlobalResponses | 320 | GlobalResponses |
| 321 | ), | 321 | ), |
diff --git a/src/routers/queue.rs b/src/routers/queue.rs index 1e93b2a..df846fb 100644 --- a/src/routers/queue.rs +++ b/src/routers/queue.rs | |||
| @@ -32,12 +32,14 @@ async fn get_owned_queue( | |||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | #[derive(Deserialize, ToSchema)] | 34 | #[derive(Deserialize, ToSchema)] |
| 35 | #[schema(description = "Body of the create queue request")] | ||
| 35 | struct CreateQueueRequest { | 36 | struct CreateQueueRequest { |
| 36 | #[schema(examples("John's queue", "Очередь Ивана"))] | 37 | #[schema(examples("John's queue", "Очередь Ивана"))] |
| 37 | name: String, | 38 | name: String, |
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | #[derive(Deserialize, ToSchema)] | 41 | #[derive(Deserialize, ToSchema)] |
| 42 | #[schema(description = "Body of the change queue name request")] | ||
| 41 | struct ChangeQueueNameRequest { | 43 | struct ChangeQueueNameRequest { |
| 42 | #[schema(examples(1))] | 44 | #[schema(examples(1))] |
| 43 | id: i64, | 45 | id: i64, |
| @@ -46,7 +48,8 @@ struct ChangeQueueNameRequest { | |||
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | #[derive(Deserialize, ToSchema)] | 50 | #[derive(Deserialize, ToSchema)] |
| 49 | struct ChangeQueueOwnerRequest { | 51 | #[schema(description = "Body of the change queue ownership request")] |
| 52 | struct ChangeQueueOwnershipRequest { | ||
| 50 | #[schema(examples(1))] | 53 | #[schema(examples(1))] |
| 51 | id: i64, | 54 | id: i64, |
| 52 | #[schema(examples(1))] | 55 | #[schema(examples(1))] |
| @@ -54,6 +57,7 @@ struct ChangeQueueOwnerRequest { | |||
| 54 | } | 57 | } |
| 55 | 58 | ||
| 56 | #[derive(Deserialize, ToSchema)] | 59 | #[derive(Deserialize, ToSchema)] |
| 60 | #[schema(description = "Body of the delete queue request")] | ||
| 57 | struct DeleteQueueRequest { | 61 | struct DeleteQueueRequest { |
| 58 | #[schema(examples(1))] | 62 | #[schema(examples(1))] |
| 59 | id: i64, | 63 | id: i64, |
| @@ -64,7 +68,7 @@ struct DeleteQueueRequest { | |||
| 64 | path = "/owned", | 68 | path = "/owned", |
| 65 | tag = QUEUE, | 69 | tag = QUEUE, |
| 66 | summary = "Get owned", | 70 | summary = "Get owned", |
| 67 | description = "Get your own queues", | 71 | description = "Get your queues", |
| 68 | responses( | 72 | responses( |
| 69 | ( | 73 | ( |
| 70 | status = 200, body = SuccessResponse<Vec<Queue>>, | 74 | status = 200, body = SuccessResponse<Vec<Queue>>, |
| @@ -96,7 +100,7 @@ async fn owned(State(state): State<AppState>, Auth(user): Auth) -> ApiResult<Vec | |||
| 96 | responses( | 100 | responses( |
| 97 | ( | 101 | ( |
| 98 | status = 200, body = SuccessResponse<Queue>, | 102 | status = 200, body = SuccessResponse<Queue>, |
| 99 | description = "Success response with created queue" | 103 | description = "Success response with the created queue" |
| 100 | ), | 104 | ), |
| 101 | GlobalResponses | 105 | GlobalResponses |
| 102 | ), | 106 | ), |
| @@ -129,7 +133,7 @@ async fn create( | |||
| 129 | responses( | 133 | responses( |
| 130 | ( | 134 | ( |
| 131 | status = 200, body = SuccessResponse<Queue>, | 135 | status = 200, body = SuccessResponse<Queue>, |
| 132 | description = "Success response with changed queue data" | 136 | description = "Success response with the changed queue data" |
| 133 | ), | 137 | ), |
| 134 | GlobalResponses | 138 | GlobalResponses |
| 135 | ), | 139 | ), |
| @@ -155,12 +159,12 @@ async fn change_name( | |||
| 155 | path = "/change/owner", | 159 | path = "/change/owner", |
| 156 | tag = QUEUE, | 160 | tag = QUEUE, |
| 157 | summary = "Change owner", | 161 | summary = "Change owner", |
| 158 | description = "Transfer ownership of the queue", | 162 | description = "Reassign queue ownership", |
| 159 | request_body = ChangeQueueOwnerRequest, | 163 | request_body = ChangeQueueOwnershipRequest, |
| 160 | responses( | 164 | responses( |
| 161 | ( | 165 | ( |
| 162 | status = 200, body = SuccessResponse<Queue>, | 166 | status = 200, body = SuccessResponse<Queue>, |
| 163 | description = "Success response with changed queue data" | 167 | description = "Success response with the changed queue data" |
| 164 | ), | 168 | ), |
| 165 | GlobalResponses | 169 | GlobalResponses |
| 166 | ), | 170 | ), |
| @@ -169,7 +173,7 @@ async fn change_name( | |||
| 169 | async fn change_owner( | 173 | async fn change_owner( |
| 170 | State(state): State<AppState>, | 174 | State(state): State<AppState>, |
| 171 | Auth(user): Auth, | 175 | Auth(user): Auth, |
| 172 | ApiJson(req): ApiJson<ChangeQueueOwnerRequest>, | 176 | ApiJson(req): ApiJson<ChangeQueueOwnershipRequest>, |
| 173 | ) -> ApiResult<Queue> { | 177 | ) -> ApiResult<Queue> { |
| 174 | if !user_exists(req.new_owner_id, &state.db).await? { | 178 | if !user_exists(req.new_owner_id, &state.db).await? { |
| 175 | return Err(ClientError::UserNotFound { | 179 | return Err(ClientError::UserNotFound { |
| @@ -193,12 +197,12 @@ async fn change_owner( | |||
| 193 | path = "/delete", | 197 | path = "/delete", |
| 194 | tag = QUEUE, | 198 | tag = QUEUE, |
| 195 | summary = "Delete", | 199 | summary = "Delete", |
| 196 | description = "Delete queue", | 200 | description = "Delete the queue", |
| 197 | request_body = DeleteQueueRequest, | 201 | request_body = DeleteQueueRequest, |
| 198 | responses( | 202 | responses( |
| 199 | ( | 203 | ( |
| 200 | status = 200, body = SuccessResponse<Queue>, | 204 | status = 200, body = SuccessResponse<Queue>, |
| 201 | description = "Success response with deleted queue data" | 205 | description = "Success response with the deleted queue data" |
| 202 | ), | 206 | ), |
| 203 | GlobalResponses | 207 | GlobalResponses |
| 204 | ), | 208 | ), |
