diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index d7ff5d52f..49e36b12e 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -253,6 +253,9 @@ jobs: cd api cargo fmt --check - name: Run clippy + env: + # Treat warnings as errors + RUSTFLAGS: "-D warnings" run: | cd api cargo clippy --frozen --quiet diff --git a/api/src/handlers.rs b/api/src/handlers.rs index 7532dd47f..ae4d11555 100644 --- a/api/src/handlers.rs +++ b/api/src/handlers.rs @@ -71,11 +71,11 @@ pub struct View { } #[derive(Serialize, Deserialize, Clone, Debug, FromRow)] -#[allow(non_snake_case)] +#[serde(rename_all = "camelCase")] pub struct Asset { pub name: String, pub key: String, - pub clampToGround: Option, + pub clamp_to_ground: Option, } #[derive(Serialize, Deserialize, Clone, Debug, FromRow)] @@ -86,27 +86,28 @@ pub struct Member { } #[derive(Serialize, Deserialize, Clone, Debug, FromRow)] -#[allow(non_snake_case)] +#[serde(rename_all = "camelCase")] pub struct Geometry { - r#type: String, + #[serde(rename = "type")] + typ: String, positions: Vec, id: Option, name: Option, show: Option, area: Option, perimeter: Option, - sidesLength: Option>, - numberOfSegments: Option, + sides_length: Option>, + number_of_segments: Option, description: Option, image: Option, website: Option, - pointSymbol: Option, + point_symbol: Option, color: Option, - clampPoint: Option, - showSlicingBox: Option, - volumeShowed: Option, - volumeHeightLimits: Option, - swissforagesId: Option, + clamp_point: Option, + show_slicing_box: Option, + volume_showed: Option, + volume_height_limits: Option, + swissforages_id: Option, depth: Option, diameter: Option, editable: Option, @@ -129,9 +130,9 @@ struct CesiumColor { } #[derive(Serialize, Deserialize, Clone, Debug, FromRow)] +#[serde(rename_all = "camelCase")] struct GeometryVolumeHeightLimits { - #[allow(non_snake_case)] - lowerLimit: Number, + lower_limit: Number, height: Number, } @@ -480,7 +481,7 @@ pub async fn duplicate_project( assets.push(Asset { name: asset.name.clone(), key: generated_file_name, - clampToGround: asset.clampToGround, + clamp_to_ground: asset.clamp_to_ground, }); } } @@ -603,5 +604,5 @@ fn generate_asset_name() -> String { .take(40) .map(char::from) .collect(); - return format!("{}_{}.kml", Utc::now().timestamp(), rand_string); + format!("{}_{}.kml", Utc::now().timestamp(), rand_string) }