Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Change color representation in json schema

Mikayla Maki6ad0b5d79f86
diff --git a/crates/gpui/src/color.rs b/crates/gpui/src/color.rs
index 7575bbc6d7d..2a0c2c1dc1a 100644
--- a/crates/gpui/src/color.rs
+++ b/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)
- }
-}