Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion crates/uv-normalize/src/group_name.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "schemars")]
use std::borrow::Cow;
use std::fmt::{Display, Formatter};
use std::path::PathBuf;
use std::str::FromStr;
Expand Down Expand Up @@ -173,14 +175,38 @@ 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,
/// A list of groups
List(Vec<GroupName>),
}

#[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::<GroupName>()
}
]
})
}
}

/// Serialize a [`DefaultGroups`] struct into a list of marker strings.
impl serde::Serialize for DefaultGroups {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down
19 changes: 5 additions & 14 deletions uv.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading