diff --git a/crates/uv-pypi-types/src/conflicts.rs b/crates/uv-pypi-types/src/conflicts.rs index 1432099c0..afe6f4a9b 100644 --- a/crates/uv-pypi-types/src/conflicts.rs +++ b/crates/uv-pypi-types/src/conflicts.rs @@ -5,9 +5,7 @@ use uv_normalize::{ExtraName, GroupName, PackageName}; /// This is useful to force the resolver to fork according to extras that have /// unavoidable conflicts with each other. (The alternative is that resolution /// will fail.) -#[derive( - Debug, Default, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, schemars::JsonSchema, -)] +#[derive(Debug, Default, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] pub struct Conflicts(Vec); impl Conflicts { @@ -60,7 +58,7 @@ impl Conflicts { /// /// A `TryFrom>` impl may be used to build a set from a /// sequence. Note though that at least 2 items are required. -#[derive(Debug, Default, Clone, Eq, PartialEq, serde::Serialize, schemars::JsonSchema)] +#[derive(Debug, Default, Clone, Eq, PartialEq, serde::Serialize)] pub struct ConflictSet(Vec); impl ConflictSet { @@ -120,16 +118,7 @@ impl TryFrom> for ConflictSet { /// Each item is a pair of a package and a corresponding extra name for that /// package. #[derive( - Debug, - Clone, - Eq, - Hash, - PartialEq, - PartialOrd, - Ord, - serde::Deserialize, - serde::Serialize, - schemars::JsonSchema, + Debug, Clone, Eq, Hash, PartialEq, PartialOrd, Ord, serde::Deserialize, serde::Serialize, )] #[serde( deny_unknown_fields, @@ -252,7 +241,7 @@ impl hashbrown::Equivalent for ConflictItemRef<'_> { /// The actual conflicting data for a package. /// /// That is, either an extra or a group name. -#[derive(Debug, Clone, Eq, Hash, PartialEq, PartialOrd, Ord, schemars::JsonSchema)] +#[derive(Debug, Clone, Eq, Hash, PartialEq, PartialOrd, Ord)] pub enum ConflictPackage { Extra(ExtraName), Group(GroupName), @@ -426,7 +415,7 @@ impl SchemaConflicts { /// schema format does not allow specifying the package name (or will make it /// optional in the future), where as the in-memory format needs the package /// name. -#[derive(Debug, Default, Clone, Eq, PartialEq, serde::Serialize, schemars::JsonSchema)] +#[derive(Debug, Default, Clone, Eq, PartialEq, schemars::JsonSchema, serde::Serialize)] pub struct SchemaConflictSet(Vec); /// Like [`ConflictItem`], but for deserialization in `pyproject.toml`. @@ -436,16 +425,7 @@ pub struct SchemaConflictSet(Vec); /// optional in the future), where as the in-memory format needs the package /// name. #[derive( - Debug, - Clone, - Eq, - Hash, - PartialEq, - PartialOrd, - Ord, - serde::Deserialize, - serde::Serialize, - schemars::JsonSchema, + Debug, Clone, Eq, Hash, PartialEq, PartialOrd, Ord, serde::Deserialize, serde::Serialize, )] #[serde( deny_unknown_fields, @@ -457,6 +437,16 @@ pub struct SchemaConflictItem { conflict: ConflictPackage, } +impl schemars::JsonSchema for SchemaConflictItem { + fn schema_name() -> String { + "SchemaConflictItem".to_string() + } + + fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { + ::json_schema(gen) + } +} + impl<'de> serde::Deserialize<'de> for SchemaConflictSet { fn deserialize(deserializer: D) -> Result where @@ -480,7 +470,11 @@ impl TryFrom> for SchemaConflictSet { } } -#[derive(Debug, serde::Deserialize, serde::Serialize)] +/// A single item in a conflicting set. +/// +/// Each item is a pair of an (optional) package and a corresponding extra or group name for that +/// package. +#[derive(Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)] struct ConflictItemWire { #[serde(default)] package: Option, diff --git a/uv.schema.json b/uv.schema.json index f77083871..370d59dc2 100644 --- a/uv.schema.json +++ b/uv.schema.json @@ -623,35 +623,6 @@ "$ref": "#/definitions/ConfigSettingValue" } }, - "ConflictPackage": { - "description": "The actual conflicting data for a package.\n\nThat is, either an extra or a group name.", - "oneOf": [ - { - "type": "object", - "required": [ - "Extra" - ], - "properties": { - "Extra": { - "$ref": "#/definitions/ExtraName" - } - }, - "additionalProperties": false - }, - { - "type": "object", - "required": [ - "Group" - ], - "properties": { - "Group": { - "$ref": "#/definitions/GroupName" - } - }, - "additionalProperties": false - } - ] - }, "ExcludeNewer": { "description": "Exclude distributions uploaded after the given timestamp.\n\nAccepts both RFC 3339 timestamps (e.g., `2006-12-02T02:07:43Z`) and local dates in the same format (e.g., `2006-12-02`).", "type": "string", @@ -1454,16 +1425,33 @@ ] }, "SchemaConflictItem": { - "description": "Like [`ConflictItem`], but for deserialization in `pyproject.toml`.\n\nThe schema format is different from the in-memory format. Specifically, the schema format does not allow specifying the package name (or will make it optional in the future), where as the in-memory format needs the package name.", + "description": "A single item in a conflicting set.\n\nEach item is a pair of an (optional) package and a corresponding extra or group name for that package.", "type": "object", - "required": [ - "conflict" - ], "properties": { - "conflict": { - "$ref": "#/definitions/ConflictPackage" + "extra": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/ExtraName" + }, + { + "type": "null" + } + ] + }, + "group": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/GroupName" + }, + { + "type": "null" + } + ] }, "package": { + "default": null, "anyOf": [ { "$ref": "#/definitions/PackageName" @@ -1473,8 +1461,7 @@ } ] } - }, - "additionalProperties": false + } }, "SchemaConflictSet": { "description": "Like [`ConflictSet`], but for deserialization in `pyproject.toml`.\n\nThe schema format is different from the in-memory format. Specifically, the schema format does not allow specifying the package name (or will make it optional in the future), where as the in-memory format needs the package name.",