Skip to content

Commit

Permalink
Ensure we deserialize just the right fields when creating new entities
Browse files Browse the repository at this point in the history
  • Loading branch information
jhodapp committed Dec 2, 2024
1 parent 643f1f9 commit 41d22c7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions entity/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ pub struct Model {
#[serde(skip_deserializing)]
pub status_changed_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}

Expand Down
3 changes: 3 additions & 0 deletions entity/src/coachees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use utoipa::ToSchema;
#[schema(as = entity::users::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "users")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
Expand All @@ -18,8 +19,10 @@ pub struct Model {
pub password: String,
pub github_username: Option<String>,
pub github_profile_url: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
3 changes: 3 additions & 0 deletions entity/src/coaches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use utoipa::ToSchema;
#[schema(as = entity::users::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "users")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
Expand All @@ -18,8 +19,10 @@ pub struct Model {
pub password: String,
pub github_username: Option<String>,
pub github_profile_url: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
3 changes: 3 additions & 0 deletions entity/src/coaching_relationships.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ use utoipa::ToSchema;
table_name = "coaching_relationships"
)]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
pub organization_id: Id,
pub coach_id: Id,
pub coachee_id: Id,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
5 changes: 5 additions & 0 deletions entity/src/coaching_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ use utoipa::ToSchema;
#[schema(as = entity::coaching_sessions::Model)]
#[sea_orm(schema_name = "refactor_platform", table_name = "coaching_sessions")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
pub coaching_relationship_id: Id,
pub date: DateTime,
pub timezone: String,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}

Expand Down
3 changes: 3 additions & 0 deletions entity/src/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ use utoipa::ToSchema;
#[schema(as = entity::organizations::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "organizations")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
pub name: String,
pub logo: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down
3 changes: 3 additions & 0 deletions entity/src/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use utoipa::ToSchema;
#[schema(as = entity::users::Model)] // OpenAPI schema
#[sea_orm(schema_name = "refactor_platform", table_name = "users")]
pub struct Model {
#[serde(skip_deserializing)]
#[sea_orm(primary_key)]
pub id: Id,
#[sea_orm(unique)]
Expand All @@ -22,8 +23,10 @@ pub struct Model {
pub password: String,
pub github_username: Option<String>,
pub github_profile_url: Option<String>,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub created_at: DateTimeWithTimeZone,
#[serde(skip_deserializing)]
#[schema(value_type = String, format = DateTime)] // Applies to OpenAPI schema
pub updated_at: DateTimeWithTimeZone,
}
Expand Down

0 comments on commit 41d22c7

Please sign in to comment.