diff --git a/crates/uv-normalize/src/group_name.rs b/crates/uv-normalize/src/group_name.rs index 124079c08ee32..405907c1fc2ea 100644 --- a/crates/uv-normalize/src/group_name.rs +++ b/crates/uv-normalize/src/group_name.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "schemars")] +use std::borrow::Cow; use std::fmt::{Display, Formatter}; use std::path::PathBuf; use std::str::FromStr; @@ -173,7 +175,6 @@ impl Display for PipGroupName { /// Either the literal "all" or a list of groups #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum DefaultGroups { /// All groups are defaulted All, @@ -181,6 +182,31 @@ pub enum DefaultGroups { List(Vec), } +#[cfg(feature = "schemars")] +impl schemars::JsonSchema for DefaultGroups { + fn schema_name() -> Cow<'static, str> { + Cow::Borrowed("DefaultGroups") + } + + fn json_schema(generator: &mut schemars::generate::SchemaGenerator) -> schemars::Schema { + schemars::json_schema!({ + "description": "Either the literal \"all\" or a list of groups", + "oneOf": [ + { + "description": "All groups are defaulted", + "type": "string", + "const": "all" + }, + { + "description": "A list of groups", + "type": "array", + "items": generator.subschema_for::() + } + ] + }) + } +} + /// Serialize a [`DefaultGroups`] struct into a list of marker strings. impl serde::Serialize for DefaultGroups { fn serialize(&self, serializer: S) -> Result diff --git a/uv.schema.json b/uv.schema.json index d16e4a1aabe14..b475bbd7ad583 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -857,23 +857,14 @@ { "description": "All groups are defaulted", "type": "string", - "const": "All" + "const": "all" }, { "description": "A list of groups", - "type": "object", - "properties": { - "List": { - "type": "array", - "items": { - "$ref": "#/definitions/GroupName" - } - } - }, - "additionalProperties": false, - "required": [ - "List" - ] + "type": "array", + "items": { + "$ref": "#/definitions/GroupName" + } } ] },