refactor: consolidate serde rename attributes using rename_all = camelCase

This commit is contained in:
2026-01-14 10:38:27 -06:00
parent 4299f65665
commit 72f1129555
7 changed files with 30 additions and 71 deletions
+10 -19
View File
@@ -34,29 +34,28 @@ pub struct ApiProjectLink {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiProject {
pub id: String,
pub slug: String,
pub name: String,
#[serde(rename = "shortDescription")]
pub short_description: String,
pub links: Vec<ApiProjectLink>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiAdminProject {
#[serde(flatten)]
pub project: ApiProject,
pub tags: Vec<ApiTag>,
pub status: String,
pub description: String,
#[serde(rename = "githubRepo", skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub github_repo: Option<String>,
#[serde(rename = "demoUrl", skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "Option::is_none")]
pub demo_url: Option<String>,
#[serde(rename = "createdAt")]
pub created_at: String, // ISO 8601
#[serde(rename = "lastActivity")]
pub created_at: String, // ISO 8601
pub last_activity: String, // ISO 8601
}
@@ -110,46 +109,38 @@ impl DbProject {
// Request types for CRUD operations
#[derive(Debug, Deserialize)]
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateProjectRequest {
pub name: String,
pub slug: Option<String>,
#[serde(rename = "shortDescription")]
pub short_description: String,
pub description: String,
pub status: ProjectStatus,
#[serde(rename = "githubRepo")]
pub github_repo: Option<String>,
#[serde(rename = "demoUrl")]
pub demo_url: Option<String>,
#[serde(rename = "tagIds")]
pub tag_ids: Vec<String>, // UUID strings
}
#[derive(Debug, Deserialize)]
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateProjectRequest {
pub name: String,
pub slug: Option<String>,
#[serde(rename = "shortDescription")]
pub short_description: String,
pub description: String,
pub status: ProjectStatus,
#[serde(rename = "githubRepo")]
pub github_repo: Option<String>,
#[serde(rename = "demoUrl")]
pub demo_url: Option<String>,
#[serde(rename = "tagIds")]
pub tag_ids: Vec<String>, // UUID strings
}
// Admin stats response
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AdminStats {
#[serde(rename = "totalProjects")]
pub total_projects: i32,
#[serde(rename = "projectsByStatus")]
pub projects_by_status: serde_json::Value,
#[serde(rename = "totalTags")]
pub total_tags: i32,
}
+6 -8
View File
@@ -31,16 +31,16 @@ pub struct DbSocialLink {
// API response types
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiSiteIdentity {
#[serde(rename = "displayName")]
pub display_name: String,
pub occupation: String,
pub bio: String,
#[serde(rename = "siteTitle")]
pub site_title: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiSocialLink {
pub id: String,
pub platform: String,
@@ -48,29 +48,28 @@ pub struct ApiSocialLink {
pub value: String,
pub icon: String,
pub visible: bool,
#[serde(rename = "displayOrder")]
pub display_order: i32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiSiteSettings {
pub identity: ApiSiteIdentity,
#[serde(rename = "socialLinks")]
pub social_links: Vec<ApiSocialLink>,
}
// Request types for updates
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSiteIdentityRequest {
#[serde(rename = "displayName")]
pub display_name: String,
pub occupation: String,
pub bio: String,
#[serde(rename = "siteTitle")]
pub site_title: String,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSocialLinkRequest {
pub id: String,
pub platform: String,
@@ -78,14 +77,13 @@ pub struct UpdateSocialLinkRequest {
pub value: String,
pub icon: String,
pub visible: bool,
#[serde(rename = "displayOrder")]
pub display_order: i32,
}
#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UpdateSiteSettingsRequest {
pub identity: UpdateSiteIdentityRequest,
#[serde(rename = "socialLinks")]
pub social_links: Vec<UpdateSocialLinkRequest>,
}
+3
View File
@@ -31,6 +31,7 @@ pub struct DbTagCooccurrence {
// API response types
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiTag {
pub id: String,
pub slug: String,
@@ -42,6 +43,7 @@ pub struct ApiTag {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiTagWithCount {
#[serde(flatten)]
pub tag: ApiTag,
@@ -49,6 +51,7 @@ pub struct ApiTagWithCount {
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ApiRelatedTag {
#[serde(flatten)]
pub tag: ApiTag,