Skip to content

Commit 520b3e2

Browse files
committed
fix: add defaults for importance
1 parent fa6d297 commit 520b3e2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/types/mod_json.rs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ pub struct ModJsonLinks {
7474
pub struct ModJsonDependency {
7575
pub id: String,
7676
pub version: String,
77+
#[serde(default)]
7778
pub importance: DependencyImportance,
7879
// This should throw a deprecated error
7980
pub required: Option<bool>,
@@ -83,6 +84,7 @@ pub struct ModJsonDependency {
8384
pub struct ModJsonIncompatibility {
8485
pub id: String,
8586
pub version: String,
87+
#[serde(default)]
8688
pub importance: IncompatibilityImportance,
8789
}
8890

src/types/models/dependency.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ impl Display for ModVersionCompare {
8686
}
8787
}
8888

89-
#[derive(sqlx::Type, Debug, Deserialize, Serialize, Clone, Copy)]
89+
#[derive(sqlx::Type, Debug, Deserialize, Serialize, Clone, Copy, Default)]
9090
#[sqlx(type_name = "dependency_importance", rename_all = "lowercase")]
9191
#[serde(rename_all = "lowercase")]
9292
pub enum DependencyImportance {
9393
Suggested,
9494
Recommended,
95+
#[default]
9596
Required,
9697
}
9798

src/types/models/incompatibility.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashMap;
1+
use std::{collections::HashMap, default};
22

33
use crate::types::api::ApiError;
44
use crate::types::models::dependency::ModVersionCompare;
@@ -45,10 +45,11 @@ pub struct Replacement {
4545
pub incompatibilities: Vec<ResponseIncompatibility>,
4646
}
4747

48-
#[derive(sqlx::Type, Debug, Serialize, Clone, Copy, Deserialize, PartialEq)]
48+
#[derive(sqlx::Type, Debug, Serialize, Clone, Copy, Deserialize, PartialEq, Default)]
4949
#[sqlx(type_name = "incompatibility_importance", rename_all = "lowercase")]
5050
#[serde(rename_all = "lowercase")]
5151
pub enum IncompatibilityImportance {
52+
#[default]
5253
Breaking,
5354
Conflicting,
5455
Superseded,

0 commit comments

Comments
 (0)