Skip to content

Commit

Permalink
chore: camel case views
Browse files Browse the repository at this point in the history
  • Loading branch information
litsynp committed Mar 29, 2024
1 parent 23d2bff commit 8775438
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/auth/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ use serde::{Deserialize, Serialize};
use utoipa::ToSchema;

#[derive(Deserialize, Serialize, ToSchema, Clone)]
#[serde(rename_all = "camelCase")]
pub struct LoginRequest {
#[schema(example = "[email protected]")]
pub email: String,
pub password: String,
}

#[derive(Deserialize, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TokenView {
pub user_id: i32,
pub access_token: String,
Expand Down
1 change: 1 addition & 0 deletions src/common/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use thiserror::Error;
use utoipa::ToSchema;

#[derive(Serialize, Error, Debug, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct ApiError {
status_code: u16,
errors: Vec<String>,
Expand Down
3 changes: 3 additions & 0 deletions src/todo/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use utoipa::ToSchema;
use crate::todo::models::Todo;

#[derive(sqlx::FromRow, Deserialize, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct TodoView {
pub id: i32,
pub title: String,
Expand All @@ -27,12 +28,14 @@ impl From<Todo> for TodoView {
}

#[derive(sqlx::FromRow, Deserialize, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct NewTodoRequest {
pub title: String,
pub description: String,
}

#[derive(sqlx::FromRow, Deserialize, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct EditTodoRequest {
pub title: String,
pub description: String,
Expand Down
2 changes: 2 additions & 0 deletions src/user/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use utoipa::ToSchema;
use crate::user::models::User;

#[derive(sqlx::FromRow, Deserialize, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UserView {
pub id: i32,
#[schema(example = "[email protected]")]
Expand All @@ -22,6 +23,7 @@ impl From<User> for UserView {
}

#[derive(sqlx::FromRow, Deserialize, Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct NewUserRequest {
#[schema(example = "[email protected]")]
pub email: String,
Expand Down

0 comments on commit 8775438

Please sign in to comment.