Change color representation in json schema

Mikayla Maki created

Change summary

crates/gpui/src/color.rs | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)

Detailed changes

crates/gpui/src/color.rs 🔗

@@ -6,20 +6,16 @@ use std::{
 
 use crate::json::ToJson;
 use pathfinder_color::{ColorF, ColorU};
-use schemars::{
-    gen::SchemaGenerator,
-    schema::{InstanceType, Schema, SchemaObject},
-    JsonSchema,
-};
+use schemars::JsonSchema;
 use serde::{
     de::{self, Unexpected},
     Deserialize, Deserializer,
 };
 use serde_json::json;
 
-#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
+#[derive(Clone, Copy, Default, PartialEq, Eq, Hash, PartialOrd, Ord, JsonSchema)]
 #[repr(transparent)]
-pub struct Color(ColorU);
+pub struct Color(#[schemars(with = "String")] ColorU);
 
 impl Color {
     pub fn transparent_black() -> Self {
@@ -132,16 +128,3 @@ impl fmt::Debug for Color {
         self.0.fmt(f)
     }
 }
-
-impl JsonSchema for Color {
-    fn schema_name() -> String {
-        "Color".into()
-    }
-
-    fn json_schema(_: &mut SchemaGenerator) -> Schema {
-        let mut schema = SchemaObject::default();
-        schema.instance_type = Some(InstanceType::Integer.into());
-        schema.format = Some("uint".to_owned());
-        Schema::Object(schema)
-    }
-}